c - How to simulate push and pop on iOS
PHP中文网
PHP中文网 2017-07-01 09:12:26
0
3
1162

When processing live video, you need to save charinto a container, take it out and play it. Android people have implemented it using a queue, but iOS queue does not seem to have this function. I have tried converting charIt is an OC object and then saved into an array. The data is retrieved and played by traversing the array. Of course, traversing the array must be placed in a sub-thread. This implementation method is no problem at the beginning, but it needs to continuously traverse the array. After traversing for a while, it will automatically stop. No longer traversing the array
Do you have any good methods to solve this function? The following is the specific operation

// This is adding an array to the array
char *p = new char[ilen 1];
memcpy(p, data, ilen);

NSData *data= [NSData dataWithBytes:p length:ilen];

[clientManager.dataArr addObject:data];

// This is traversing the array
[clientManager.dataArr enumerateObjectsUsingBlock:^(id _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {

int fragment_type; NSLog(@"+++++++++++%lu",(unsigned long)clientManager.dataArr.count); NSData *data = clientManager.dataArr[0]; [clientManager.dataArr removeObjectAtIndex:0]; char* Framebuf= (char*)[data bytes]; NSLog(@"2<><><><><>>%s",Framebuf); int head_size = sizeof(FRAME_HEAD); FRAME_HEAD *frameHead = new FRAME_HEAD; memcpy(frameHead, Framebuf, head_size); int frameType = frameHead->iFrameType;
PHP中文网
PHP中文网

认证0级讲师

reply all (3)
过去多啦不再A梦

How can you push in and out of the stack? The characteristic of the stack is first in, last out. You put the live broadcast data into an array. Isn't it streaming? You keep putting it in, and you take it out from 0. How can you use a stack to achieve this? In and out later, the old data cannot be used

    代言

    You can refer to the following method
    How do I make and use a Queue in Objective-C?
    Objective-C queue implementation

      我想大声告诉你

      It’s not a live broadcast, it’s a replay. The C++ side can’t handle it. Sending commands to C++ and then to the cloud terminal requires a process, so we need to handle it

        Latest Downloads
        More>
        Web Effects
        Website Source Code
        Website Materials
        Front End Template
        About us Disclaimer Sitemap
        php.cn:Public welfare online PHP training,Help PHP learners grow quickly!