GVKun编程网logo

AVCaptureSession和相机线程没有关闭[iOS](相机的avchd)

1

此处将为大家介绍关于AVCaptureSession和相机线程没有关闭[iOS]的详细内容,并且为您解答有关相机的avchd的相关问题,此外,我们还将为您介绍关于AndroidStudio制作的Flu

此处将为大家介绍关于AVCaptureSession和相机线程没有关闭[iOS]的详细内容,并且为您解答有关相机的avchd的相关问题,此外,我们还将为您介绍关于Android Studio 制作的 Flutter Project 可以在 iOs 上实现 在你的 iOS 设备上测试你的 Flutter iOS 应用、Apple 不再在 iOS 16.2 发布之前签署 iOS 16.1 和 iOS 16.1.1、C++ write and read file via fstream in ios::out,ios::in,ios::app mode、iOS 11 开发教程(三)运行第一个 iOS 11 程序的有用信息。

本文目录一览:

AVCaptureSession和相机线程没有关闭[iOS](相机的avchd)

AVCaptureSession和相机线程没有关闭[iOS](相机的avchd)

问题
当我停止运行AVCaptureSession时,我的AVCaptureSession期间创建的线程不会关闭.

症状
通常我的dispatch_queue会立即开始从相机获取帧.但是打开和关闭打开/关闭AVCaptureSession的ViewController大约四次后,dispatch_queue大约需要十秒钟才能启动.

预测
似乎与AVCaptureSession关联的线程未清除.

关闭AVCaptureSession后,我看到这些线程仍然存在:

com.apple.coremedia.capturesource.connections(serial) 1 Pending Block
com.apple.coremedia.capturesession.connections(serial) 1 Pending Block
<AVCMNotificationdispatcher: 0x16bce00> serial queue(serial) 4 Pending Blocks
com.apple.avfoundation.videocapturedevice.observed_properties_queue(serial)
com.apple.tcc.cache_queue(serial) 1 Pending Block
com.apple.tcc.preflight.kTCCServiceCamera(serial) 1 Pending Block

在我使用AVCaptureSession打开/关闭ViewController之后,仍保留相同的线程,但是这三个线程的Pending块数量增加了

<AVCMNotificationdispatcher: 0x17c441a0> serial queue (serial) 9 Pending Blocks
com.apple.avfoundation.videocapturedevice.observed_properties_queue(serial)
com.apple.tcc.preflight.kTCCServiceCamera(serial)  5 Pending Blocks

代码设置

VideoSource.h和VideoSource.mm

在我的ViewController中,我将它初始化为:

self.videoSource = [[VideoSource alloc] init];
self.videoSource.delegate = self;
[self.videoSource setResolution:AVCaptureSessionPreset352x288]; // was 640
[self.videoSource startWithDevicePosition:AVCaptureDevicePositionFront];

我开始和停止captureSession如下,它开始和停止非常好.实际的帧抓取效果非常好.

[self.videoSource.captureSession startRunning];
    [self.videoSource.captureSession stopRunning];

VideoSource的相关部分,如果您需要了解更多,请告诉我.

来自VideoSource.mm

- (void)dealloc {
NSLog(@"Cleaning Up Video Source");
[_captureSession stopRunning];

AVCaptureInput* input = [_captureSession.inputs objectAtIndex:0];
[_captureSession removeInput:input];
input = nil;

AVCaptureVideoDataOutput* output = (AVCaptureVideoDataOutput*)[_captureSession.outputs objectAtIndex:0];
[_captureSession removeOutput:output];
output = nil;

_captureSession = nil;
_deviceInput = nil;
_delegate = nil;

//  [super dealloc]; // compiler handles this for you with ARC
}


