summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuo Jinghua <sunmoon1997@gmail.com>2009-09-21 23:21:52 +0800
committerLuo Jinghua <sunmoon1997@gmail.com>2009-09-21 23:21:52 +0800
commit613f2be1760186c38950e5cc2c3febf9595da1dc (patch)
tree00c9c854a9295712834441478e8db28b5e0bdaf3
parent8495b0a84946ee6274b6df4479ab8239a7ec528e (diff)
pmpdemux: indent the code and respect package name & package origin
-rw-r--r--src/gstpmpdemux.c494
1 files changed, 246 insertions, 248 deletions
diff --git a/src/gstpmpdemux.c b/src/gstpmpdemux.c
index ff5af01..ca99a3c 100644
--- a/src/gstpmpdemux.c
+++ b/src/gstpmpdemux.c
@@ -43,7 +43,7 @@
#include "config.h"
#endif
-//#include "gst/gst-i18n-plugin.h"
+#include "gst-i18n-plugin.h"
#include "gstpmpdemux.h"
@@ -55,10 +55,6 @@ GST_DEBUG_CATEGORY (pmpdemux_debug);
#define PMP_HEADER_SIZE (14 * 4)
#define PMP_FRAME_HEADER_SIZE (1 + 4 * 3)
-#ifndef _
-#define _(x) x
-#endif
-
struct _PmpdemuxStream
{
GstPad *pad;
@@ -134,7 +130,7 @@ GST_ELEMENT_DETAILS ("PMP demuxer",
"Luo Jinghua <sunmoon1997@gmail.com>");
static GstStaticPadTemplate gst_pmpdemux_sink_template =
- GST_STATIC_PAD_TEMPLATE ("sink",
+GST_STATIC_PAD_TEMPLATE ("sink",
GST_PAD_SINK,
GST_PAD_ALWAYS,
GST_STATIC_CAPS ("video/x-pmp")
@@ -175,10 +171,8 @@ static GstCaps *pmpdemux_audio_caps (GstPmpdemux * pmpdemux,
PmpdemuxStream * stream, guint32 format);
static gboolean
-gst_pmpdemux_add_stream (GstPmpdemux * pmpdemux,
- PmpdemuxStream * stream);
-static void
-gst_pmpdemux_push_event (GstPmpdemux * pmpdemux, GstEvent * event);
+gst_pmpdemux_add_stream (GstPmpdemux * pmpdemux, PmpdemuxStream * stream);
+static void gst_pmpdemux_push_event (GstPmpdemux * pmpdemux, GstEvent * event);
GType
gst_pmpdemux_get_type (void)
@@ -244,7 +238,8 @@ gst_pmpdemux_init (GstPmpdemux * pmpdemux)
gst_pad_set_activatepush_function (pmpdemux->sinkpad,
pmpdemux_sink_activate_push);
gst_pad_set_chain_function (pmpdemux->sinkpad, gst_pmpdemux_chain);
- gst_pad_set_event_function (pmpdemux->sinkpad, gst_pmpdemux_handle_sink_event);
+ gst_pad_set_event_function (pmpdemux->sinkpad,
+ gst_pmpdemux_handle_sink_event);
gst_element_add_pad (GST_ELEMENT_CAST (pmpdemux), pmpdemux->sinkpad);
pmpdemux->state = PMPDEMUX_STATE_HEADER;
@@ -438,20 +433,21 @@ gst_pmpdemux_perform_seek (GstPmpdemux * pmpdemux, GstSegment * segment)
desired_offset = segment->last_stop;
GST_DEBUG_OBJECT (pmpdemux, "seeking to %" GST_TIME_FORMAT,
- GST_TIME_ARGS (desired_offset));
+ GST_TIME_ARGS (desired_offset));
if (segment->flags & GST_SEEK_FLAG_KEY_UNIT) {
guint index;
index = gst_util_uint64_scale (desired_offset, pmpdemux->timerate,
- pmpdemux->timescale * GST_SECOND);
+ pmpdemux->timescale * GST_SECOND);
/* seek to previous keyframe */
while (index > 0 && !(pmpdemux->samples[index].size & 1))
index--;
- desired_offset = gst_util_uint64_scale (index * pmpdemux->timescale, GST_SECOND,
- pmpdemux->timerate);
+ desired_offset =
+ gst_util_uint64_scale (index * pmpdemux->timescale, GST_SECOND,
+ pmpdemux->timerate);
GST_DEBUG_OBJECT (pmpdemux, "keyframe seek, align to %"
GST_TIME_FORMAT, GST_TIME_ARGS (desired_offset));
@@ -666,26 +662,26 @@ gst_pmpdemux_handle_sink_event (GstPad * sinkpad, GstEvent * event)
/* we only expect a BYTE segment, e.g. following a seek */
if (format == GST_FORMAT_BYTES) {
- guint i;
+ guint i;
if (start > 0) {
- for (i = 0; i < demux->n_samples; i++)
- if (demux->samples[i].offset <= start &&
- (demux->samples[i].offset +
- (demux->samples[i].size >> 1)) > start)
- break;
-
- start = gst_util_uint64_scale (i * demux->timerate,
- GST_SECOND, demux->timescale);
- }
- if (stop > 0) {
- for (i = 0; i < demux->n_samples; i++)
- if (demux->samples[i].offset >= stop)
- start = demux->samples[i].offset;
- break;
- stop = gst_util_uint64_scale (i * demux->timerate,
- GST_SECOND, demux->timescale);
- }
+ for (i = 0; i < demux->n_samples; i++)
+ if (demux->samples[i].offset <= start &&
+ (demux->samples[i].offset +
+ (demux->samples[i].size >> 1)) > start)
+ break;
+
+ start = gst_util_uint64_scale (i * demux->timerate,
+ GST_SECOND, demux->timescale);
+ }
+ if (stop > 0) {
+ for (i = 0; i < demux->n_samples; i++)
+ if (demux->samples[i].offset >= stop)
+ start = demux->samples[i].offset;
+ break;
+ stop = gst_util_uint64_scale (i * demux->timerate,
+ GST_SECOND, demux->timescale);
+ }
} else {
GST_DEBUG_OBJECT (demux, "unsupported segment format, ignoring");
goto exit;
@@ -804,15 +800,15 @@ gst_pmpdemux_change_state (GstElement * element, GstStateChange transition)
}
static GstFlowReturn
-gst_pmpdemux_parse_header (GstPmpdemux * pmpdemux, guint8 *data)
+gst_pmpdemux_parse_header (GstPmpdemux * pmpdemux, guint8 * data)
{
GstFlowReturn ret = GST_FLOW_OK;
PmpHeader *header = &pmpdemux->header;
if (GST_READ_UINT32_LE (data) != 0x6d706d70) {
GST_ELEMENT_ERROR (pmpdemux, STREAM, DECODE,
- (_("This file is a invalid PMP file.")),
- ("Bad magic, expected %d", 0x6d706d70));
+ (_("This file is a invalid PMP file.")),
+ ("Bad magic, expected %d", 0x6d706d70));
ret = GST_FLOW_ERROR;
goto done;
}
@@ -820,9 +816,8 @@ gst_pmpdemux_parse_header (GstPmpdemux * pmpdemux, guint8 *data)
header->version = GST_READ_UINT32_LE (data + 4);
if (header->version != 1) {
GST_ELEMENT_ERROR (pmpdemux, STREAM, DECODE,
- (_("This file is unsupported.")),
- ("Version is %d, only version 1 is supported",
- header->version));
+ (_("This file is unsupported.")),
+ ("Version is %d, only version 1 is supported", header->version));
ret = GST_FLOW_ERROR;
goto done;
}
@@ -845,29 +840,26 @@ gst_pmpdemux_parse_header (GstPmpdemux * pmpdemux, guint8 *data)
header->video.n_frames == 0 ||
!header->video.width || !header->video.height ||
!header->video.scale || !header->video.rate ||
- header->video.rate < header->video.scale ||
+ header->video.rate < header->video.scale ||
header->video.scale > 0xffffff ||
- (header->video.width % 8) != 0 ||
+ (header->video.width % 8) != 0 ||
(header->video.height % 8) != 0 ||
header->video.width > 720 ||
header->video.height > 512 ||
header->audio.format < 0 || header->audio.format > 1 ||
- !header->audio.n_streams ||
- !header->audio.max_frames) {
+ !header->audio.n_streams || !header->audio.max_frames) {
GST_ELEMENT_ERROR (pmpdemux, STREAM, DECODE,
- (_("Bad pmp header.")),
- ("Bad value found in PMP header"));
+ (_("Bad pmp header.")), ("Bad value found in PMP header"));
ret = GST_FLOW_ERROR;
goto done;
}
- if ((header->audio.format == 0 && header->audio.scale != 1152) ||
- (header->audio.format == 1 && header->audio.scale != 1024) ||
+ if ((header->audio.format == 0 && header->audio.scale != 1152) ||
+ (header->audio.format == 1 && header->audio.scale != 1024) ||
(header->audio.rate != 44100 && header->audio.rate != 48000) ||
header->audio.stereo != 1) {
GST_ELEMENT_ERROR (pmpdemux, STREAM, DECODE,
- (_("Bad pmp audio header.")),
- ("Bad value found in pmp audio header"));
+ (_("Bad pmp audio header.")), ("Bad value found in pmp audio header"));
ret = GST_FLOW_ERROR;
goto done;
}
@@ -877,7 +869,7 @@ done:
return ret;
}
-static PmpdemuxStream*
+static PmpdemuxStream *
gst_pmpdemux_create_stream (GstPmpdemux * pmpdemux)
{
PmpdemuxStream *stream;
@@ -924,14 +916,16 @@ gst_pmpdemux_init_streams (GstPmpdemux * pmpdemux)
pmpdemux->n_audio_streams = 0;
pmpdemux->timescale = pmpdemux->header.video.scale;
pmpdemux->timerate = pmpdemux->header.video.rate;
- pmpdemux->duration = gst_util_uint64_scale ((pmpdemux->n_samples * pmpdemux->timescale),
- GST_SECOND, pmpdemux->timerate);
- pmpdemux->fps = (gdouble)pmpdemux->timerate / pmpdemux->timescale;
+ pmpdemux->duration =
+ gst_util_uint64_scale ((pmpdemux->n_samples * pmpdemux->timescale),
+ GST_SECOND, pmpdemux->timerate);
+ pmpdemux->fps = (gdouble) pmpdemux->timerate / pmpdemux->timescale;
gst_pmpdemux_create_streams (pmpdemux);
gst_element_no_more_pads (GST_ELEMENT (pmpdemux));
- gst_segment_set_duration (&pmpdemux->segment, GST_FORMAT_TIME, pmpdemux->duration);
+ gst_segment_set_duration (&pmpdemux->segment, GST_FORMAT_TIME,
+ pmpdemux->duration);
if (pmpdemux->segment.stop < 0)
pmpdemux->segment.stop = pmpdemux->duration;
}
@@ -943,7 +937,8 @@ gst_pmpdemux_loop_state_header (GstPmpdemux * pmpdemux)
GstFlowReturn ret = GST_FLOW_OK;
guint64 cur_offset = pmpdemux->offset;
- ret = gst_pad_pull_range (pmpdemux->sinkpad, cur_offset, PMP_HEADER_SIZE, &buf);
+ ret =
+ gst_pad_pull_range (pmpdemux->sinkpad, cur_offset, PMP_HEADER_SIZE, &buf);
if (ret != GST_FLOW_OK)
goto beach;
@@ -976,7 +971,7 @@ gst_pmpdemux_loop_state_indices (GstPmpdemux * pmpdemux)
pmpdemux->n_samples = pmpdemux->header.video.n_frames;
pmpdemux->samples = g_new (PmpSample, pmpdemux->n_samples);
ret = gst_pad_pull_range (pmpdemux->sinkpad, cur_offset,
- 4 * pmpdemux->n_samples, &buf);
+ 4 * pmpdemux->n_samples, &buf);
if (ret != GST_FLOW_OK)
return ret;
@@ -1020,7 +1015,7 @@ gst_pmpdemux_seek_to_previous_keyframe (GstPmpdemux * pmpdemux)
ref_str->sample_index--;
while (ref_str->sample_index > 0 &&
- !(pmpdemux->samples[ref_str->sample_index].size & 1))
+ !(pmpdemux->samples[ref_str->sample_index].size & 1))
ref_str->sample_index--;
for (i = 1; i < pmpdemux->n_samples; i++)
pmpdemux->streams[i]->sample_index = ref_str->sample_index;
@@ -1039,8 +1034,7 @@ eos:
*/
static gboolean
gst_pmpdemux_prepare_current_sample (GstPmpdemux * pmpdemux,
- PmpdemuxStream * stream, gint index,
- PmpFrame *frame)
+ PmpdemuxStream * stream, gint index, PmpFrame * frame)
{
guint64 position;
guint64 time_position;
@@ -1074,20 +1068,18 @@ gst_pmpdemux_prepare_current_sample (GstPmpdemux * pmpdemux,
if (stream->sample_index == -1) {
stream->discont = TRUE;
stream->sample_index =
- gst_util_uint64_scale (stream->time_position, pmpdemux->n_samples,
- pmpdemux->duration);
+ gst_util_uint64_scale (stream->time_position, pmpdemux->n_samples,
+ pmpdemux->duration);
GST_DEBUG_OBJECT (pmpdemux, "seeked to %" GST_TIME_FORMAT " sample @%d",
- GST_TIME_ARGS (stream->time_position),
- stream->sample_index);
+ GST_TIME_ARGS (stream->time_position), stream->sample_index);
if (stream->pad)
gst_pad_push_event (stream->pad,
- gst_event_new_new_segment (FALSE,
- pmpdemux->segment.rate,
- pmpdemux->segment.format,
- pmpdemux->segment.start,
- pmpdemux->segment.stop,
- pmpdemux->segment.time));
+ gst_event_new_new_segment (FALSE,
+ pmpdemux->segment.rate,
+ pmpdemux->segment.format,
+ pmpdemux->segment.start,
+ pmpdemux->segment.stop, pmpdemux->segment.time));
}
if (stream->sample_index >= pmpdemux->n_samples)
@@ -1097,10 +1089,10 @@ gst_pmpdemux_prepare_current_sample (GstPmpdemux * pmpdemux,
position = pmpdemux->samples[stream->sample_index].offset;
GST_DEBUG_OBJECT (pmpdemux, "prepare sample %d offset %lld for stream %d",
- stream->sample_index, position, index);
+ stream->sample_index, position, index);
ret = gst_pad_pull_range (pmpdemux->sinkpad, position,
- PMP_FRAME_HEADER_SIZE, &buf);
+ PMP_FRAME_HEADER_SIZE, &buf);
if (ret != GST_FLOW_OK)
goto eos;
@@ -1113,21 +1105,22 @@ gst_pmpdemux_prepare_current_sample (GstPmpdemux * pmpdemux,
gst_buffer_unref (buf);
GST_DEBUG_OBJECT (pmpdemux, "frame: n_audio_frames %d video_len %d",
- frame->n_audio_frames, frame->video_len);
+ frame->n_audio_frames, frame->video_len);
frame->offset = position;
frame->offset += PMP_FRAME_HEADER_SIZE;
frame->offset += 4 * frame->n_audio_frames * pmpdemux->header.audio.n_streams;
if (index) {
- ret = gst_pad_pull_range (pmpdemux->sinkpad, position + PMP_FRAME_HEADER_SIZE,
- 4 * frame->n_audio_frames * pmpdemux->header.audio.n_streams,
- &buf);
+ ret =
+ gst_pad_pull_range (pmpdemux->sinkpad, position + PMP_FRAME_HEADER_SIZE,
+ 4 * frame->n_audio_frames * pmpdemux->header.audio.n_streams, &buf);
if (ret != GST_FLOW_OK)
goto eos;
data = GST_BUFFER_DATA (buf);
- for (n = 0; n < frame->n_audio_frames * pmpdemux->header.audio.n_streams; n++)
+ for (n = 0; n < frame->n_audio_frames * pmpdemux->header.audio.n_streams;
+ n++)
frame->frames_len[n] = GST_READ_UINT32_LE (data + n * 4);
gst_buffer_unref (buf);
}
@@ -1193,7 +1186,7 @@ gst_pmpdemux_sync_streams (GstPmpdemux * demux)
continue;
} else {
/* push mode is byte position based */
- continue;
+ continue;
}
if (stream->sent_eos)
@@ -1316,23 +1309,23 @@ gst_pmpdemux_loop_state_frame (GstPmpdemux * pmpdemux)
if (index) {
offset += frame.video_len;
for (i = 0; i < frame.n_audio_frames * (index - 1); i++)
- offset += frame.frames_len[i];
+ offset += frame.frames_len[i];
} else {
/* video */
frame.frames_len[0] = frame.video_len;
}
GST_DEBUG_OBJECT (pmpdemux, "last stop: %" GST_TIME_FORMAT,
- GST_TIME_ARGS (min_time));
+ GST_TIME_ARGS (min_time));
duration = pmpdemux->duration;
timestamp = gst_util_uint64_scale (stream->sample_index * pmpdemux->timescale,
- GST_SECOND, pmpdemux->timerate);
+ GST_SECOND, pmpdemux->timerate);
stream->timestamp = timestamp;
for (i = 0; i < n_frames; i++) {
size = frame.frames_len[i];
GST_LOG_OBJECT (pmpdemux, "reading %d bytes @ %" G_GUINT64_FORMAT, size,
- offset);
+ offset);
ret = gst_pad_pull_range (pmpdemux->sinkpad, offset, size, &buf);
if (ret != GST_FLOW_OK)
@@ -1340,36 +1333,37 @@ gst_pmpdemux_loop_state_frame (GstPmpdemux * pmpdemux)
pmpdemux->last_ts = timestamp;
if (pmpdemux->segment.rate >= 0) {
- gst_segment_set_last_stop (&pmpdemux->segment, GST_FORMAT_TIME, timestamp);
+ gst_segment_set_last_stop (&pmpdemux->segment, GST_FORMAT_TIME,
+ timestamp);
gst_pmpdemux_sync_streams (pmpdemux);
}
if (stream->pad && gst_pad_is_linked (stream->pad)) {
/* we're going to modify the metadata */
buf = gst_buffer_make_metadata_writable (buf);
if (buf == NULL)
- goto next;
+ goto next;
GST_BUFFER_TIMESTAMP (buf) = timestamp;
GST_BUFFER_OFFSET (buf) = -1;
GST_BUFFER_OFFSET_END (buf) = -1;
if (stream->discont) {
- GST_LOG_OBJECT (pmpdemux, "marking discont buffer");
- GST_BUFFER_FLAG_SET (buf, GST_BUFFER_FLAG_DISCONT);
- stream->discont = FALSE;
+ GST_LOG_OBJECT (pmpdemux, "marking discont buffer");
+ GST_BUFFER_FLAG_SET (buf, GST_BUFFER_FLAG_DISCONT);
+ stream->discont = FALSE;
}
if (!(pmpdemux->samples[stream->sample_index].size & 1))
- GST_BUFFER_FLAG_SET (buf, GST_BUFFER_FLAG_DELTA_UNIT);
+ GST_BUFFER_FLAG_SET (buf, GST_BUFFER_FLAG_DELTA_UNIT);
gst_buffer_set_caps (buf, stream->caps);
GST_LOG_OBJECT (pmpdemux,
- "Pushing buffer with time %" GST_TIME_FORMAT ", duration %"
- GST_TIME_FORMAT " on pad %s",
- GST_TIME_ARGS (GST_BUFFER_TIMESTAMP (buf)),
- GST_TIME_ARGS (GST_BUFFER_DURATION (buf)),
- GST_PAD_NAME (stream->pad));
+ "Pushing buffer with time %" GST_TIME_FORMAT ", duration %"
+ GST_TIME_FORMAT " on pad %s",
+ GST_TIME_ARGS (GST_BUFFER_TIMESTAMP (buf)),
+ GST_TIME_ARGS (GST_BUFFER_DURATION (buf)),
+ GST_PAD_NAME (stream->pad));
stream->last_ret = gst_pad_push (stream->pad, buf);
} else {
GST_DEBUG_OBJECT (pmpdemux, "No output pad for stream, ignoring");
@@ -1490,7 +1484,8 @@ pause:
stop = pmpdemux->segment.duration;
if (pmpdemux->segment.rate >= 0) {
- GST_LOG_OBJECT (pmpdemux, "Sending segment done, at end of segment");
+ GST_LOG_OBJECT (pmpdemux,
+ "Sending segment done, at end of segment");
gst_element_post_message (GST_ELEMENT_CAST (pmpdemux),
gst_message_new_segment_done (GST_OBJECT_CAST (pmpdemux),
GST_FORMAT_TIME, stop));
@@ -1558,99 +1553,101 @@ gst_pmpdemux_chain (GstPad * sinkpad, GstBuffer * inbuf)
data = gst_adapter_take (demux->adapter, demux->neededbytes);
/* parse the file header */
- ret = gst_pmpdemux_parse_header (demux, (guint8 *) data);
+ ret = gst_pmpdemux_parse_header (demux, (guint8 *) data);
- g_free (data);
+ g_free (data);
if (ret != GST_FLOW_OK) {
ret = GST_FLOW_ERROR;
break;
}
- gst_pmpdemux_init_streams (demux);
- demux->offset += demux->neededbytes;
- demux->neededbytes = demux->n_samples * 4;
- demux->state = PMPDEMUX_STATE_INDICES;
+ gst_pmpdemux_init_streams (demux);
+ demux->offset += demux->neededbytes;
+ demux->neededbytes = demux->n_samples * 4;
+ demux->state = PMPDEMUX_STATE_INDICES;
break;
}
case PMPDEMUX_STATE_INDICES:{
guint8 *data;
- guint32 i;
- guint64 offset;
+ guint32 i;
+ guint64 offset;
GST_DEBUG_OBJECT (demux, "Parsing indices");
data = gst_adapter_take (demux->adapter, demux->neededbytes);
/* parse the indices */
- demux->samples = g_new (PmpSample, demux->n_samples);
- offset = demux->offset + 4 * demux->n_samples;
- for (i = 0; i < demux->n_samples; i++) {
- demux->samples[i].size = GST_READ_UINT32_LE (data + i * 4);
- demux->samples[i].offset = offset;
- offset += (demux->samples[i].size >> 1);
- }
+ demux->samples = g_new (PmpSample, demux->n_samples);
+ offset = demux->offset + 4 * demux->n_samples;
+ for (i = 0; i < demux->n_samples; i++) {
+ demux->samples[i].size = GST_READ_UINT32_LE (data + i * 4);
+ demux->samples[i].offset = offset;
+ offset += (demux->samples[i].size >> 1);
+ }
- g_free (data);
+ g_free (data);
GST_DEBUG_OBJECT (demux, "Finished parsing the indices");
- demux->offset += 4 * demux->n_samples;
- demux->neededbytes = PMP_FRAME_HEADER_SIZE;
- demux->state = PMPDEMUX_STATE_FRAME_HEADER;
+ demux->offset += 4 * demux->n_samples;
+ demux->neededbytes = PMP_FRAME_HEADER_SIZE;
+ demux->state = PMPDEMUX_STATE_FRAME_HEADER;
break;
}
case PMPDEMUX_STATE_FRAME_HEADER:{
- guint8 *data;
- PmpFrame *frame = &demux->cur_frame;
+ guint8 *data;
+ PmpFrame *frame = &demux->cur_frame;
- GST_DEBUG_OBJECT (demux, "Parsing movie frame header for offset %lld",
- demux->offset);
+ GST_DEBUG_OBJECT (demux, "Parsing movie frame header for offset %lld",
+ demux->offset);
- data = gst_adapter_take (demux->adapter, PMP_FRAME_HEADER_SIZE);
+ data = gst_adapter_take (demux->adapter, PMP_FRAME_HEADER_SIZE);
- frame->n_audio_frames = GST_READ_UINT8 (data);
- frame->first_delay = GST_READ_UINT32_LE (data + 1);
- frame->last_delay = GST_READ_UINT32_LE (data + 5);
- frame->video_len = GST_READ_UINT32_LE (data + 9);
+ frame->n_audio_frames = GST_READ_UINT8 (data);
+ frame->first_delay = GST_READ_UINT32_LE (data + 1);
+ frame->last_delay = GST_READ_UINT32_LE (data + 5);
+ frame->video_len = GST_READ_UINT32_LE (data + 9);
- g_free (data);
+ g_free (data);
- demux->offset += demux->neededbytes;
- demux->neededbytes = 4 * frame->n_audio_frames * demux->header.audio.n_streams;
- demux->state = PMPDEMUX_STATE_FRAME_AUDIO_HEADER;
+ demux->offset += demux->neededbytes;
+ demux->neededbytes =
+ 4 * frame->n_audio_frames * demux->header.audio.n_streams;
+ demux->state = PMPDEMUX_STATE_FRAME_AUDIO_HEADER;
- GST_DEBUG_OBJECT (demux, "frame: n_audio_frames %d video_len %d",
- frame->n_audio_frames, frame->video_len);
- break;
+ GST_DEBUG_OBJECT (demux, "frame: n_audio_frames %d video_len %d",
+ frame->n_audio_frames, frame->video_len);
+ break;
}
case PMPDEMUX_STATE_FRAME_AUDIO_HEADER:{
- guint8 *data;
- PmpFrame *frame = &demux->cur_frame;
- gsize audio_len = 0;
- guint i;
-
- GST_DEBUG_OBJECT (demux, "Parsing frame audio header for offset %lld",
- demux->offset);
-
- data = gst_adapter_take (demux->adapter, demux->neededbytes);
- for (i = 0; i < frame->n_audio_frames * demux->header.audio.n_streams; i++) {
- frame->frames_len[i] = GST_READ_UINT32_LE (data + i * 4);
- audio_len += frame->frames_len[i];
- }
- g_free (data);
-
- demux->offset += demux->neededbytes;
- demux->neededbytes = frame->video_len + audio_len;
- demux->state = PMPDEMUX_STATE_FRAME_DATA;
- break;
+ guint8 *data;
+ PmpFrame *frame = &demux->cur_frame;
+ gsize audio_len = 0;
+ guint i;
+
+ GST_DEBUG_OBJECT (demux, "Parsing frame audio header for offset %lld",
+ demux->offset);
+
+ data = gst_adapter_take (demux->adapter, demux->neededbytes);
+ for (i = 0; i < frame->n_audio_frames * demux->header.audio.n_streams;
+ i++) {
+ frame->frames_len[i] = GST_READ_UINT32_LE (data + i * 4);
+ audio_len += frame->frames_len[i];
+ }
+ g_free (data);
+
+ demux->offset += demux->neededbytes;
+ demux->neededbytes = frame->video_len + audio_len;
+ demux->state = PMPDEMUX_STATE_FRAME_DATA;
+ break;
}
case PMPDEMUX_STATE_FRAME_DATA:{
GstBuffer *outbuf;
PmpdemuxStream *stream = NULL;
- PmpFrame *frame = &demux->cur_frame;
- gsize size;
- guint64 offset;
- int index;
+ PmpFrame *frame = &demux->cur_frame;
+ gsize size;
+ guint64 offset;
+ int index;
int i;
GST_DEBUG_OBJECT (demux, "Parsing movie frame data for offset %lld",
@@ -1661,36 +1658,35 @@ gst_pmpdemux_chain (GstPad * sinkpad, GstBuffer * inbuf)
g_return_val_if_fail (outbuf != NULL, GST_FLOW_ERROR);
- for (i = 0; i < demux->n_streams; i++) {
- stream = demux->streams[i];
- if (stream->sample_index == -1) {
- if (stream->pad && gst_pad_is_linked (stream->pad)) {
- GstEvent *event;
-
- GST_LOG_OBJECT (demux,
- "New segment start %" GST_TIME_FORMAT ", stop %"
- GST_TIME_FORMAT " time %" GST_TIME_FORMAT " on pad %s",
- GST_TIME_ARGS (demux->segment.start),
- GST_TIME_ARGS (demux->segment.stop),
- GST_TIME_ARGS (demux->segment.time),
- GST_PAD_NAME (stream->pad));
-
- event = gst_event_new_new_segment (FALSE,
- demux->segment.rate,
- demux->segment.format,
- demux->segment.start,
- demux->segment.stop,
- demux->segment.time);
- gst_pad_push_event (stream->pad, event);
- }
- stream->sample_index = 0;
- }
- }
-
- index = demux->streams[0]->sample_index;
- demux->last_ts = gst_util_uint64_scale (index * demux->timescale,
- GST_SECOND, demux->timerate);
- GST_BUFFER_TIMESTAMP (outbuf) = demux->last_ts;
+ for (i = 0; i < demux->n_streams; i++) {
+ stream = demux->streams[i];
+ if (stream->sample_index == -1) {
+ if (stream->pad && gst_pad_is_linked (stream->pad)) {
+ GstEvent *event;
+
+ GST_LOG_OBJECT (demux,
+ "New segment start %" GST_TIME_FORMAT ", stop %"
+ GST_TIME_FORMAT " time %" GST_TIME_FORMAT " on pad %s",
+ GST_TIME_ARGS (demux->segment.start),
+ GST_TIME_ARGS (demux->segment.stop),
+ GST_TIME_ARGS (demux->segment.time),
+ GST_PAD_NAME (stream->pad));
+
+ event = gst_event_new_new_segment (FALSE,
+ demux->segment.rate,
+ demux->segment.format,
+ demux->segment.start,
+ demux->segment.stop, demux->segment.time);
+ gst_pad_push_event (stream->pad, event);
+ }
+ stream->sample_index = 0;
+ }
+ }
+
+ index = demux->streams[0]->sample_index;
+ demux->last_ts = gst_util_uint64_scale (index * demux->timescale,
+ GST_SECOND, demux->timerate);
+ GST_BUFFER_TIMESTAMP (outbuf) = demux->last_ts;
/* position reporting */
gst_segment_set_last_stop (&demux->segment, GST_FORMAT_TIME,
@@ -1698,58 +1694,58 @@ gst_pmpdemux_chain (GstPad * sinkpad, GstBuffer * inbuf)
gst_pmpdemux_sync_streams (demux);
/* send buffer */
- offset = 0;
- for (i = 0; i < demux->n_streams; i++) {
- GstBuffer *buf;
- guint j, n_frames;
-
- stream = demux->streams[i];
- stream->timestamp = demux->last_ts;
- n_frames = i == 0 ? 1 : frame->n_audio_frames;
- for (j = 0; j < n_frames; j++) {
- if (i == 0)
- size = frame->video_len;
- else
- size = frame->frames_len[(i - 1) * frame->n_audio_frames + j];
-
- buf = gst_buffer_create_sub (outbuf, offset, size);
- buf = gst_buffer_make_metadata_writable (buf);
- if (buf) {
- stream = demux->streams[i];
- if (stream->pad && gst_pad_is_linked (stream->pad)) {
- if (j == 0)
- GST_BUFFER_TIMESTAMP (buf) = demux->last_ts;
- else
- GST_BUFFER_TIMESTAMP (buf) = GST_CLOCK_TIME_NONE;
-
- if (!(demux->samples[stream->sample_index].size & 1))
- GST_BUFFER_FLAG_SET (buf, GST_BUFFER_FLAG_DELTA_UNIT);
- gst_buffer_set_caps (buf, stream->caps);
-
- GST_LOG_OBJECT (demux,
- "Pushing buffer with time %" GST_TIME_FORMAT ", duration %"
- GST_TIME_FORMAT " on pad %s",
- GST_TIME_ARGS (GST_BUFFER_TIMESTAMP (buf)),
- GST_TIME_ARGS (GST_BUFFER_DURATION (buf)),
- GST_PAD_NAME (stream->pad));
- stream->last_ret = gst_pad_push (stream->pad, buf);
- } else {
- gst_buffer_unref (buf);
- ret = GST_FLOW_OK;
- }
- }
- offset += size;
- }
- }
- gst_buffer_unref (outbuf);
+ offset = 0;
+ for (i = 0; i < demux->n_streams; i++) {
+ GstBuffer *buf;
+ guint j, n_frames;
+
+ stream = demux->streams[i];
+ stream->timestamp = demux->last_ts;
+ n_frames = i == 0 ? 1 : frame->n_audio_frames;
+ for (j = 0; j < n_frames; j++) {
+ if (i == 0)
+ size = frame->video_len;
+ else
+ size = frame->frames_len[(i - 1) * frame->n_audio_frames + j];
+
+ buf = gst_buffer_create_sub (outbuf, offset, size);
+ buf = gst_buffer_make_metadata_writable (buf);
+ if (buf) {
+ stream = demux->streams[i];
+ if (stream->pad && gst_pad_is_linked (stream->pad)) {
+ if (j == 0)
+ GST_BUFFER_TIMESTAMP (buf) = demux->last_ts;
+ else
+ GST_BUFFER_TIMESTAMP (buf) = GST_CLOCK_TIME_NONE;
+
+ if (!(demux->samples[stream->sample_index].size & 1))
+ GST_BUFFER_FLAG_SET (buf, GST_BUFFER_FLAG_DELTA_UNIT);
+ gst_buffer_set_caps (buf, stream->caps);
+
+ GST_LOG_OBJECT (demux,
+ "Pushing buffer with time %" GST_TIME_FORMAT ", duration %"
+ GST_TIME_FORMAT " on pad %s",
+ GST_TIME_ARGS (GST_BUFFER_TIMESTAMP (buf)),
+ GST_TIME_ARGS (GST_BUFFER_DURATION (buf)),
+ GST_PAD_NAME (stream->pad));
+ stream->last_ret = gst_pad_push (stream->pad, buf);
+ } else {
+ gst_buffer_unref (buf);
+ ret = GST_FLOW_OK;
+ }
+ }
+ offset += size;
+ }
+ }
+ gst_buffer_unref (outbuf);
/* combine flows */
ret = gst_pmpdemux_combine_flows (demux, stream, ret);
- for (i = 0; i < demux->n_streams; i++) {
- demux->streams[i]->sample_index++;
- demux->streams[i]->time_position = demux->streams[i]->timestamp;
- }
+ for (i = 0; i < demux->n_streams; i++) {
+ demux->streams[i]->sample_index++;
+ demux->streams[i]->time_position = demux->streams[i]->timestamp;
+ }
/* update current offset and figure out size of next buffer */
GST_LOG_OBJECT (demux, "increasing offset %" G_GUINT64_FORMAT " by %u",
@@ -1757,10 +1753,10 @@ gst_pmpdemux_chain (GstPad * sinkpad, GstBuffer * inbuf)
demux->offset += demux->neededbytes;
GST_LOG_OBJECT (demux, "offset is now %lld", demux->offset);
- if (demux->streams[0]->sample_index >= demux->n_samples)
+ if (demux->streams[0]->sample_index >= demux->n_samples)
goto eos;
- demux->neededbytes = PMP_FRAME_HEADER_SIZE;
- demux->state = PMPDEMUX_STATE_FRAME_HEADER;
+ demux->neededbytes = PMP_FRAME_HEADER_SIZE;
+ demux->state = PMPDEMUX_STATE_FRAME_HEADER;
break;
}
default:
@@ -1832,8 +1828,7 @@ pmpdemux_sink_activate_push (GstPad * sinkpad, gboolean active)
}
static gboolean
-gst_pmpdemux_add_stream (GstPmpdemux * pmpdemux,
- PmpdemuxStream * stream)
+gst_pmpdemux_add_stream (GstPmpdemux * pmpdemux, PmpdemuxStream * stream)
{
if (pmpdemux->n_streams >= GST_PMPDEMUX_MAX_STREAMS)
goto too_many_streams;
@@ -1843,7 +1838,8 @@ gst_pmpdemux_add_stream (GstPmpdemux * pmpdemux,
gchar *name = g_strdup_printf ("video_%02d", pmpdemux->n_video_streams);
stream->pad =
- gst_pad_new_from_static_template (&gst_pmpdemux_videosrc_template, name);
+ gst_pad_new_from_static_template (&gst_pmpdemux_videosrc_template,
+ name);
g_free (name);
stream->fps_n = pmpdemux->timerate;
@@ -1860,7 +1856,8 @@ gst_pmpdemux_add_stream (GstPmpdemux * pmpdemux,
gchar *name = g_strdup_printf ("audio_%02d", pmpdemux->n_audio_streams);
stream->pad =
- gst_pad_new_from_static_template (&gst_pmpdemux_audiosrc_template, name);
+ gst_pad_new_from_static_template (&gst_pmpdemux_audiosrc_template,
+ name);
g_free (name);
if (stream->caps) {
gst_caps_set_simple (stream->caps,
@@ -1910,10 +1907,10 @@ pmpdemux_video_caps (GstPmpdemux * pmpdemux, PmpdemuxStream * stream,
GstCaps *caps;
if (format == 0)
- caps = gst_caps_new_simple ("video/mpeg", "mpegversion", G_TYPE_INT, 4,
- "systemstream", G_TYPE_BOOLEAN, FALSE, NULL);
+ caps = gst_caps_new_simple ("video/mpeg", "mpegversion", G_TYPE_INT, 4,
+ "systemstream", G_TYPE_BOOLEAN, FALSE, NULL);
else
- caps = gst_caps_new_simple ("video/x-h264", NULL);
+ caps = gst_caps_new_simple ("video/x-h264", NULL);
return caps;
}
@@ -1926,16 +1923,17 @@ pmpdemux_audio_caps (GstPmpdemux * pmpdemux, PmpdemuxStream * stream,
GST_DEBUG_OBJECT (pmpdemux, "resolve format %d", format);
if (format == 0)
- caps = gst_caps_new_simple ("audio/mpeg", "layer", G_TYPE_INT, 3,
- "mpegversion", G_TYPE_INT, 1, NULL);
+ caps = gst_caps_new_simple ("audio/mpeg", "layer", G_TYPE_INT, 3,
+ "mpegversion", G_TYPE_INT, 1, NULL);
else
- caps = gst_caps_new_simple ("audio/mpeg",
- "mpegversion", G_TYPE_INT, 4, "framed", G_TYPE_BOOLEAN, TRUE, NULL);
+ caps = gst_caps_new_simple ("audio/mpeg",
+ "mpegversion", G_TYPE_INT, 4, "framed", G_TYPE_BOOLEAN, TRUE, NULL);
return caps;
}
static GstStaticCaps typefind_caps = GST_STATIC_CAPS ("video/x-pmp");
-static void gst_pmp_typefind (GstTypeFind *find, gpointer user_data)
+static void
+gst_pmp_typefind (GstTypeFind * find, gpointer user_data)
{
guint8 *data;
guint32 version;
@@ -1951,7 +1949,7 @@ static void gst_pmp_typefind (GstTypeFind *find, gpointer user_data)
if (version != 0 && version != 1)
return;
gst_type_find_suggest (find, GST_TYPE_FIND_MAXIMUM,
- gst_static_caps_get (&typefind_caps));
+ gst_static_caps_get (&typefind_caps));
}
static gboolean
@@ -1960,8 +1958,8 @@ plugin_init (GstPlugin * plugin)
static char *extensions[] = { "pmp", NULL };
gst_type_find_register (plugin, "pmptypefind", GST_RANK_PRIMARY,
- gst_pmp_typefind, extensions,
- gst_static_caps_get (&typefind_caps), NULL, NULL);
+ gst_pmp_typefind, extensions,
+ gst_static_caps_get (&typefind_caps), NULL, NULL);
return gst_element_register (plugin, "pmpdemux", GST_RANK_PRIMARY,
GST_TYPE_PMPDEMUX);
@@ -1971,4 +1969,4 @@ GST_PLUGIN_DEFINE (GST_VERSION_MAJOR,
GST_VERSION_MINOR,
"pmp",
"PMP demuxer",
- plugin_init, VERSION, "LGPL", PACKAGE, "")
+ plugin_init, VERSION, GST_LICENSE, GST_PACKAGE_NAME, GST_PACKAGE_ORIGIN)