1
===================================================================
2
RCS file: /srv/anoncvs.freedesktop.org/cvs/gstreamer/gst-plugins-ugly/ext/mad/gstmad.c,v
3
rcsdiff: /srv/anoncvs.freedesktop.org/cvs/gstreamer/gst-plugins-ugly/ext/mad/gstmad.c,v: warning: Unknown phrases like `commitid ...;' are present.
4
retrieving revision 1.155
5
retrieving revision 1.157
6
diff -u -r1.155 -r1.157
7
--- gst-plugins-ugly/ext/mad/gstmad.c 2006/04/09 18:09:39 1.155
8
+++ gst-plugins-ugly/ext/mad/gstmad.c 2006/04/21 20:37:43 1.157
13
+ if (src_format == *dest_format) {
14
+ *dest_value = src_value;
18
mad = GST_MAD (GST_PAD_PARENT (pad));
20
if (mad->vbr_average == 0)
22
gint bytes_per_sample;
25
+ if (src_format == *dest_format) {
26
+ *dest_value = src_value;
30
mad = GST_MAD (GST_PAD_PARENT (pad));
32
bytes_per_sample = MAD_NCHANNELS (&mad->frame.header) * 4;
37
- *dest_value = src_value * GST_SECOND / byterate;
39
+ gst_util_uint64_scale_int (src_value, GST_SECOND, byterate);
45
if (mad->frame.header.samplerate == 0)
47
- *dest_value = src_value * GST_SECOND / mad->frame.header.samplerate;
48
+ *dest_value = gst_util_uint64_scale_int (src_value, GST_SECOND,
49
+ mad->frame.header.samplerate);
54
scale = bytes_per_sample;
56
case GST_FORMAT_DEFAULT:
58
- src_value * scale * mad->frame.header.samplerate / GST_SECOND;
59
+ *dest_value = gst_util_uint64_scale_int (src_value,
60
+ scale * mad->frame.header.samplerate, GST_SECOND);
66
case GST_QUERY_DURATION:
70
+ GstFormat bytes_format = GST_FORMAT_BYTES;
71
+ GstFormat time_format = GST_FORMAT_TIME;
72
+ GstFormat req_format;
73
gint64 total, total_bytes;
75
/* save requested format */
76
- gst_query_parse_duration (query, &format, NULL);
77
+ gst_query_parse_duration (query, &req_format, NULL);
82
/* try any demuxer before us first */
83
- if (format == GST_FORMAT_TIME && gst_pad_query (peer, query)) {
84
+ if (req_format == GST_FORMAT_TIME && gst_pad_query (peer, query)) {
85
gst_query_parse_duration (query, NULL, &total);
86
GST_LOG_OBJECT (mad, "peer returned duration %" GST_TIME_FORMAT,
87
GST_TIME_ARGS (total));
91
/* query peer for total length in bytes */
92
- gst_query_set_duration (query, GST_FORMAT_BYTES, -1);
94
- if (!gst_pad_query (peer, query)) {
95
- GST_LOG_OBJECT (mad, "query on peer pad failed");
96
+ if (!gst_pad_query_peer_duration (mad->sinkpad, &bytes_format,
97
+ &total_bytes) || total_bytes <= 0) {
98
+ GST_LOG_OBJECT (mad, "duration query on peer pad failed");
102
- /* get the returned format */
103
- gst_query_parse_duration (query, &rformat, &total_bytes);
104
- if (rformat == GST_FORMAT_BYTES) {
105
- GST_LOG_OBJECT (mad, "peer pad returned total=%lld bytes", total_bytes);
106
- } else if (rformat == GST_FORMAT_TIME) {
107
- GST_LOG_OBJECT (mad, "peer pad returned total time=%", GST_TIME_FORMAT,
108
- GST_TIME_ARGS (total_bytes));
111
- /* Check if requested format is returned format */
112
- if (format == rformat)
114
+ GST_LOG_OBJECT (mad, "peer pad returned total=%" G_GINT64_FORMAT
115
+ " bytes", total_bytes);
117
- if (total_bytes != -1) {
118
- if (format != GST_FORMAT_BYTES) {
119
- if (!gst_mad_convert_sink (pad, GST_FORMAT_BYTES, total_bytes,
123
- total = total_bytes;
127
+ if (!gst_mad_convert_sink (pad, GST_FORMAT_BYTES, total_bytes,
128
+ &time_format, &total)) {
129
+ GST_DEBUG_OBJECT (mad, "conversion BYTE => TIME failed");
132
+ if (!gst_mad_convert_src (pad, GST_FORMAT_TIME, total,
133
+ &req_format, &total)) {
134
+ GST_DEBUG_OBJECT (mad, "conversion TIME => %s failed",
135
+ gst_format_get_name (req_format));
139
- gst_query_set_duration (query, format, total);
140
- if (format == GST_FORMAT_TIME) {
141
- GST_LOG ("duration=%" GST_TIME_FORMAT, GST_TIME_ARGS (total));
142
+ gst_query_set_duration (query, req_format, total);
144
+ if (req_format == GST_FORMAT_TIME) {
145
+ GST_LOG_OBJECT (mad, "duration=%" GST_TIME_FORMAT,
146
+ GST_TIME_ARGS (total));
148
- GST_LOG ("duration=%" G_GINT64_FORMAT ", format=%u", total, format);
149
+ GST_LOG_OBJECT (mad, "duration=%" G_GINT64_FORMAT " (%s)",
150
+ gst_format_get_name (req_format));
154
@@ -1548,8 +1553,11 @@
155
mad->total_samples = total;
156
mad->last_ts = GST_CLOCK_TIME_NONE;
158
- time_offset = mad->total_samples * (GST_SECOND / mad->rate);
159
- time_duration = (nsamples * (GST_SECOND / mad->rate));
161
+ gst_util_uint64_scale_int (mad->total_samples, GST_SECOND,
164
+ gst_util_uint64_scale_int (nsamples, GST_SECOND, mad->rate);