- (void) addVideoDataOutput {
// (1) Instantiate a new video data output object
AVCaptureVideoDataOutput * captureOutput = [[AVCaptureVideoDataOutput alloc] init ];
//    captureOutput.alwaysdiscardsLateVideoFrames = YES;

NSLog(@"Create dispatch Queue");


// (2) The sample buffer delegate requires a serial dispatch queue
dispatch_queue_t queue;
queue = dispatch_queue_create("com.name.test",disPATCH_QUEUE_SERIAL);
[captureOutput setSampleBufferDelegate:self queue:queue];

//    dispatch_release(queue); // compiler handles this for you with ARC

// (3) Define the pixel format for the video data output
Nsstring * key = (Nsstring*)kCVPixelBufferPixelFormatTypeKey;
NSNumber * value = [NSNumber numberWithUnsignedInt:kCVPixelFormatType_32BGRA];
NSDictionary * settings = @{key:value};

NSLog(@"Set Video Settings");

[captureOutput setVideoSettings:settings];

NSLog(@"Always discard Late Video Frames");

[captureOutput setAlwaysdiscardsLateVideoFrames:YES];
// (4) Configure the output port on the captureSession property

[self.captureSession addOutput:captureOutput];
}

来自VideoSource.h

@interface VideoSource : NSObject

@property (nonatomic,strong) AVCaptureSession * captureSession;  
@property (nonatomic,strong) AVCaptureDeviceInput * deviceInput;
@property (nonatomic,weak) id<VideoSourceDelegate> delegate;

- (BOOL)startWithDevicePosition:(AVCaptureDevicePosition)devicePosition;
- (void) setResolution:(Nsstring*)resolution;

@end

请求

当我取消分配VideoSource时,如何确保这些线程关闭?

解决方法@H_301_62@
解决了!

解决方案:从与用于captureOutput的SampleBuffer队列相同的dispatch_queue调用startRunning和stopRunning.

这是我的新设置:

#import "VideoSource.h"

@interface VideoSource () <AVCaptureVideoDataOutputSampleBufferDelegate>

// Session management.
@property (nonatomic) dispatch_queue_t sessionQueue;
@property (nonatomic) AVCaptureSession *captureSession;
@property (nonatomic) AVCaptureDeviceInput *deviceInput;

/*@property (nonatomic,strong) AVCaptureSession * captureSession;
@property (nonatomic,strong) AVCaptureDeviceInput * deviceInput; */

@end

@implementation VideoSource


-(id) init{
    if(self = [super init]){
        self.captureSession = [[AVCaptureSession alloc] init];
        self.sessionQueue = dispatch_queue_create( "session queue",disPATCH_QUEUE_SERIAL );

    }
    return self;
}

然后为setSampleBufferDelegate队列使用相同的sessionQueue.

[captureOutput setSampleBufferDelegate:self queue:self.sessionQueue];

现在,对于最重要的部分,请确保从SAME队列中调用startRunning / stopRunning:

dispatch_async( self.sessionQueue,^{
    [self.captureSession startRunning];

});

同样,您可以创建一个很好的小函数来清理并停止captureSession:

-(void)closeCaptureSession {

     dispatch_async(self.sessionQueue,^{

         if([_captureSession isRunning])[_captureSession stopRunning];

         [_captureSession stopRunning];

         // Remove all inputs
         for(AVCaptureInput *input1 in _captureSession.inputs) {
             [_captureSession removeInput:input1];
         }

         // Remove all outputs
         for(AVCaptureVideoDataOutput *output1 in _captureSession.outputs) {
             [output1 setSampleBufferDelegate:nil queue:NULL];
             [_captureSession removeOutput:output1];
         }

         // Set to Nil to make ARC's job a little easier
         self.captureSession = nil;
         self.deviceInput = nil;
         self.delegate = nil;
         self.sessionQueue=nil;
     });

}

Android Studio 制作的 Flutter Project 可以在 iOs 上实现 在你的 iOS 设备上测试你的 Flutter iOS 应用

Android Studio 制作的 Flutter Project 可以在 iOs 上实现 在你的 iOS 设备上测试你的 Flutter iOS 应用

如何解决Android Studio 制作的 Flutter Project 可以在 iOs 上实现 在你的 iOS 设备上测试你的 Flutter iOS 应用

