Mercurial > mplayer.hg
annotate edl.c @ 29881:5797dc687a8e
Add preliminary support for streaming via FFmpeg's URProtocol functions.
Basic playback tested for file and http protocols.
author | reimar |
---|---|
date | Tue, 17 Nov 2009 16:09:17 +0000 |
parents | 0f1b5b68af32 |
children | c1a3f1bbba26 |
rev | line source |
---|---|
13168 | 1 #include <stdio.h> |
2 #include <stdlib.h> | |
3 #include "config.h" | |
4 #include "mp_msg.h" | |
5 #include "edl.h" | |
13358
567875b88aab
Hardcoded EDL messages moved to help_mp-en.h, Doxygen comments added, patch
diego
parents:
13168
diff
changeset
|
6 #include "help_mp.h" |
13168 | 7 |
14607
7a80c6ac5058
several sets of headers declare global variables in them, which causes multiple definition errors with gcc 4.x
iive
parents:
13358
diff
changeset
|
8 char *edl_filename; // file to extract EDL entries from (-edl) |
7a80c6ac5058
several sets of headers declare global variables in them, which causes multiple definition errors with gcc 4.x
iive
parents:
13358
diff
changeset
|
9 char *edl_output_filename; // file to put EDL entries in (-edlout) |
7a80c6ac5058
several sets of headers declare global variables in them, which causes multiple definition errors with gcc 4.x
iive
parents:
13358
diff
changeset
|
10 |
13358
567875b88aab
Hardcoded EDL messages moved to help_mp-en.h, Doxygen comments added, patch
diego
parents:
13168
diff
changeset
|
11 /** |
14807
664b06b907cb
Some to-be-redundant EDL code moved to edl.c with mencoder's edl in mind. Stack handling improvements, Patch by Oded Shimon
reynaldo
parents:
14607
diff
changeset
|
12 * Allocates a new EDL record and makes sure allocation was successful. |
664b06b907cb
Some to-be-redundant EDL code moved to edl.c with mencoder's edl in mind. Stack handling improvements, Patch by Oded Shimon
reynaldo
parents:
14607
diff
changeset
|
13 * |
664b06b907cb
Some to-be-redundant EDL code moved to edl.c with mencoder's edl in mind. Stack handling improvements, Patch by Oded Shimon
reynaldo
parents:
14607
diff
changeset
|
14 * \return New allocated EDL record. |
664b06b907cb
Some to-be-redundant EDL code moved to edl.c with mencoder's edl in mind. Stack handling improvements, Patch by Oded Shimon
reynaldo
parents:
14607
diff
changeset
|
15 * \brief Allocate new EDL record |
13358
567875b88aab
Hardcoded EDL messages moved to help_mp-en.h, Doxygen comments added, patch
diego
parents:
13168
diff
changeset
|
16 */ |
567875b88aab
Hardcoded EDL messages moved to help_mp-en.h, Doxygen comments added, patch
diego
parents:
13168
diff
changeset
|
17 |
14807
664b06b907cb
Some to-be-redundant EDL code moved to edl.c with mencoder's edl in mind. Stack handling improvements, Patch by Oded Shimon
reynaldo
parents:
14607
diff
changeset
|
18 static edl_record_ptr edl_alloc_new(edl_record_ptr next_edl_record) |
13168 | 19 { |
14807
664b06b907cb
Some to-be-redundant EDL code moved to edl.c with mencoder's edl in mind. Stack handling improvements, Patch by Oded Shimon
reynaldo
parents:
14607
diff
changeset
|
20 edl_record_ptr new_record = calloc(1, sizeof(struct edl_record)); |
664b06b907cb
Some to-be-redundant EDL code moved to edl.c with mencoder's edl in mind. Stack handling improvements, Patch by Oded Shimon
reynaldo
parents:
14607
diff
changeset
|
21 if (!new_record) { |
664b06b907cb
Some to-be-redundant EDL code moved to edl.c with mencoder's edl in mind. Stack handling improvements, Patch by Oded Shimon
reynaldo
parents:
14607
diff
changeset
|
22 mp_msg(MSGT_CPLAYER, MSGL_FATAL, MSGTR_EdlOutOfMem); |
664b06b907cb
Some to-be-redundant EDL code moved to edl.c with mencoder's edl in mind. Stack handling improvements, Patch by Oded Shimon
reynaldo
parents:
14607
diff
changeset
|
23 exit(1); |
664b06b907cb
Some to-be-redundant EDL code moved to edl.c with mencoder's edl in mind. Stack handling improvements, Patch by Oded Shimon
reynaldo
parents:
14607
diff
changeset
|
24 } |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
18904
diff
changeset
|
25 |
14807
664b06b907cb
Some to-be-redundant EDL code moved to edl.c with mencoder's edl in mind. Stack handling improvements, Patch by Oded Shimon
reynaldo
parents:
14607
diff
changeset
|
26 if (next_edl_record) // if this isn't the first record, tell the previous one what the new one is. |
664b06b907cb
Some to-be-redundant EDL code moved to edl.c with mencoder's edl in mind. Stack handling improvements, Patch by Oded Shimon
reynaldo
parents:
14607
diff
changeset
|
27 next_edl_record->next = new_record; |
664b06b907cb
Some to-be-redundant EDL code moved to edl.c with mencoder's edl in mind. Stack handling improvements, Patch by Oded Shimon
reynaldo
parents:
14607
diff
changeset
|
28 new_record->prev = next_edl_record; |
17802 | 29 new_record->next = NULL; |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
18904
diff
changeset
|
30 |
14807
664b06b907cb
Some to-be-redundant EDL code moved to edl.c with mencoder's edl in mind. Stack handling improvements, Patch by Oded Shimon
reynaldo
parents:
14607
diff
changeset
|
31 return new_record; |
664b06b907cb
Some to-be-redundant EDL code moved to edl.c with mencoder's edl in mind. Stack handling improvements, Patch by Oded Shimon
reynaldo
parents:
14607
diff
changeset
|
32 } |
13168 | 33 |
14807
664b06b907cb
Some to-be-redundant EDL code moved to edl.c with mencoder's edl in mind. Stack handling improvements, Patch by Oded Shimon
reynaldo
parents:
14607
diff
changeset
|
34 /** |
664b06b907cb
Some to-be-redundant EDL code moved to edl.c with mencoder's edl in mind. Stack handling improvements, Patch by Oded Shimon
reynaldo
parents:
14607
diff
changeset
|
35 * Goes through entire EDL records and frees all memory. |
664b06b907cb
Some to-be-redundant EDL code moved to edl.c with mencoder's edl in mind. Stack handling improvements, Patch by Oded Shimon
reynaldo
parents:
14607
diff
changeset
|
36 * Assumes next_edl_record is valid or NULL. |
664b06b907cb
Some to-be-redundant EDL code moved to edl.c with mencoder's edl in mind. Stack handling improvements, Patch by Oded Shimon
reynaldo
parents:
14607
diff
changeset
|
37 * |
664b06b907cb
Some to-be-redundant EDL code moved to edl.c with mencoder's edl in mind. Stack handling improvements, Patch by Oded Shimon
reynaldo
parents:
14607
diff
changeset
|
38 * \brief Free EDL memory |
664b06b907cb
Some to-be-redundant EDL code moved to edl.c with mencoder's edl in mind. Stack handling improvements, Patch by Oded Shimon
reynaldo
parents:
14607
diff
changeset
|
39 */ |
13168 | 40 |
14807
664b06b907cb
Some to-be-redundant EDL code moved to edl.c with mencoder's edl in mind. Stack handling improvements, Patch by Oded Shimon
reynaldo
parents:
14607
diff
changeset
|
41 void free_edl(edl_record_ptr next_edl_record) |
664b06b907cb
Some to-be-redundant EDL code moved to edl.c with mencoder's edl in mind. Stack handling improvements, Patch by Oded Shimon
reynaldo
parents:
14607
diff
changeset
|
42 { |
664b06b907cb
Some to-be-redundant EDL code moved to edl.c with mencoder's edl in mind. Stack handling improvements, Patch by Oded Shimon
reynaldo
parents:
14607
diff
changeset
|
43 edl_record_ptr tmp; |
664b06b907cb
Some to-be-redundant EDL code moved to edl.c with mencoder's edl in mind. Stack handling improvements, Patch by Oded Shimon
reynaldo
parents:
14607
diff
changeset
|
44 while (next_edl_record) { |
664b06b907cb
Some to-be-redundant EDL code moved to edl.c with mencoder's edl in mind. Stack handling improvements, Patch by Oded Shimon
reynaldo
parents:
14607
diff
changeset
|
45 tmp = next_edl_record->next; |
664b06b907cb
Some to-be-redundant EDL code moved to edl.c with mencoder's edl in mind. Stack handling improvements, Patch by Oded Shimon
reynaldo
parents:
14607
diff
changeset
|
46 free(next_edl_record); |
664b06b907cb
Some to-be-redundant EDL code moved to edl.c with mencoder's edl in mind. Stack handling improvements, Patch by Oded Shimon
reynaldo
parents:
14607
diff
changeset
|
47 next_edl_record = tmp; |
13168 | 48 } |
49 } | |
50 | |
13358
567875b88aab
Hardcoded EDL messages moved to help_mp-en.h, Doxygen comments added, patch
diego
parents:
13168
diff
changeset
|
51 /** Parses edl_filename to fill EDL operations queue. |
14807
664b06b907cb
Some to-be-redundant EDL code moved to edl.c with mencoder's edl in mind. Stack handling improvements, Patch by Oded Shimon
reynaldo
parents:
14607
diff
changeset
|
52 * Prints out how many EDL operations recorded total. |
13358
567875b88aab
Hardcoded EDL messages moved to help_mp-en.h, Doxygen comments added, patch
diego
parents:
13168
diff
changeset
|
53 * \brief Fills EDL operations queue. |
567875b88aab
Hardcoded EDL messages moved to help_mp-en.h, Doxygen comments added, patch
diego
parents:
13168
diff
changeset
|
54 */ |
567875b88aab
Hardcoded EDL messages moved to help_mp-en.h, Doxygen comments added, patch
diego
parents:
13168
diff
changeset
|
55 |
17566
f580a7755ac5
Patch by Stefan Huehner / stefan % huehner ! org \
rathann
parents:
17109
diff
changeset
|
56 edl_record_ptr edl_parse_file(void) |
13168 | 57 { |
58 FILE *fd; | |
59 char line[100]; | |
60 float start, stop; | |
61 int action; | |
62 int record_count = 0; | |
63 int lineCount = 0; | |
17802 | 64 edl_record_ptr edl_records = NULL; |
65 edl_record_ptr next_edl_record = NULL; | |
13168 | 66 |
67 if (edl_filename) | |
68 { | |
69 if ((fd = fopen(edl_filename, "r")) == NULL) | |
70 { | |
14807
664b06b907cb
Some to-be-redundant EDL code moved to edl.c with mencoder's edl in mind. Stack handling improvements, Patch by Oded Shimon
reynaldo
parents:
14607
diff
changeset
|
71 return NULL; |
18904
64a5e75bb7f2
all cosmetics, mainly denestifying of main edl operation's fill loop
reynaldo
parents:
18903
diff
changeset
|
72 } |
64a5e75bb7f2
all cosmetics, mainly denestifying of main edl operation's fill loop
reynaldo
parents:
18903
diff
changeset
|
73 |
64a5e75bb7f2
all cosmetics, mainly denestifying of main edl operation's fill loop
reynaldo
parents:
18903
diff
changeset
|
74 while (fgets(line, 99, fd) != NULL) |
13168 | 75 { |
18904
64a5e75bb7f2
all cosmetics, mainly denestifying of main edl operation's fill loop
reynaldo
parents:
18903
diff
changeset
|
76 lineCount++; |
64a5e75bb7f2
all cosmetics, mainly denestifying of main edl operation's fill loop
reynaldo
parents:
18903
diff
changeset
|
77 |
64a5e75bb7f2
all cosmetics, mainly denestifying of main edl operation's fill loop
reynaldo
parents:
18903
diff
changeset
|
78 if ((sscanf(line, "%f %f %d", &start, &stop, &action)) |
64a5e75bb7f2
all cosmetics, mainly denestifying of main edl operation's fill loop
reynaldo
parents:
18903
diff
changeset
|
79 != 3) |
64a5e75bb7f2
all cosmetics, mainly denestifying of main edl operation's fill loop
reynaldo
parents:
18903
diff
changeset
|
80 { |
64a5e75bb7f2
all cosmetics, mainly denestifying of main edl operation's fill loop
reynaldo
parents:
18903
diff
changeset
|
81 mp_msg(MSGT_CPLAYER, MSGL_WARN, MSGTR_EdlBadlyFormattedLine, |
64a5e75bb7f2
all cosmetics, mainly denestifying of main edl operation's fill loop
reynaldo
parents:
18903
diff
changeset
|
82 lineCount); |
64a5e75bb7f2
all cosmetics, mainly denestifying of main edl operation's fill loop
reynaldo
parents:
18903
diff
changeset
|
83 continue; |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
18904
diff
changeset
|
84 } |
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
18904
diff
changeset
|
85 |
18904
64a5e75bb7f2
all cosmetics, mainly denestifying of main edl operation's fill loop
reynaldo
parents:
18903
diff
changeset
|
86 if (next_edl_record && start <= next_edl_record->stop_sec) |
64a5e75bb7f2
all cosmetics, mainly denestifying of main edl operation's fill loop
reynaldo
parents:
18903
diff
changeset
|
87 { |
64a5e75bb7f2
all cosmetics, mainly denestifying of main edl operation's fill loop
reynaldo
parents:
18903
diff
changeset
|
88 mp_msg(MSGT_CPLAYER, MSGL_WARN, MSGTR_EdlNOValidLine, line); |
64a5e75bb7f2
all cosmetics, mainly denestifying of main edl operation's fill loop
reynaldo
parents:
18903
diff
changeset
|
89 mp_msg(MSGT_CPLAYER, MSGL_WARN, MSGTR_EdlBadLineOverlap, |
64a5e75bb7f2
all cosmetics, mainly denestifying of main edl operation's fill loop
reynaldo
parents:
18903
diff
changeset
|
90 next_edl_record->stop_sec, start); |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
18904
diff
changeset
|
91 continue; |
18904
64a5e75bb7f2
all cosmetics, mainly denestifying of main edl operation's fill loop
reynaldo
parents:
18903
diff
changeset
|
92 } |
64a5e75bb7f2
all cosmetics, mainly denestifying of main edl operation's fill loop
reynaldo
parents:
18903
diff
changeset
|
93 |
64a5e75bb7f2
all cosmetics, mainly denestifying of main edl operation's fill loop
reynaldo
parents:
18903
diff
changeset
|
94 if (stop <= start) |
13168 | 95 { |
18904
64a5e75bb7f2
all cosmetics, mainly denestifying of main edl operation's fill loop
reynaldo
parents:
18903
diff
changeset
|
96 mp_msg(MSGT_CPLAYER, MSGL_WARN, MSGTR_EdlNOValidLine, |
64a5e75bb7f2
all cosmetics, mainly denestifying of main edl operation's fill loop
reynaldo
parents:
18903
diff
changeset
|
97 line); |
64a5e75bb7f2
all cosmetics, mainly denestifying of main edl operation's fill loop
reynaldo
parents:
18903
diff
changeset
|
98 mp_msg(MSGT_CPLAYER, MSGL_WARN, MSGTR_EdlBadLineBadStop); |
64a5e75bb7f2
all cosmetics, mainly denestifying of main edl operation's fill loop
reynaldo
parents:
18903
diff
changeset
|
99 continue; |
64a5e75bb7f2
all cosmetics, mainly denestifying of main edl operation's fill loop
reynaldo
parents:
18903
diff
changeset
|
100 } |
64a5e75bb7f2
all cosmetics, mainly denestifying of main edl operation's fill loop
reynaldo
parents:
18903
diff
changeset
|
101 |
64a5e75bb7f2
all cosmetics, mainly denestifying of main edl operation's fill loop
reynaldo
parents:
18903
diff
changeset
|
102 next_edl_record = edl_alloc_new(next_edl_record); |
64a5e75bb7f2
all cosmetics, mainly denestifying of main edl operation's fill loop
reynaldo
parents:
18903
diff
changeset
|
103 |
64a5e75bb7f2
all cosmetics, mainly denestifying of main edl operation's fill loop
reynaldo
parents:
18903
diff
changeset
|
104 if (!edl_records) edl_records = next_edl_record; |
64a5e75bb7f2
all cosmetics, mainly denestifying of main edl operation's fill loop
reynaldo
parents:
18903
diff
changeset
|
105 |
64a5e75bb7f2
all cosmetics, mainly denestifying of main edl operation's fill loop
reynaldo
parents:
18903
diff
changeset
|
106 next_edl_record->action = action; |
17802 | 107 |
18904
64a5e75bb7f2
all cosmetics, mainly denestifying of main edl operation's fill loop
reynaldo
parents:
18903
diff
changeset
|
108 if (action == EDL_MUTE) |
64a5e75bb7f2
all cosmetics, mainly denestifying of main edl operation's fill loop
reynaldo
parents:
18903
diff
changeset
|
109 { |
64a5e75bb7f2
all cosmetics, mainly denestifying of main edl operation's fill loop
reynaldo
parents:
18903
diff
changeset
|
110 next_edl_record->length_sec = 0; |
64a5e75bb7f2
all cosmetics, mainly denestifying of main edl operation's fill loop
reynaldo
parents:
18903
diff
changeset
|
111 next_edl_record->start_sec = start; |
64a5e75bb7f2
all cosmetics, mainly denestifying of main edl operation's fill loop
reynaldo
parents:
18903
diff
changeset
|
112 next_edl_record->stop_sec = start; |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
18904
diff
changeset
|
113 |
18904
64a5e75bb7f2
all cosmetics, mainly denestifying of main edl operation's fill loop
reynaldo
parents:
18903
diff
changeset
|
114 next_edl_record = edl_alloc_new(next_edl_record); |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
18904
diff
changeset
|
115 |
18904
64a5e75bb7f2
all cosmetics, mainly denestifying of main edl operation's fill loop
reynaldo
parents:
18903
diff
changeset
|
116 next_edl_record->action = action; |
64a5e75bb7f2
all cosmetics, mainly denestifying of main edl operation's fill loop
reynaldo
parents:
18903
diff
changeset
|
117 next_edl_record->length_sec = 0; |
64a5e75bb7f2
all cosmetics, mainly denestifying of main edl operation's fill loop
reynaldo
parents:
18903
diff
changeset
|
118 next_edl_record->start_sec = stop; |
64a5e75bb7f2
all cosmetics, mainly denestifying of main edl operation's fill loop
reynaldo
parents:
18903
diff
changeset
|
119 next_edl_record->stop_sec = stop; |
64a5e75bb7f2
all cosmetics, mainly denestifying of main edl operation's fill loop
reynaldo
parents:
18903
diff
changeset
|
120 } else |
64a5e75bb7f2
all cosmetics, mainly denestifying of main edl operation's fill loop
reynaldo
parents:
18903
diff
changeset
|
121 { |
64a5e75bb7f2
all cosmetics, mainly denestifying of main edl operation's fill loop
reynaldo
parents:
18903
diff
changeset
|
122 next_edl_record->length_sec = stop - start; |
64a5e75bb7f2
all cosmetics, mainly denestifying of main edl operation's fill loop
reynaldo
parents:
18903
diff
changeset
|
123 next_edl_record->start_sec = start; |
64a5e75bb7f2
all cosmetics, mainly denestifying of main edl operation's fill loop
reynaldo
parents:
18903
diff
changeset
|
124 next_edl_record->stop_sec = stop; |
13168 | 125 } |
18904
64a5e75bb7f2
all cosmetics, mainly denestifying of main edl operation's fill loop
reynaldo
parents:
18903
diff
changeset
|
126 |
64a5e75bb7f2
all cosmetics, mainly denestifying of main edl operation's fill loop
reynaldo
parents:
18903
diff
changeset
|
127 record_count++; |
13168 | 128 } |
18904
64a5e75bb7f2
all cosmetics, mainly denestifying of main edl operation's fill loop
reynaldo
parents:
18903
diff
changeset
|
129 |
13168 | 130 fclose(fd); |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
18904
diff
changeset
|
131 } |
18904
64a5e75bb7f2
all cosmetics, mainly denestifying of main edl operation's fill loop
reynaldo
parents:
18903
diff
changeset
|
132 |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
18904
diff
changeset
|
133 if (edl_records) |
18904
64a5e75bb7f2
all cosmetics, mainly denestifying of main edl operation's fill loop
reynaldo
parents:
18903
diff
changeset
|
134 mp_msg(MSGT_CPLAYER, MSGL_INFO, MSGTR_EdlRecordsNo, record_count); |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
18904
diff
changeset
|
135 else |
18904
64a5e75bb7f2
all cosmetics, mainly denestifying of main edl operation's fill loop
reynaldo
parents:
18903
diff
changeset
|
136 mp_msg(MSGT_CPLAYER, MSGL_INFO, MSGTR_EdlQueueEmpty); |
17802 | 137 |
14807
664b06b907cb
Some to-be-redundant EDL code moved to edl.c with mencoder's edl in mind. Stack handling improvements, Patch by Oded Shimon
reynaldo
parents:
14607
diff
changeset
|
138 return edl_records; |
13168 | 139 } |