forked from wjhwsh/VideoPlayer-iOS
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAVPacketQueue.h
79 lines (65 loc) · 1.84 KB
/
AVPacketQueue.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
//
// FFAVPacketQueue.h
// FFmpegPlayTest
//
// Created by Jack on 11/12/12.
// Copyright (c) 2012 Jack. All rights reserved.
//
/*
TODO: Implement queue as fixed size queue
in current version, the size of queue is automatically increase if the writing
process is faster than reading process. It may cause the increasement of memory
usage if there is a problem that blocks reading thread.
To implement fixed size queue, there should be condition wait inside putPacket
method waiting for a signal from reading process.
*/
#import <Foundation/Foundation.h>
#import "FFmpeg.h"
@interface AVPacketQueue : NSObject
{
@private
AVPacketList *_firstPacket;
AVPacketList *_lastPacket;
NSInteger _count;
/**
Total size of all the packets' data
*/
NSInteger _dataSize;
/**
Maximum dataSize
*/
int _maxDataSize;
/**
Maximum of total size of all packets' data,
when _dataSize > _queueSize, writing to queue should
be disabled.
*/
NSInteger _queueSize;
// Thread-safe
//pthread_mutex_t mutex;
//pthread_cond_t condition;
NSCondition* _condition;
}
@property (nonatomic, readonly) NSInteger count;
@property (nonatomic, readonly) NSInteger dataSize;
@property (nonatomic) NSInteger queueSize;
- (id) initWithSize: (NSInteger) size;
/**
Get packet from queue thread-safely
outPacket: output packet
block : should block the process to wait until there is packet available.
*/
- (int) popPacket: (AVPacket*) outPacket
blocked: (BOOL) blocked;
/**
Get packet from queue thread-safely
inPacket : input packet
block : should block the process to wait until there is space for new packet.
*/
- (int) pushPacket: (AVPacket*) inPacket
blocked:(BOOL) blocked;
/**
Flush all the packets in the queue.
*/
- (void) flush;
@end