我对我的项目有疑问我终于从我在 Android Studio 上的 Flutter 项目中完成了,并在许多 android 设备上测试了它,现在我需要打开同一个项目并在 iOs 上测试它,我的问题是:-

  1. 我是否应该更改代码或文件中的某些内容以在 Xcode 上打开它?
  2. 我可以发布到 ipa 吗?

解决方法

在你的 iOS 设备上测试你的 Flutter iOS 应用

您只需按照以下步骤操作:

  1. Runner.xcworkspace 文件放在项目文件夹的 ios 文件夹中
  2. 双击打开该项目,它将在 Xcode 中启动(如果您安装了 Xcode)
  3. 然后使用 USB 数据线将您的 iOS 设备(实际手机)连接到 Xcode/MacBook
  4. 另外,不要忘记分别配置 TeamBundle Identifier(如果您对 Bundle Identifier 有任何问题):

Signing & Capabilities中,将Team更改为Personal(例如);

General 中,将 Bundle Identifier 编辑为独特的

最后,您可以运行该应用了!

,

对于 iOS,这有点复杂,因为您需要 Apple ID 或注册“开发者帐户”:

打开 XCode,然后打开“Preferences>Accounts”。使用您的 ID 登录。 “管理证书”> 单击“+”号并选择“iOS 开发”。 将您的设备插入您的机器。在下拉菜单中找到您的设备(窗口 > 管理器)。 在团队弹出菜单下方,单击修复问题。 在 Xcode 中,单击运行按钮。 (在后续运行中,您可以使用 Android Studio、VS Code 或任何其他选择的 IDE 部署到 iOS 设备,您只需要在第一次使用 Xcode 设置该证书。这是 Apple 的文档关于设置 Xcode 以运行物理设备。)

详情请点击链接How do I run/test my Flutter app on a real device?

Apple 不再在 iOS 16.2 发布之前签署 iOS 16.1 和 iOS 16.1.1

Apple 不再在 iOS 16.2 发布之前签署 iOS 16.1 和 iOS 16.1.1

继 ios 16.1.2 于 11 月 30 日发布后,apple 现已停止签署 ios 16.1 和 ios 16.1.1。iphone 和 ipad 用户不能再从操作系统升级到 ios 16.1.2 或更高版本之后的旧版本。

Apple 不再签署 iOS 16.1 和 iOS 16.1.1

iOS 16.1于 10 月发布,具有多项新功能和增强功能,例如 iCloud 共享照片库、适用于 iPhone 用户的 Fitness+、Live Activities 等。在11月份发布的iOS 16.1.1修复了缺陷并改进了安全性。

然后,在 11 月 30 日,Apple 发布了 iOS 16.1.2,以增强 iPhone 14 的崩溃检测功能,并提高无线运营商的兼容性。这是目前正式提供给用户的最新iOS版本。

与此同时,苹果即将在未来几天向公众发布iOS 16.2 。该更新将添加新的 Freeform 应用程序、对 Home 应用程序的改进、面向 iPhone 14 Pro 用户的新的永远在线选项、Apple Music Sing 等。

经常有越狱的iPhone和iPad用户恢复到旧版本的iOS。目前还没有任何迹象显示正在开发适用于 iOS 16 的越狱工具。将 Apple 设备恢复到以前版本的 iOS 有时也会对升级到最新版本的 iOS 后遇到重大错误的用户有所帮助。

从 iOS 16 降级到 iOS 15

即使您无法轻松恢复到iOS 16.1版本,仍有可能将您的设备降级至iOS 15版本以上。Apple正在为使用iOS 15.7.1的用户提供安全更新,导致此情况发生。如果想将 iPhone 或 iPad 降级,就必须使用 Mac 或 PC。

这不是苹果第一次提供让用户继续使用旧版 iOS 的选项。去年,一旦 iOS 15 可用, 用户可以选择在 iOS 14 上停留更长时间 ,而苹果仍在为其发布安全更新。然而, 该公司在几个月后取消了这个选项。

