-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvideo_queue.c
100 lines (84 loc) · 2.11 KB
/
video_queue.c
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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
#include <libavcodec/avcodec.h>
#include <libavformat/avformat.h>
#include <libavutil/opt.h>
#include <libavutil/pixdesc.h>
#include <libavutil/avutil.h>
#include "debug_tools.h"
#include "file.h"
#include "filters/filter.h"
#include "video_queue.h"
#include <libavutil/time.h>
#include <pthread.h>
video_queue *video_queue_create()
{
video_queue *queue = calloc(1, sizeof(video_queue));
if (queue == NULL)
{
return NULL;
}
queue->next = NULL;
queue->video = NULL;
queue->status = VIDEO_QUEUE_STATUS_UNDEFINED;
return queue;
}
void video_queue_print(video_queue *queue)
{
if (queue == NULL)
{
printf("NULL\n");
return;
}
printf("%i->", queue->status);
video_queue_print(queue->next);
}
// free video_queue
void video_queue_free(video_queue *vq)
{
if (!vq)
return;
if (vq->video)
file_free(vq->video);
video_queue_free(vq->next);
free(vq);
}
// append new to end of root
video_queue *video_queue_append(video_queue *root, video_queue *new)
{
if (root == NULL)
return new;
root->next = video_queue_append(root->next, new);
return root;
}
// TESTS
void *video_queue_run(void *_vq)
{
vq_run *vq_run = _vq;
video_queue **vq = vq_run->vq;
filters_path **extra_filters = vq_run->extra_filters;
video_queue **curr = vq;
while (1)
{
printf("%p %p\n", curr, curr[0]);
printf("WAITING FOR NEW INPUT\n");
av_usleep(1000000);
if (curr[0] == NULL)
continue;
switch (curr[0]->status)
{
case VIDEO_QUEUE_STATUS_UNDEFINED:
continue;
case VIDEO_QUEUE_STATUS_TRANSCODING:
case VIDEO_QUEUE_STATUS_DONE:
case VIDEO_QUEUE_STATUS_FREE:
curr = &curr[0]->next;
continue;
case VIDEO_QUEUE_STATUS_WAITING:
curr[0]->status = VIDEO_QUEUE_STATUS_TRANSCODING;
file_stream(curr[0]->video, extra_filters);
curr[0]->status = VIDEO_QUEUE_STATUS_DONE;
continue;
case VIDEO_QUEUE_STATUS_END:
return NULL;
}
}
}