annotate edl.c @ 14720:4e83e075024f

added support for raw udp:// streaming
author nicodvb
date Thu, 17 Feb 2005 20:55:57 +0000
parents 7a80c6ac5058
children 664b06b907cb
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
13168
ce046ef860da EDL enhancement/fixes:
rtognimp
parents:
diff changeset
1 #include <stdio.h>
ce046ef860da EDL enhancement/fixes:
rtognimp
parents:
diff changeset
2 #include <stdlib.h>
ce046ef860da EDL enhancement/fixes:
rtognimp
parents:
diff changeset
3 #include "config.h"
ce046ef860da EDL enhancement/fixes:
rtognimp
parents:
diff changeset
4 #include "mp_msg.h"
ce046ef860da EDL enhancement/fixes:
rtognimp
parents:
diff changeset
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
ce046ef860da EDL enhancement/fixes:
rtognimp
parents:
diff changeset
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
13168
ce046ef860da EDL enhancement/fixes:
rtognimp
parents:
diff changeset
11 #ifdef USE_EDL
ce046ef860da EDL enhancement/fixes:
rtognimp
parents:
diff changeset
12
13358
567875b88aab Hardcoded EDL messages moved to help_mp-en.h, Doxygen comments added, patch
diego
parents: 13168
diff changeset
13 /**
567875b88aab Hardcoded EDL messages moved to help_mp-en.h, Doxygen comments added, patch
diego
parents: 13168
diff changeset
14 * We can't do -edl and -edlout at the same time
567875b88aab Hardcoded EDL messages moved to help_mp-en.h, Doxygen comments added, patch
diego
parents: 13168
diff changeset
15 * so we check that here.
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 * \return EDL_ERROR on error and 1 otherwise.
567875b88aab Hardcoded EDL messages moved to help_mp-en.h, Doxygen comments added, patch
diego
parents: 13168
diff changeset
18 * \brief Makes sure EDL has been called correctly.
567875b88aab Hardcoded EDL messages moved to help_mp-en.h, Doxygen comments added, patch
diego
parents: 13168
diff changeset
19 */
567875b88aab Hardcoded EDL messages moved to help_mp-en.h, Doxygen comments added, patch
diego
parents: 13168
diff changeset
20
13168
ce046ef860da EDL enhancement/fixes:
rtognimp
parents:
diff changeset
21 int edl_check_mode(void)
ce046ef860da EDL enhancement/fixes:
rtognimp
parents:
diff changeset
22 {
ce046ef860da EDL enhancement/fixes:
rtognimp
parents:
diff changeset
23 if (edl_filename && edl_output_filename)
ce046ef860da EDL enhancement/fixes:
rtognimp
parents:
diff changeset
24 {
ce046ef860da EDL enhancement/fixes:
rtognimp
parents:
diff changeset
25 return (EDL_ERROR);
ce046ef860da EDL enhancement/fixes:
rtognimp
parents:
diff changeset
26 }
ce046ef860da EDL enhancement/fixes:
rtognimp
parents:
diff changeset
27
ce046ef860da EDL enhancement/fixes:
rtognimp
parents:
diff changeset
28 return (1);
ce046ef860da EDL enhancement/fixes:
rtognimp
parents:
diff changeset
29 }
ce046ef860da EDL enhancement/fixes:
rtognimp
parents:
diff changeset
30
13358
567875b88aab Hardcoded EDL messages moved to help_mp-en.h, Doxygen comments added, patch
diego
parents: 13168
diff changeset
31 /** Calculates the total amount of edl_records we will need
567875b88aab Hardcoded EDL messages moved to help_mp-en.h, Doxygen comments added, patch
diego
parents: 13168
diff changeset
32 * to hold the EDL operations queue, we need one edl_record
567875b88aab Hardcoded EDL messages moved to help_mp-en.h, Doxygen comments added, patch
diego
parents: 13168
diff changeset
33 * for each SKIP and two for each MUTE.
567875b88aab Hardcoded EDL messages moved to help_mp-en.h, Doxygen comments added, patch
diego
parents: 13168
diff changeset
34 * \return Number of necessary EDL entries, EDL_ERROR when file can't be read.
567875b88aab Hardcoded EDL messages moved to help_mp-en.h, Doxygen comments added, patch
diego
parents: 13168
diff changeset
35 * \brief Counts needed EDL entries.
567875b88aab Hardcoded EDL messages moved to help_mp-en.h, Doxygen comments added, patch
diego
parents: 13168
diff changeset
36 */
567875b88aab Hardcoded EDL messages moved to help_mp-en.h, Doxygen comments added, patch
diego
parents: 13168
diff changeset
37
13168
ce046ef860da EDL enhancement/fixes:
rtognimp
parents:
diff changeset
38 int edl_count_entries(void)
ce046ef860da EDL enhancement/fixes:
rtognimp
parents:
diff changeset
39 {
ce046ef860da EDL enhancement/fixes:
rtognimp
parents:
diff changeset
40 FILE *fd = NULL;
ce046ef860da EDL enhancement/fixes:
rtognimp
parents:
diff changeset
41 int entries = 0;
ce046ef860da EDL enhancement/fixes:
rtognimp
parents:
diff changeset
42 int action = 0;
ce046ef860da EDL enhancement/fixes:
rtognimp
parents:
diff changeset
43 float start = 0;
ce046ef860da EDL enhancement/fixes:
rtognimp
parents:
diff changeset
44 float stop = 0;
ce046ef860da EDL enhancement/fixes:
rtognimp
parents:
diff changeset
45 char line[100];
ce046ef860da EDL enhancement/fixes:
rtognimp
parents:
diff changeset
46
ce046ef860da EDL enhancement/fixes:
rtognimp
parents:
diff changeset
47 if (edl_filename)
ce046ef860da EDL enhancement/fixes:
rtognimp
parents:
diff changeset
48 {
ce046ef860da EDL enhancement/fixes:
rtognimp
parents:
diff changeset
49 if ((fd = fopen(edl_filename, "r")) == NULL)
ce046ef860da EDL enhancement/fixes:
rtognimp
parents:
diff changeset
50 {
13358
567875b88aab Hardcoded EDL messages moved to help_mp-en.h, Doxygen comments added, patch
diego
parents: 13168
diff changeset
51 mp_msg(MSGT_CPLAYER, MSGL_WARN, MSGTR_EdlCantOpenForRead,
13168
ce046ef860da EDL enhancement/fixes:
rtognimp
parents:
diff changeset
52 edl_filename);
ce046ef860da EDL enhancement/fixes:
rtognimp
parents:
diff changeset
53 return (EDL_ERROR);
ce046ef860da EDL enhancement/fixes:
rtognimp
parents:
diff changeset
54 } else
ce046ef860da EDL enhancement/fixes:
rtognimp
parents:
diff changeset
55 {
ce046ef860da EDL enhancement/fixes:
rtognimp
parents:
diff changeset
56 while (fgets(line, 99, fd) != NULL)
ce046ef860da EDL enhancement/fixes:
rtognimp
parents:
diff changeset
57 {
ce046ef860da EDL enhancement/fixes:
rtognimp
parents:
diff changeset
58 if ((sscanf(line, "%f %f %d", &start, &stop, &action)) ==
ce046ef860da EDL enhancement/fixes:
rtognimp
parents:
diff changeset
59 3)
ce046ef860da EDL enhancement/fixes:
rtognimp
parents:
diff changeset
60 {
ce046ef860da EDL enhancement/fixes:
rtognimp
parents:
diff changeset
61 if (action == EDL_SKIP)
ce046ef860da EDL enhancement/fixes:
rtognimp
parents:
diff changeset
62 entries += 1;
ce046ef860da EDL enhancement/fixes:
rtognimp
parents:
diff changeset
63 if (action == EDL_MUTE)
ce046ef860da EDL enhancement/fixes:
rtognimp
parents:
diff changeset
64 entries += 2;
ce046ef860da EDL enhancement/fixes:
rtognimp
parents:
diff changeset
65 } else
ce046ef860da EDL enhancement/fixes:
rtognimp
parents:
diff changeset
66 {
13358
567875b88aab Hardcoded EDL messages moved to help_mp-en.h, Doxygen comments added, patch
diego
parents: 13168
diff changeset
67 mp_msg(MSGT_CPLAYER, MSGL_WARN, MSGTR_EdlNOValidLine, line);
13168
ce046ef860da EDL enhancement/fixes:
rtognimp
parents:
diff changeset
68 return (EDL_ERROR);
ce046ef860da EDL enhancement/fixes:
rtognimp
parents:
diff changeset
69 }
ce046ef860da EDL enhancement/fixes:
rtognimp
parents:
diff changeset
70
ce046ef860da EDL enhancement/fixes:
rtognimp
parents:
diff changeset
71 }
ce046ef860da EDL enhancement/fixes:
rtognimp
parents:
diff changeset
72 }
ce046ef860da EDL enhancement/fixes:
rtognimp
parents:
diff changeset
73 } else
ce046ef860da EDL enhancement/fixes:
rtognimp
parents:
diff changeset
74 {
ce046ef860da EDL enhancement/fixes:
rtognimp
parents:
diff changeset
75 return (EDL_ERROR);
ce046ef860da EDL enhancement/fixes:
rtognimp
parents:
diff changeset
76 }
ce046ef860da EDL enhancement/fixes:
rtognimp
parents:
diff changeset
77
ce046ef860da EDL enhancement/fixes:
rtognimp
parents:
diff changeset
78 return (entries);
ce046ef860da EDL enhancement/fixes:
rtognimp
parents:
diff changeset
79 }
ce046ef860da EDL enhancement/fixes:
rtognimp
parents:
diff changeset
80
13358
567875b88aab Hardcoded EDL messages moved to help_mp-en.h, Doxygen comments added, patch
diego
parents: 13168
diff changeset
81 /** Parses edl_filename to fill EDL operations queue.
567875b88aab Hardcoded EDL messages moved to help_mp-en.h, Doxygen comments added, patch
diego
parents: 13168
diff changeset
82 * \return Number of stored EDL records or EDL_ERROR when file can't be read.
567875b88aab Hardcoded EDL messages moved to help_mp-en.h, Doxygen comments added, patch
diego
parents: 13168
diff changeset
83 * \brief Fills EDL operations queue.
567875b88aab Hardcoded EDL messages moved to help_mp-en.h, Doxygen comments added, patch
diego
parents: 13168
diff changeset
84 */
567875b88aab Hardcoded EDL messages moved to help_mp-en.h, Doxygen comments added, patch
diego
parents: 13168
diff changeset
85
13168
ce046ef860da EDL enhancement/fixes:
rtognimp
parents:
diff changeset
86 int edl_parse_file(edl_record_ptr edl_records)
ce046ef860da EDL enhancement/fixes:
rtognimp
parents:
diff changeset
87 {
ce046ef860da EDL enhancement/fixes:
rtognimp
parents:
diff changeset
88 FILE *fd;
ce046ef860da EDL enhancement/fixes:
rtognimp
parents:
diff changeset
89 char line[100];
ce046ef860da EDL enhancement/fixes:
rtognimp
parents:
diff changeset
90 float start, stop;
ce046ef860da EDL enhancement/fixes:
rtognimp
parents:
diff changeset
91 int action;
ce046ef860da EDL enhancement/fixes:
rtognimp
parents:
diff changeset
92 int record_count = 0;
ce046ef860da EDL enhancement/fixes:
rtognimp
parents:
diff changeset
93 int lineCount = 0;
ce046ef860da EDL enhancement/fixes:
rtognimp
parents:
diff changeset
94 struct edl_record *next_edl_record = edl_records;
ce046ef860da EDL enhancement/fixes:
rtognimp
parents:
diff changeset
95
ce046ef860da EDL enhancement/fixes:
rtognimp
parents:
diff changeset
96 if (edl_filename)
ce046ef860da EDL enhancement/fixes:
rtognimp
parents:
diff changeset
97 {
ce046ef860da EDL enhancement/fixes:
rtognimp
parents:
diff changeset
98 if ((fd = fopen(edl_filename, "r")) == NULL)
ce046ef860da EDL enhancement/fixes:
rtognimp
parents:
diff changeset
99 {
ce046ef860da EDL enhancement/fixes:
rtognimp
parents:
diff changeset
100 return (EDL_ERROR);
ce046ef860da EDL enhancement/fixes:
rtognimp
parents:
diff changeset
101 } else
ce046ef860da EDL enhancement/fixes:
rtognimp
parents:
diff changeset
102 {
ce046ef860da EDL enhancement/fixes:
rtognimp
parents:
diff changeset
103 while (fgets(line, 99, fd) != NULL)
ce046ef860da EDL enhancement/fixes:
rtognimp
parents:
diff changeset
104 {
ce046ef860da EDL enhancement/fixes:
rtognimp
parents:
diff changeset
105 lineCount++;
ce046ef860da EDL enhancement/fixes:
rtognimp
parents:
diff changeset
106 if ((sscanf(line, "%f %f %d", &start, &stop, &action))
ce046ef860da EDL enhancement/fixes:
rtognimp
parents:
diff changeset
107 != 3)
ce046ef860da EDL enhancement/fixes:
rtognimp
parents:
diff changeset
108 {
13358
567875b88aab Hardcoded EDL messages moved to help_mp-en.h, Doxygen comments added, patch
diego
parents: 13168
diff changeset
109 mp_msg(MSGT_CPLAYER, MSGL_WARN, MSGTR_EdlBadlyFormattedLine,
567875b88aab Hardcoded EDL messages moved to help_mp-en.h, Doxygen comments added, patch
diego
parents: 13168
diff changeset
110 lineCount + 1);
13168
ce046ef860da EDL enhancement/fixes:
rtognimp
parents:
diff changeset
111 continue;
ce046ef860da EDL enhancement/fixes:
rtognimp
parents:
diff changeset
112 } else
ce046ef860da EDL enhancement/fixes:
rtognimp
parents:
diff changeset
113 {
ce046ef860da EDL enhancement/fixes:
rtognimp
parents:
diff changeset
114 if (record_count > 0)
ce046ef860da EDL enhancement/fixes:
rtognimp
parents:
diff changeset
115 {
ce046ef860da EDL enhancement/fixes:
rtognimp
parents:
diff changeset
116 if (start <= (next_edl_record - 1)->stop_sec)
ce046ef860da EDL enhancement/fixes:
rtognimp
parents:
diff changeset
117 {
ce046ef860da EDL enhancement/fixes:
rtognimp
parents:
diff changeset
118 mp_msg(MSGT_CPLAYER, MSGL_WARN,
13358
567875b88aab Hardcoded EDL messages moved to help_mp-en.h, Doxygen comments added, patch
diego
parents: 13168
diff changeset
119 MSGTR_EdlNOValidLine, line);
13168
ce046ef860da EDL enhancement/fixes:
rtognimp
parents:
diff changeset
120 mp_msg(MSGT_CPLAYER, MSGL_WARN,
13358
567875b88aab Hardcoded EDL messages moved to help_mp-en.h, Doxygen comments added, patch
diego
parents: 13168
diff changeset
121 MSGTR_EdlBadLineOverlap,
13168
ce046ef860da EDL enhancement/fixes:
rtognimp
parents:
diff changeset
122 (next_edl_record - 1)->stop_sec, start);
ce046ef860da EDL enhancement/fixes:
rtognimp
parents:
diff changeset
123 continue;
ce046ef860da EDL enhancement/fixes:
rtognimp
parents:
diff changeset
124 }
ce046ef860da EDL enhancement/fixes:
rtognimp
parents:
diff changeset
125 }
ce046ef860da EDL enhancement/fixes:
rtognimp
parents:
diff changeset
126 if (stop <= start)
ce046ef860da EDL enhancement/fixes:
rtognimp
parents:
diff changeset
127 {
13358
567875b88aab Hardcoded EDL messages moved to help_mp-en.h, Doxygen comments added, patch
diego
parents: 13168
diff changeset
128 mp_msg(MSGT_CPLAYER, MSGL_WARN, MSGTR_EdlNOValidLine,
13168
ce046ef860da EDL enhancement/fixes:
rtognimp
parents:
diff changeset
129 line);
13358
567875b88aab Hardcoded EDL messages moved to help_mp-en.h, Doxygen comments added, patch
diego
parents: 13168
diff changeset
130 mp_msg(MSGT_CPLAYER, MSGL_WARN, MSGTR_EdlBadLineBadStop);
13168
ce046ef860da EDL enhancement/fixes:
rtognimp
parents:
diff changeset
131 continue;
ce046ef860da EDL enhancement/fixes:
rtognimp
parents:
diff changeset
132 }
ce046ef860da EDL enhancement/fixes:
rtognimp
parents:
diff changeset
133 next_edl_record->action = action;
ce046ef860da EDL enhancement/fixes:
rtognimp
parents:
diff changeset
134 if (action == EDL_MUTE)
ce046ef860da EDL enhancement/fixes:
rtognimp
parents:
diff changeset
135 {
ce046ef860da EDL enhancement/fixes:
rtognimp
parents:
diff changeset
136 next_edl_record->length_sec = 0;
ce046ef860da EDL enhancement/fixes:
rtognimp
parents:
diff changeset
137 next_edl_record->start_sec = start;
ce046ef860da EDL enhancement/fixes:
rtognimp
parents:
diff changeset
138 next_edl_record->stop_sec = start;
ce046ef860da EDL enhancement/fixes:
rtognimp
parents:
diff changeset
139 next_edl_record->mute_state = EDL_MUTE_START;
ce046ef860da EDL enhancement/fixes:
rtognimp
parents:
diff changeset
140 next_edl_record++;
ce046ef860da EDL enhancement/fixes:
rtognimp
parents:
diff changeset
141 (next_edl_record - 1)->next = next_edl_record;
ce046ef860da EDL enhancement/fixes:
rtognimp
parents:
diff changeset
142 next_edl_record->action = action;
ce046ef860da EDL enhancement/fixes:
rtognimp
parents:
diff changeset
143 next_edl_record->length_sec = 0;
ce046ef860da EDL enhancement/fixes:
rtognimp
parents:
diff changeset
144 next_edl_record->start_sec = stop;
ce046ef860da EDL enhancement/fixes:
rtognimp
parents:
diff changeset
145 next_edl_record->stop_sec = stop;
ce046ef860da EDL enhancement/fixes:
rtognimp
parents:
diff changeset
146 next_edl_record->mute_state = EDL_MUTE_END;
ce046ef860da EDL enhancement/fixes:
rtognimp
parents:
diff changeset
147
ce046ef860da EDL enhancement/fixes:
rtognimp
parents:
diff changeset
148 } else
ce046ef860da EDL enhancement/fixes:
rtognimp
parents:
diff changeset
149 {
ce046ef860da EDL enhancement/fixes:
rtognimp
parents:
diff changeset
150 next_edl_record->length_sec = stop - start;
ce046ef860da EDL enhancement/fixes:
rtognimp
parents:
diff changeset
151 next_edl_record->start_sec = start;
ce046ef860da EDL enhancement/fixes:
rtognimp
parents:
diff changeset
152 next_edl_record->stop_sec = stop;
ce046ef860da EDL enhancement/fixes:
rtognimp
parents:
diff changeset
153 }
ce046ef860da EDL enhancement/fixes:
rtognimp
parents:
diff changeset
154 next_edl_record++;
ce046ef860da EDL enhancement/fixes:
rtognimp
parents:
diff changeset
155
ce046ef860da EDL enhancement/fixes:
rtognimp
parents:
diff changeset
156 if (record_count >= 0)
ce046ef860da EDL enhancement/fixes:
rtognimp
parents:
diff changeset
157 {
ce046ef860da EDL enhancement/fixes:
rtognimp
parents:
diff changeset
158 (next_edl_record - 1)->next = next_edl_record;
ce046ef860da EDL enhancement/fixes:
rtognimp
parents:
diff changeset
159 }
ce046ef860da EDL enhancement/fixes:
rtognimp
parents:
diff changeset
160
ce046ef860da EDL enhancement/fixes:
rtognimp
parents:
diff changeset
161 record_count++;
ce046ef860da EDL enhancement/fixes:
rtognimp
parents:
diff changeset
162 }
ce046ef860da EDL enhancement/fixes:
rtognimp
parents:
diff changeset
163 }
ce046ef860da EDL enhancement/fixes:
rtognimp
parents:
diff changeset
164
ce046ef860da EDL enhancement/fixes:
rtognimp
parents:
diff changeset
165 if (record_count > 0)
ce046ef860da EDL enhancement/fixes:
rtognimp
parents:
diff changeset
166 {
ce046ef860da EDL enhancement/fixes:
rtognimp
parents:
diff changeset
167 (next_edl_record - 1)->next = NULL;
ce046ef860da EDL enhancement/fixes:
rtognimp
parents:
diff changeset
168 }
ce046ef860da EDL enhancement/fixes:
rtognimp
parents:
diff changeset
169 }
ce046ef860da EDL enhancement/fixes:
rtognimp
parents:
diff changeset
170 fclose(fd);
ce046ef860da EDL enhancement/fixes:
rtognimp
parents:
diff changeset
171 } else
ce046ef860da EDL enhancement/fixes:
rtognimp
parents:
diff changeset
172 {
ce046ef860da EDL enhancement/fixes:
rtognimp
parents:
diff changeset
173 return (EDL_ERROR);
ce046ef860da EDL enhancement/fixes:
rtognimp
parents:
diff changeset
174 }
ce046ef860da EDL enhancement/fixes:
rtognimp
parents:
diff changeset
175
ce046ef860da EDL enhancement/fixes:
rtognimp
parents:
diff changeset
176 return (record_count);
ce046ef860da EDL enhancement/fixes:
rtognimp
parents:
diff changeset
177 }
ce046ef860da EDL enhancement/fixes:
rtognimp
parents:
diff changeset
178
ce046ef860da EDL enhancement/fixes:
rtognimp
parents:
diff changeset
179 #endif