目前尚不清楚 iOS 15.7.1 作为 iOS 16 的替代选项将保留多长时间。

以上就是Apple 不再在 iOS 16.2 发布之前签署 iOS 16.1 和 iOS 16.1.1的详细内容,更多请关注php中文网其它相关文章!

C++ write and read file via fstream in ios::out,ios::in,ios::app mode

C++ write and read file via fstream in ios::out,ios::in,ios::app mode

#include <iostream>
#include <uuid/uuid.h>
#include <ostream>
#include <istream>
#include <fstream>
#include <iostream>

using namespace std;

void retrieveUuid(char *uuidValue);
void writeFile2();
void readFile3();

int main()
{
    writeFile2(); 
    readFile3();
    return 0;
}

void readFile3()
{
    fstream wFile;
    wFile.open("log3.txt",ios::app|ios::in|ios::out);
    if(!wFile.is_open())
    {
        cout<<"Create or open log3.txt Failed!"<<endl;
    }

    string uuidValue;
    int num=0;
    while(getline(wFile,uuidValue))
    { 
        cout<<"Id="<<++num<<",value="<<uuidValue<<endl;
    } 
    wFile.close();
    printf("Finished!\n");
}

void writeFile2()
{
    fstream wFile;
    wFile.open("log3.txt",ios::app|ios::out|ios::in);
    if(!wFile.is_open())
    {
        cout<<"Create or open log3.txt Failed!"<<endl;
    }

    char *uuidValue=(char*)malloc(40);
    for(int i=0;i<10000;i++)
    {
        retrieveUuid(uuidValue);
        wFile<<uuidValue<<endl;
    }
    free(uuidValue);   
    wFile.close(); 
}

void retrieveUuid(char *uuidValue)
{
    uuid_t newUUID;
    uuid_generate(newUUID);
    uuid_unparse(newUUID,uuidValue);
}

Complile and run

g++ -g -std=c++2a h2.cpp -o h2 -luuid

Run the ./h2 command

./h2

 

 

iOS 11 开发教程(三)运行第一个 iOS 11 程序

iOS 11 开发教程(三)运行第一个 iOS 11 程序

iOS 11 开发教程(三)运行第一个 iOS 11 程序

运行 iOS11 程序

创建好项目之后,就可以运行这个项目中的程序了。单击运行按钮,如果程序没有任何问题的话,会看到如图 1.6 和 1.7 的运行效果。

图 1.6  运行效果                         图 1.7  运行效果

注意:由于没有对程序进行编写,也没有对编辑界面进行设置,所有这时运行结果是不会产生任何效果的。对于编辑界面会在后面做一个详细的介绍。

其中,图 1.6 是应用程序的一个启动界面,它是系统自带的,在 Xcode 7.0 的测试版中是对此界面进行设计的,但是在 Xcode 7.0 的正式版以及以后的版本中此界面是没有进行设计的。运行程序后,会在此界面停留几秒,然后进入应用程序的主界面,也就是开发者真正要使用到的界面,即图 1.7 所示的界面。如果开发者不想在程序运行时有启动界面,可以打开 Info.plist 文件,在此文件中找到 Launch screen interface file base name,将其 value 后面的内容删除,如图 1.8 所示,

图 1.8  Info.plist 文件

关于AVCaptureSession和相机线程没有关闭[iOS]相机的avchd的问题我们已经讲解完毕,感谢您的阅读,如果还想了解更多关于Android Studio 制作的 Flutter Project 可以在 iOs 上实现 在你的 iOS 设备上测试你的 Flutter iOS 应用、Apple 不再在 iOS 16.2 发布之前签署 iOS 16.1 和 iOS 16.1.1、C++ write and read file via fstream in ios::out,ios::in,ios::app mode、iOS 11 开发教程(三)运行第一个 iOS 11 程序等相关内容,可以在本站寻找。

本文标签: