Fixed formatting.
Replaced else if with switch.
This commit is contained in:
parent
1f1a2fe6e5
commit
ec252a3bc4
@ -59,7 +59,8 @@ static int tsmf_gstreamer_pipeline_set_state(TSMFGstreamerDecoder *mdecoder,
|
|||||||
const char *get_type(TSMFGstreamerDecoder *mdecoder)
|
const char *get_type(TSMFGstreamerDecoder *mdecoder)
|
||||||
{
|
{
|
||||||
assert(mdecoder);
|
assert(mdecoder);
|
||||||
if(mdecoder->media_type == TSMF_MAJOR_TYPE_VIDEO)
|
|
||||||
|
if (mdecoder->media_type == TSMF_MAJOR_TYPE_VIDEO)
|
||||||
return "VIDEO";
|
return "VIDEO";
|
||||||
else
|
else
|
||||||
return "AUDIO";
|
return "AUDIO";
|
||||||
@ -84,13 +85,18 @@ static gboolean tsmf_gstreamer_seek_data(GstAppSrc *src, guint64 offset, gpointe
|
|||||||
TSMFGstreamerDecoder *mdecoder = user_data;
|
TSMFGstreamerDecoder *mdecoder = user_data;
|
||||||
(void)mdecoder;
|
(void)mdecoder;
|
||||||
DEBUG_TSMF("%s offset=%llu", get_type(mdecoder), offset);
|
DEBUG_TSMF("%s offset=%llu", get_type(mdecoder), offset);
|
||||||
if(!mdecoder->paused)
|
|
||||||
|
if (!mdecoder->paused)
|
||||||
gst_element_set_state(mdecoder->pipe, GST_STATE_PAUSED);
|
gst_element_set_state(mdecoder->pipe, GST_STATE_PAUSED);
|
||||||
|
|
||||||
gst_app_src_end_of_stream((GstAppSrc *)mdecoder->src);
|
gst_app_src_end_of_stream((GstAppSrc *)mdecoder->src);
|
||||||
if(!mdecoder->paused)
|
|
||||||
|
if (!mdecoder->paused)
|
||||||
gst_element_set_state(mdecoder->pipe, GST_STATE_PLAYING);
|
gst_element_set_state(mdecoder->pipe, GST_STATE_PLAYING);
|
||||||
if(mdecoder->sync_cb)
|
|
||||||
|
if (mdecoder->sync_cb)
|
||||||
mdecoder->sync_cb(mdecoder->stream);
|
mdecoder->sync_cb(mdecoder->stream);
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -105,22 +111,34 @@ static inline const GstClockTime tsmf_gstreamer_timestamp_ms_to_gst(UINT64 ms_ti
|
|||||||
static const char *tsmf_gstreamer_state_name(GstState state)
|
static const char *tsmf_gstreamer_state_name(GstState state)
|
||||||
{
|
{
|
||||||
const char *name;
|
const char *name;
|
||||||
if(state == GST_STATE_PLAYING)
|
|
||||||
name = NAME_GST_STATE_PLAYING;
|
switch (state)
|
||||||
else
|
{
|
||||||
if(state == GST_STATE_PAUSED)
|
case GST_STATE_PLAYING:
|
||||||
|
name = NAME_GST_STATE_PLAYING;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case GST_STATE_PAUSED:
|
||||||
name = NAME_GST_STATE_PAUSED;
|
name = NAME_GST_STATE_PAUSED;
|
||||||
else
|
break;
|
||||||
if(state == GST_STATE_READY)
|
|
||||||
name = NAME_GST_STATE_READY;
|
case GST_STATE_READY:
|
||||||
else
|
name = NAME_GST_STATE_READY;
|
||||||
if(state == GST_STATE_NULL)
|
break;
|
||||||
name = NAME_GST_STATE_NULL;
|
|
||||||
else
|
case GST_STATE_NULL:
|
||||||
if(state == GST_STATE_VOID_PENDING)
|
name = NAME_GST_STATE_NULL;
|
||||||
name = NAME_GST_STATE_VOID_PENDING;
|
break;
|
||||||
else
|
|
||||||
name = NAME_GST_STATE_OTHER;
|
case GST_STATE_VOID_PENDING:
|
||||||
|
name = NAME_GST_STATE_VOID_PENDING;
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
name = NAME_GST_STATE_OTHER;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -128,25 +146,30 @@ int tsmf_gstreamer_pipeline_set_state(TSMFGstreamerDecoder *mdecoder, GstState d
|
|||||||
{
|
{
|
||||||
GstStateChangeReturn state_change;
|
GstStateChangeReturn state_change;
|
||||||
const char *name;
|
const char *name;
|
||||||
if(!mdecoder)
|
|
||||||
|
if (!mdecoder)
|
||||||
return 0;
|
return 0;
|
||||||
if(!mdecoder->pipe)
|
|
||||||
|
if (!mdecoder->pipe)
|
||||||
return 0; /* Just in case this is called during startup or shutdown when we don't expect it */
|
return 0; /* Just in case this is called during startup or shutdown when we don't expect it */
|
||||||
if(desired_state == mdecoder->state)
|
|
||||||
|
if (desired_state == mdecoder->state)
|
||||||
return 0; /* Redundant request - Nothing to do */
|
return 0; /* Redundant request - Nothing to do */
|
||||||
|
|
||||||
name = tsmf_gstreamer_state_name(desired_state); /* For debug */
|
name = tsmf_gstreamer_state_name(desired_state); /* For debug */
|
||||||
DEBUG_TSMF("%s to %s", get_type(mdecoder), name);
|
DEBUG_TSMF("%s to %s", get_type(mdecoder), name);
|
||||||
state_change = gst_element_set_state(mdecoder->pipe, desired_state);
|
state_change = gst_element_set_state(mdecoder->pipe, desired_state);
|
||||||
if(state_change == GST_STATE_CHANGE_FAILURE)
|
|
||||||
|
if (state_change == GST_STATE_CHANGE_FAILURE)
|
||||||
DEBUG_WARN("(%s) GST_STATE_CHANGE_FAILURE.", name);
|
DEBUG_WARN("(%s) GST_STATE_CHANGE_FAILURE.", name);
|
||||||
|
else if (state_change == GST_STATE_CHANGE_ASYNC)
|
||||||
|
{
|
||||||
|
DEBUG_WARN("(%s) GST_STATE_CHANGE_ASYNC.", name);
|
||||||
|
mdecoder->state = desired_state;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
if(state_change == GST_STATE_CHANGE_ASYNC)
|
mdecoder->state = desired_state;
|
||||||
{
|
|
||||||
DEBUG_WARN("(%s) GST_STATE_CHANGE_ASYNC.", name);
|
|
||||||
mdecoder->state = desired_state;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
mdecoder->state = desired_state;
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -172,21 +195,27 @@ static GstBuffer *tsmf_get_buffer_from_payload(TS_AM_MEDIA_TYPE *media_type)
|
|||||||
static BOOL tsmf_gstreamer_set_format(ITSMFDecoder *decoder, TS_AM_MEDIA_TYPE *media_type)
|
static BOOL tsmf_gstreamer_set_format(ITSMFDecoder *decoder, TS_AM_MEDIA_TYPE *media_type)
|
||||||
{
|
{
|
||||||
TSMFGstreamerDecoder *mdecoder = (TSMFGstreamerDecoder *) decoder;
|
TSMFGstreamerDecoder *mdecoder = (TSMFGstreamerDecoder *) decoder;
|
||||||
if(!mdecoder)
|
|
||||||
|
if (!mdecoder)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
DEBUG_TSMF("");
|
DEBUG_TSMF("");
|
||||||
switch(media_type->MajorType)
|
|
||||||
|
switch (media_type->MajorType)
|
||||||
{
|
{
|
||||||
case TSMF_MAJOR_TYPE_VIDEO:
|
case TSMF_MAJOR_TYPE_VIDEO:
|
||||||
mdecoder->media_type = TSMF_MAJOR_TYPE_VIDEO;
|
mdecoder->media_type = TSMF_MAJOR_TYPE_VIDEO;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case TSMF_MAJOR_TYPE_AUDIO:
|
case TSMF_MAJOR_TYPE_AUDIO:
|
||||||
mdecoder->media_type = TSMF_MAJOR_TYPE_AUDIO;
|
mdecoder->media_type = TSMF_MAJOR_TYPE_AUDIO;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
switch(media_type->SubType)
|
|
||||||
|
switch (media_type->SubType)
|
||||||
{
|
{
|
||||||
case TSMF_SUB_TYPE_WVC1:
|
case TSMF_SUB_TYPE_WVC1:
|
||||||
mdecoder->gst_caps = gst_caps_new_simple("video/x-wmv",
|
mdecoder->gst_caps = gst_caps_new_simple("video/x-wmv",
|
||||||
@ -198,6 +227,7 @@ static BOOL tsmf_gstreamer_set_format(ITSMFDecoder *decoder, TS_AM_MEDIA_TYPE *m
|
|||||||
//"framerate", GST_TYPE_FRACTION, media_type->SamplesPerSecond.Numerator, media_type->SamplesPerSecond.Denominator,
|
//"framerate", GST_TYPE_FRACTION, media_type->SamplesPerSecond.Numerator, media_type->SamplesPerSecond.Denominator,
|
||||||
NULL);
|
NULL);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case TSMF_SUB_TYPE_MP4S:
|
case TSMF_SUB_TYPE_MP4S:
|
||||||
mdecoder->gst_caps = gst_caps_new_simple("video/x-divx",
|
mdecoder->gst_caps = gst_caps_new_simple("video/x-divx",
|
||||||
"divxversion", G_TYPE_INT, 5,
|
"divxversion", G_TYPE_INT, 5,
|
||||||
@ -206,6 +236,7 @@ static BOOL tsmf_gstreamer_set_format(ITSMFDecoder *decoder, TS_AM_MEDIA_TYPE *m
|
|||||||
"height", G_TYPE_INT, media_type->Height,
|
"height", G_TYPE_INT, media_type->Height,
|
||||||
NULL);
|
NULL);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case TSMF_SUB_TYPE_MP42:
|
case TSMF_SUB_TYPE_MP42:
|
||||||
mdecoder->gst_caps = gst_caps_new_simple("video/x-msmpeg",
|
mdecoder->gst_caps = gst_caps_new_simple("video/x-msmpeg",
|
||||||
"msmpegversion", G_TYPE_INT, 42,
|
"msmpegversion", G_TYPE_INT, 42,
|
||||||
@ -214,6 +245,7 @@ static BOOL tsmf_gstreamer_set_format(ITSMFDecoder *decoder, TS_AM_MEDIA_TYPE *m
|
|||||||
"height", G_TYPE_INT, media_type->Height,
|
"height", G_TYPE_INT, media_type->Height,
|
||||||
NULL);
|
NULL);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case TSMF_SUB_TYPE_MP43:
|
case TSMF_SUB_TYPE_MP43:
|
||||||
mdecoder->gst_caps = gst_caps_new_simple("video/x-msmpeg",
|
mdecoder->gst_caps = gst_caps_new_simple("video/x-msmpeg",
|
||||||
"bitrate", G_TYPE_UINT, media_type->BitRate,
|
"bitrate", G_TYPE_UINT, media_type->BitRate,
|
||||||
@ -222,6 +254,7 @@ static BOOL tsmf_gstreamer_set_format(ITSMFDecoder *decoder, TS_AM_MEDIA_TYPE *m
|
|||||||
"format", G_TYPE_STRING, "MP43",
|
"format", G_TYPE_STRING, "MP43",
|
||||||
NULL);
|
NULL);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case TSMF_SUB_TYPE_WMA9:
|
case TSMF_SUB_TYPE_WMA9:
|
||||||
mdecoder->gst_caps = gst_caps_new_simple("audio/x-wma",
|
mdecoder->gst_caps = gst_caps_new_simple("audio/x-wma",
|
||||||
"wmaversion", G_TYPE_INT, 3,
|
"wmaversion", G_TYPE_INT, 3,
|
||||||
@ -233,6 +266,7 @@ static BOOL tsmf_gstreamer_set_format(ITSMFDecoder *decoder, TS_AM_MEDIA_TYPE *m
|
|||||||
"block_align", G_TYPE_INT, media_type->BlockAlign,
|
"block_align", G_TYPE_INT, media_type->BlockAlign,
|
||||||
NULL);
|
NULL);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case TSMF_SUB_TYPE_WMA2:
|
case TSMF_SUB_TYPE_WMA2:
|
||||||
mdecoder->gst_caps = gst_caps_new_simple("audio/x-wma",
|
mdecoder->gst_caps = gst_caps_new_simple("audio/x-wma",
|
||||||
"wmaversion", G_TYPE_INT, 2,
|
"wmaversion", G_TYPE_INT, 2,
|
||||||
@ -244,6 +278,7 @@ static BOOL tsmf_gstreamer_set_format(ITSMFDecoder *decoder, TS_AM_MEDIA_TYPE *m
|
|||||||
"block_align", G_TYPE_INT, media_type->BlockAlign,
|
"block_align", G_TYPE_INT, media_type->BlockAlign,
|
||||||
NULL);
|
NULL);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case TSMF_SUB_TYPE_MP3:
|
case TSMF_SUB_TYPE_MP3:
|
||||||
mdecoder->gst_caps = gst_caps_new_simple("audio/mpeg",
|
mdecoder->gst_caps = gst_caps_new_simple("audio/mpeg",
|
||||||
"mpegversion", G_TYPE_INT, 1,
|
"mpegversion", G_TYPE_INT, 1,
|
||||||
@ -252,6 +287,7 @@ static BOOL tsmf_gstreamer_set_format(ITSMFDecoder *decoder, TS_AM_MEDIA_TYPE *m
|
|||||||
"channels", G_TYPE_INT, media_type->Channels,
|
"channels", G_TYPE_INT, media_type->Channels,
|
||||||
NULL);
|
NULL);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case TSMF_SUB_TYPE_WMV1:
|
case TSMF_SUB_TYPE_WMV1:
|
||||||
mdecoder->gst_caps = gst_caps_new_simple("video/x-wmv",
|
mdecoder->gst_caps = gst_caps_new_simple("video/x-wmv",
|
||||||
"bitrate", G_TYPE_UINT, media_type->BitRate,
|
"bitrate", G_TYPE_UINT, media_type->BitRate,
|
||||||
@ -261,6 +297,7 @@ static BOOL tsmf_gstreamer_set_format(ITSMFDecoder *decoder, TS_AM_MEDIA_TYPE *m
|
|||||||
"format", G_TYPE_STRING, "WMV1",
|
"format", G_TYPE_STRING, "WMV1",
|
||||||
NULL);
|
NULL);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case TSMF_SUB_TYPE_WMV2:
|
case TSMF_SUB_TYPE_WMV2:
|
||||||
mdecoder->gst_caps = gst_caps_new_simple("video/x-wmv",
|
mdecoder->gst_caps = gst_caps_new_simple("video/x-wmv",
|
||||||
"width", G_TYPE_INT, media_type->Width,
|
"width", G_TYPE_INT, media_type->Width,
|
||||||
@ -269,6 +306,7 @@ static BOOL tsmf_gstreamer_set_format(ITSMFDecoder *decoder, TS_AM_MEDIA_TYPE *m
|
|||||||
"format", G_TYPE_STRING, "WMV2",
|
"format", G_TYPE_STRING, "WMV2",
|
||||||
NULL);
|
NULL);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case TSMF_SUB_TYPE_WMV3:
|
case TSMF_SUB_TYPE_WMV3:
|
||||||
mdecoder->gst_caps = gst_caps_new_simple("video/x-wmv",
|
mdecoder->gst_caps = gst_caps_new_simple("video/x-wmv",
|
||||||
"bitrate", G_TYPE_UINT, media_type->BitRate,
|
"bitrate", G_TYPE_UINT, media_type->BitRate,
|
||||||
@ -279,6 +317,7 @@ static BOOL tsmf_gstreamer_set_format(ITSMFDecoder *decoder, TS_AM_MEDIA_TYPE *m
|
|||||||
//"framerate", GST_TYPE_FRACTION, media_type->SamplesPerSecond.Numerator, media_type->SamplesPerSecond.Denominator,
|
//"framerate", GST_TYPE_FRACTION, media_type->SamplesPerSecond.Numerator, media_type->SamplesPerSecond.Denominator,
|
||||||
NULL);
|
NULL);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case TSMF_SUB_TYPE_AVC1:
|
case TSMF_SUB_TYPE_AVC1:
|
||||||
case TSMF_SUB_TYPE_H264:
|
case TSMF_SUB_TYPE_H264:
|
||||||
mdecoder->gst_caps = gst_caps_new_simple("video/x-h264",
|
mdecoder->gst_caps = gst_caps_new_simple("video/x-h264",
|
||||||
@ -287,33 +326,39 @@ static BOOL tsmf_gstreamer_set_format(ITSMFDecoder *decoder, TS_AM_MEDIA_TYPE *m
|
|||||||
//"framerate", GST_TYPE_FRACTION, media_type->SamplesPerSecond.Numerator, media_type->SamplesPerSecond.Denominator,
|
//"framerate", GST_TYPE_FRACTION, media_type->SamplesPerSecond.Numerator, media_type->SamplesPerSecond.Denominator,
|
||||||
NULL);
|
NULL);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case TSMF_SUB_TYPE_AC3:
|
case TSMF_SUB_TYPE_AC3:
|
||||||
mdecoder->gst_caps = gst_caps_new_simple("audio/x-ac3",
|
mdecoder->gst_caps = gst_caps_new_simple("audio/x-ac3",
|
||||||
"rate", G_TYPE_INT, media_type->SamplesPerSecond.Numerator,
|
"rate", G_TYPE_INT, media_type->SamplesPerSecond.Numerator,
|
||||||
"channels", G_TYPE_INT, media_type->Channels,
|
"channels", G_TYPE_INT, media_type->Channels,
|
||||||
NULL);
|
NULL);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case TSMF_SUB_TYPE_AAC:
|
case TSMF_SUB_TYPE_AAC:
|
||||||
|
|
||||||
/* For AAC the pFormat is a HEAACWAVEINFO struct, and the codec data
|
/* For AAC the pFormat is a HEAACWAVEINFO struct, and the codec data
|
||||||
is at the end of it. See
|
is at the end of it. See
|
||||||
http://msdn.microsoft.com/en-us/library/dd757806.aspx */
|
http://msdn.microsoft.com/en-us/library/dd757806.aspx */
|
||||||
if(media_type->ExtraData)
|
if (media_type->ExtraData)
|
||||||
{
|
{
|
||||||
media_type->ExtraData += 12;
|
media_type->ExtraData += 12;
|
||||||
media_type->ExtraDataSize -= 12;
|
media_type->ExtraDataSize -= 12;
|
||||||
}
|
}
|
||||||
|
|
||||||
mdecoder->gst_caps = gst_caps_new_simple("audio/mpeg",
|
mdecoder->gst_caps = gst_caps_new_simple("audio/mpeg",
|
||||||
"rate", G_TYPE_INT, media_type->SamplesPerSecond.Numerator,
|
"rate", G_TYPE_INT, media_type->SamplesPerSecond.Numerator,
|
||||||
"channels", G_TYPE_INT, media_type->Channels,
|
"channels", G_TYPE_INT, media_type->Channels,
|
||||||
"mpegversion", G_TYPE_INT, 4,
|
"mpegversion", G_TYPE_INT, 4,
|
||||||
NULL);
|
NULL);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case TSMF_SUB_TYPE_MP1A:
|
case TSMF_SUB_TYPE_MP1A:
|
||||||
mdecoder->gst_caps = gst_caps_new_simple("audio/mpeg",
|
mdecoder->gst_caps = gst_caps_new_simple("audio/mpeg",
|
||||||
"mpegversion", G_TYPE_INT, 1,
|
"mpegversion", G_TYPE_INT, 1,
|
||||||
"channels", G_TYPE_INT, media_type->Channels,
|
"channels", G_TYPE_INT, media_type->Channels,
|
||||||
NULL);
|
NULL);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case TSMF_SUB_TYPE_MP1V:
|
case TSMF_SUB_TYPE_MP1V:
|
||||||
mdecoder->gst_caps = gst_caps_new_simple("video/mpeg",
|
mdecoder->gst_caps = gst_caps_new_simple("video/mpeg",
|
||||||
"mpegversion", G_TYPE_INT, 1,
|
"mpegversion", G_TYPE_INT, 1,
|
||||||
@ -322,6 +367,7 @@ static BOOL tsmf_gstreamer_set_format(ITSMFDecoder *decoder, TS_AM_MEDIA_TYPE *m
|
|||||||
"systemstream", G_TYPE_BOOLEAN, FALSE,
|
"systemstream", G_TYPE_BOOLEAN, FALSE,
|
||||||
NULL);
|
NULL);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case TSMF_SUB_TYPE_YUY2:
|
case TSMF_SUB_TYPE_YUY2:
|
||||||
mdecoder->gst_caps = gst_caps_new_simple("video/x-raw-yuv",
|
mdecoder->gst_caps = gst_caps_new_simple("video/x-raw-yuv",
|
||||||
"format", G_TYPE_STRING, "YUY2",
|
"format", G_TYPE_STRING, "YUY2",
|
||||||
@ -330,6 +376,7 @@ static BOOL tsmf_gstreamer_set_format(ITSMFDecoder *decoder, TS_AM_MEDIA_TYPE *m
|
|||||||
"height", G_TYPE_INT, media_type->Height,
|
"height", G_TYPE_INT, media_type->Height,
|
||||||
NULL);
|
NULL);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case TSMF_SUB_TYPE_MP2V:
|
case TSMF_SUB_TYPE_MP2V:
|
||||||
mdecoder->gst_caps = gst_caps_new_simple("video/mpeg",
|
mdecoder->gst_caps = gst_caps_new_simple("video/mpeg",
|
||||||
//"bitrate", G_TYPE_UINT, media_type->BitRate,
|
//"bitrate", G_TYPE_UINT, media_type->BitRate,
|
||||||
@ -339,6 +386,7 @@ static BOOL tsmf_gstreamer_set_format(ITSMFDecoder *decoder, TS_AM_MEDIA_TYPE *m
|
|||||||
"systemstream", G_TYPE_BOOLEAN, FALSE,
|
"systemstream", G_TYPE_BOOLEAN, FALSE,
|
||||||
NULL);
|
NULL);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case TSMF_SUB_TYPE_MP2A:
|
case TSMF_SUB_TYPE_MP2A:
|
||||||
mdecoder->gst_caps = gst_caps_new_simple("audio/mpeg",
|
mdecoder->gst_caps = gst_caps_new_simple("audio/mpeg",
|
||||||
"mpegversion", G_TYPE_INT, 2,
|
"mpegversion", G_TYPE_INT, 2,
|
||||||
@ -346,11 +394,13 @@ static BOOL tsmf_gstreamer_set_format(ITSMFDecoder *decoder, TS_AM_MEDIA_TYPE *m
|
|||||||
"channels", G_TYPE_INT, media_type->Channels,
|
"channels", G_TYPE_INT, media_type->Channels,
|
||||||
NULL);
|
NULL);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
DEBUG_WARN("unknown format:(%d).", media_type->SubType);
|
DEBUG_WARN("unknown format:(%d).", media_type->SubType);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
if(media_type->ExtraDataSize > 0)
|
|
||||||
|
if (media_type->ExtraDataSize > 0)
|
||||||
{
|
{
|
||||||
GValue val = G_VALUE_INIT;
|
GValue val = G_VALUE_INIT;
|
||||||
GstBuffer *buffer = tsmf_get_buffer_from_payload(media_type);
|
GstBuffer *buffer = tsmf_get_buffer_from_payload(media_type);
|
||||||
@ -359,18 +409,22 @@ static BOOL tsmf_gstreamer_set_format(ITSMFDecoder *decoder, TS_AM_MEDIA_TYPE *m
|
|||||||
g_value_set_boxed(&val, buffer);
|
g_value_set_boxed(&val, buffer);
|
||||||
gst_caps_set_value(mdecoder->gst_caps, "codec_data", &val);
|
gst_caps_set_value(mdecoder->gst_caps, "codec_data", &val);
|
||||||
}
|
}
|
||||||
|
|
||||||
DEBUG_TSMF("%p format '%s'", mdecoder, gst_caps_to_string(mdecoder->gst_caps));
|
DEBUG_TSMF("%p format '%s'", mdecoder, gst_caps_to_string(mdecoder->gst_caps));
|
||||||
tsmf_platform_set_format(mdecoder);
|
tsmf_platform_set_format(mdecoder);
|
||||||
|
|
||||||
/* Create the pipeline... */
|
/* Create the pipeline... */
|
||||||
if(!tsmf_gstreamer_pipeline_build(mdecoder))
|
if (!tsmf_gstreamer_pipeline_build(mdecoder))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
void tsmf_gstreamer_clean_up_pad(TSMFGstreamerDecoder *mdecoder)
|
void tsmf_gstreamer_clean_up_pad(TSMFGstreamerDecoder *mdecoder)
|
||||||
{
|
{
|
||||||
if(!mdecoder || !mdecoder->pipe)
|
if (!mdecoder || !mdecoder->pipe)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
mdecoder->outconv = NULL;
|
mdecoder->outconv = NULL;
|
||||||
mdecoder->outresample = NULL;
|
mdecoder->outresample = NULL;
|
||||||
mdecoder->outsink = NULL;
|
mdecoder->outsink = NULL;
|
||||||
@ -380,13 +434,15 @@ void tsmf_gstreamer_clean_up_pad(TSMFGstreamerDecoder *mdecoder)
|
|||||||
void tsmf_gstreamer_clean_up(TSMFGstreamerDecoder *mdecoder)
|
void tsmf_gstreamer_clean_up(TSMFGstreamerDecoder *mdecoder)
|
||||||
{
|
{
|
||||||
//Cleaning up elements
|
//Cleaning up elements
|
||||||
if(!mdecoder || !mdecoder->pipe)
|
if (!mdecoder || !mdecoder->pipe)
|
||||||
return;
|
return;
|
||||||
if(mdecoder->pipe && GST_OBJECT_REFCOUNT_VALUE(mdecoder->pipe) > 0)
|
|
||||||
|
if (mdecoder->pipe && GST_OBJECT_REFCOUNT_VALUE(mdecoder->pipe) > 0)
|
||||||
{
|
{
|
||||||
gst_element_set_state(mdecoder->pipe, GST_STATE_NULL);
|
gst_element_set_state(mdecoder->pipe, GST_STATE_NULL);
|
||||||
gst_object_unref(mdecoder->pipe);
|
gst_object_unref(mdecoder->pipe);
|
||||||
}
|
}
|
||||||
|
|
||||||
tsmf_gstreamer_clean_up_pad(mdecoder);
|
tsmf_gstreamer_clean_up_pad(mdecoder);
|
||||||
tsmf_window_destroy(mdecoder);
|
tsmf_window_destroy(mdecoder);
|
||||||
mdecoder->ready = FALSE;
|
mdecoder->ready = FALSE;
|
||||||
@ -406,12 +462,14 @@ cb_newpad(GstElement *decodebin,
|
|||||||
TSMFGstreamerDecoder *mdecoder = data;
|
TSMFGstreamerDecoder *mdecoder = data;
|
||||||
/* only link once */
|
/* only link once */
|
||||||
outpad = gst_element_get_static_pad(mdecoder->outbin, "sink");
|
outpad = gst_element_get_static_pad(mdecoder->outbin, "sink");
|
||||||
if(GST_PAD_IS_LINKED(outpad))
|
|
||||||
|
if (GST_PAD_IS_LINKED(outpad))
|
||||||
{
|
{
|
||||||
DEBUG_WARN("sink already linded!");
|
DEBUG_WARN("sink already linded!");
|
||||||
gst_object_unref(outpad);
|
gst_object_unref(outpad);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* link'n'play */
|
/* link'n'play */
|
||||||
gst_pad_link(pad, outpad);
|
gst_pad_link(pad, outpad);
|
||||||
gst_object_unref(outpad);
|
gst_object_unref(outpad);
|
||||||
@ -425,17 +483,20 @@ cb_freepad(GstElement *decodebin,
|
|||||||
GstPad *outpad;
|
GstPad *outpad;
|
||||||
TSMFGstreamerDecoder *mdecoder = data;
|
TSMFGstreamerDecoder *mdecoder = data;
|
||||||
outpad = gst_element_get_static_pad(mdecoder->outbin, "sink");
|
outpad = gst_element_get_static_pad(mdecoder->outbin, "sink");
|
||||||
if(!outpad)
|
|
||||||
|
if (!outpad)
|
||||||
{
|
{
|
||||||
DEBUG_WARN("sink pad does not exist!");
|
DEBUG_WARN("sink pad does not exist!");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if(!GST_PAD_IS_LINKED(outpad))
|
|
||||||
|
if (!GST_PAD_IS_LINKED(outpad))
|
||||||
{
|
{
|
||||||
DEBUG_WARN("sink not linded!");
|
DEBUG_WARN("sink not linded!");
|
||||||
gst_object_unref(outpad);
|
gst_object_unref(outpad);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* link'n'play */
|
/* link'n'play */
|
||||||
gst_pad_unlink(pad, outpad);
|
gst_pad_unlink(pad, outpad);
|
||||||
gst_object_unref(outpad);
|
gst_object_unref(outpad);
|
||||||
@ -443,7 +504,7 @@ cb_freepad(GstElement *decodebin,
|
|||||||
|
|
||||||
void tsmf_gstreamer_remove_pad(TSMFGstreamerDecoder *mdecoder)
|
void tsmf_gstreamer_remove_pad(TSMFGstreamerDecoder *mdecoder)
|
||||||
{
|
{
|
||||||
if(mdecoder->outbin)
|
if (mdecoder->outbin)
|
||||||
{
|
{
|
||||||
gst_element_remove_pad(mdecoder->outbin, mdecoder->ghost_pad);
|
gst_element_remove_pad(mdecoder->outbin, mdecoder->ghost_pad);
|
||||||
gst_object_unref(mdecoder->ghost_pad);
|
gst_object_unref(mdecoder->ghost_pad);
|
||||||
@ -455,7 +516,8 @@ BOOL tsmf_gstreamer_add_pad(TSMFGstreamerDecoder *mdecoder)
|
|||||||
{
|
{
|
||||||
GstPad *out_pad;
|
GstPad *out_pad;
|
||||||
gboolean linkResult = FALSE;
|
gboolean linkResult = FALSE;
|
||||||
switch(mdecoder->media_type)
|
|
||||||
|
switch (mdecoder->media_type)
|
||||||
{
|
{
|
||||||
case TSMF_MAJOR_TYPE_VIDEO:
|
case TSMF_MAJOR_TYPE_VIDEO:
|
||||||
{
|
{
|
||||||
@ -466,6 +528,7 @@ BOOL tsmf_gstreamer_add_pad(TSMFGstreamerDecoder *mdecoder)
|
|||||||
DEBUG_TSMF("building Video Pipe");
|
DEBUG_TSMF("building Video Pipe");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case TSMF_MAJOR_TYPE_AUDIO:
|
case TSMF_MAJOR_TYPE_AUDIO:
|
||||||
{
|
{
|
||||||
mdecoder->outconv = gst_element_factory_make("audioconvert", "audioconvert");
|
mdecoder->outconv = gst_element_factory_make("audioconvert", "audioconvert");
|
||||||
@ -475,21 +538,27 @@ BOOL tsmf_gstreamer_add_pad(TSMFGstreamerDecoder *mdecoder)
|
|||||||
DEBUG_TSMF("building Audio Pipe");
|
DEBUG_TSMF("building Audio Pipe");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
default:
|
default:
|
||||||
DEBUG_WARN("Invalid media type %08X", mdecoder->media_type);
|
DEBUG_WARN("Invalid media type %08X", mdecoder->media_type);
|
||||||
tsmf_gstreamer_clean_up_pad(mdecoder);
|
tsmf_gstreamer_clean_up_pad(mdecoder);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Add audio / video specific elements to outbin */
|
/* Add audio / video specific elements to outbin */
|
||||||
if(mdecoder->outconv)
|
if (mdecoder->outconv)
|
||||||
gst_bin_add(GST_BIN(mdecoder->outbin), mdecoder->outconv);
|
gst_bin_add(GST_BIN(mdecoder->outbin), mdecoder->outconv);
|
||||||
if(mdecoder->outresample)
|
|
||||||
|
if (mdecoder->outresample)
|
||||||
gst_bin_add(GST_BIN(mdecoder->outbin), mdecoder->outresample);
|
gst_bin_add(GST_BIN(mdecoder->outbin), mdecoder->outresample);
|
||||||
if(mdecoder->volume)
|
|
||||||
|
if (mdecoder->volume)
|
||||||
gst_bin_add(GST_BIN(mdecoder->outbin), mdecoder->volume);
|
gst_bin_add(GST_BIN(mdecoder->outbin), mdecoder->volume);
|
||||||
if(mdecoder->outsink)
|
|
||||||
|
if (mdecoder->outsink)
|
||||||
gst_bin_add(GST_BIN(mdecoder->outbin), mdecoder->outsink);
|
gst_bin_add(GST_BIN(mdecoder->outbin), mdecoder->outsink);
|
||||||
if(!mdecoder->outconv || ! mdecoder->outsink || !mdecoder->outresample)
|
|
||||||
|
if (!mdecoder->outconv || ! mdecoder->outsink || !mdecoder->outresample)
|
||||||
{
|
{
|
||||||
DEBUG_WARN("Failed to load (some) output pipe elements");
|
DEBUG_WARN("Failed to load (some) output pipe elements");
|
||||||
DEBUG_WARN("converter=%p, sink=%p, resample=%p",
|
DEBUG_WARN("converter=%p, sink=%p, resample=%p",
|
||||||
@ -497,9 +566,10 @@ BOOL tsmf_gstreamer_add_pad(TSMFGstreamerDecoder *mdecoder)
|
|||||||
tsmf_gstreamer_clean_up_pad(mdecoder);
|
tsmf_gstreamer_clean_up_pad(mdecoder);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
if(mdecoder->media_type == TSMF_MAJOR_TYPE_AUDIO)
|
|
||||||
|
if (mdecoder->media_type == TSMF_MAJOR_TYPE_AUDIO)
|
||||||
{
|
{
|
||||||
if(!mdecoder->volume)
|
if (!mdecoder->volume)
|
||||||
{
|
{
|
||||||
DEBUG_WARN("Failed to load (some) audio output pipe elements");
|
DEBUG_WARN("Failed to load (some) audio output pipe elements");
|
||||||
DEBUG_WARN("volume=%p", mdecoder->volume);
|
DEBUG_WARN("volume=%p", mdecoder->volume);
|
||||||
@ -507,8 +577,10 @@ BOOL tsmf_gstreamer_add_pad(TSMFGstreamerDecoder *mdecoder)
|
|||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
out_pad = gst_element_get_static_pad(mdecoder->outconv, "sink");
|
out_pad = gst_element_get_static_pad(mdecoder->outconv, "sink");
|
||||||
if(mdecoder->media_type == TSMF_MAJOR_TYPE_AUDIO)
|
|
||||||
|
if (mdecoder->media_type == TSMF_MAJOR_TYPE_AUDIO)
|
||||||
{
|
{
|
||||||
g_object_set(mdecoder->volume, "mute", mdecoder->gstMuted, NULL);
|
g_object_set(mdecoder->volume, "mute", mdecoder->gstMuted, NULL);
|
||||||
g_object_set(mdecoder->volume, "volume", mdecoder->gstVolume, NULL);
|
g_object_set(mdecoder->volume, "volume", mdecoder->gstVolume, NULL);
|
||||||
@ -520,12 +592,14 @@ BOOL tsmf_gstreamer_add_pad(TSMFGstreamerDecoder *mdecoder)
|
|||||||
linkResult = gst_element_link_many(mdecoder->outconv,
|
linkResult = gst_element_link_many(mdecoder->outconv,
|
||||||
mdecoder->outresample, mdecoder->outsink, NULL);
|
mdecoder->outresample, mdecoder->outsink, NULL);
|
||||||
}
|
}
|
||||||
if(!linkResult)
|
|
||||||
|
if (!linkResult)
|
||||||
{
|
{
|
||||||
DEBUG_WARN("Failed to link these elements: converter->sink");
|
DEBUG_WARN("Failed to link these elements: converter->sink");
|
||||||
tsmf_gstreamer_clean_up_pad(mdecoder);
|
tsmf_gstreamer_clean_up_pad(mdecoder);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
mdecoder->ghost_pad = gst_ghost_pad_new("sink", out_pad);
|
mdecoder->ghost_pad = gst_ghost_pad_new("sink", out_pad);
|
||||||
gst_element_add_pad(mdecoder->outbin, mdecoder->ghost_pad);
|
gst_element_add_pad(mdecoder->outbin, mdecoder->ghost_pad);
|
||||||
gst_object_unref(out_pad);
|
gst_object_unref(out_pad);
|
||||||
@ -535,31 +609,40 @@ BOOL tsmf_gstreamer_add_pad(TSMFGstreamerDecoder *mdecoder)
|
|||||||
BOOL tsmf_gstreamer_pipeline_build(TSMFGstreamerDecoder *mdecoder)
|
BOOL tsmf_gstreamer_pipeline_build(TSMFGstreamerDecoder *mdecoder)
|
||||||
{
|
{
|
||||||
gboolean linkResult;
|
gboolean linkResult;
|
||||||
if(!mdecoder)
|
|
||||||
|
if (!mdecoder)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
mdecoder->pipe = gst_pipeline_new("pipeline");
|
mdecoder->pipe = gst_pipeline_new("pipeline");
|
||||||
if(!mdecoder->pipe)
|
|
||||||
|
if (!mdecoder->pipe)
|
||||||
{
|
{
|
||||||
DEBUG_WARN("Failed to create new pipe");
|
DEBUG_WARN("Failed to create new pipe");
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
tsmf_platform_register_handler(mdecoder);
|
tsmf_platform_register_handler(mdecoder);
|
||||||
mdecoder->src = gst_element_factory_make("appsrc", "source");
|
mdecoder->src = gst_element_factory_make("appsrc", "source");
|
||||||
mdecoder->queue = gst_element_factory_make("queue2", "queue");
|
mdecoder->queue = gst_element_factory_make("queue2", "queue");
|
||||||
mdecoder->decbin = gst_element_factory_make("decodebin", "decoder");
|
mdecoder->decbin = gst_element_factory_make("decodebin", "decoder");
|
||||||
mdecoder->outbin = gst_bin_new("outbin");
|
mdecoder->outbin = gst_bin_new("outbin");
|
||||||
|
|
||||||
/* Add all elements to the bin allowing proper resource cleanup,
|
/* Add all elements to the bin allowing proper resource cleanup,
|
||||||
* if any step failed. */
|
* if any step failed. */
|
||||||
if(mdecoder->src)
|
if (mdecoder->src)
|
||||||
gst_bin_add(GST_BIN(mdecoder->pipe), mdecoder->src);
|
gst_bin_add(GST_BIN(mdecoder->pipe), mdecoder->src);
|
||||||
if(mdecoder->queue)
|
|
||||||
|
if (mdecoder->queue)
|
||||||
gst_bin_add(GST_BIN(mdecoder->pipe), mdecoder->queue);
|
gst_bin_add(GST_BIN(mdecoder->pipe), mdecoder->queue);
|
||||||
if(mdecoder->decbin)
|
|
||||||
|
if (mdecoder->decbin)
|
||||||
gst_bin_add(GST_BIN(mdecoder->pipe), mdecoder->decbin);
|
gst_bin_add(GST_BIN(mdecoder->pipe), mdecoder->decbin);
|
||||||
if(mdecoder->outbin)
|
|
||||||
|
if (mdecoder->outbin)
|
||||||
gst_bin_add(GST_BIN(mdecoder->pipe), mdecoder->outbin);
|
gst_bin_add(GST_BIN(mdecoder->pipe), mdecoder->outbin);
|
||||||
|
|
||||||
/* Check, if everything was loaded correctly. */
|
/* Check, if everything was loaded correctly. */
|
||||||
if(!mdecoder->src || !mdecoder->queue || !mdecoder->decbin ||
|
if (!mdecoder->src || !mdecoder->queue || !mdecoder->decbin ||
|
||||||
!mdecoder->outbin)
|
!mdecoder->outbin)
|
||||||
{
|
{
|
||||||
DEBUG_WARN("Failed to load (some) pipeline stage");
|
DEBUG_WARN("Failed to load (some) pipeline stage");
|
||||||
@ -568,6 +651,7 @@ BOOL tsmf_gstreamer_pipeline_build(TSMFGstreamerDecoder *mdecoder)
|
|||||||
tsmf_gstreamer_clean_up(mdecoder);
|
tsmf_gstreamer_clean_up(mdecoder);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
gst_pipeline_set_delay((GstPipeline *)mdecoder->pipe, 5000);
|
gst_pipeline_set_delay((GstPipeline *)mdecoder->pipe, 5000);
|
||||||
/* AppSrc settings */
|
/* AppSrc settings */
|
||||||
GstAppSrcCallbacks callbacks =
|
GstAppSrcCallbacks callbacks =
|
||||||
@ -593,12 +677,14 @@ BOOL tsmf_gstreamer_pipeline_build(TSMFGstreamerDecoder *mdecoder)
|
|||||||
// g_object_set(mdecoder->outsink, "async-handling", TRUE, NULL);
|
// g_object_set(mdecoder->outsink, "async-handling", TRUE, NULL);
|
||||||
linkResult = gst_element_link_many(mdecoder->src, mdecoder->queue,
|
linkResult = gst_element_link_many(mdecoder->src, mdecoder->queue,
|
||||||
mdecoder->decbin, NULL);
|
mdecoder->decbin, NULL);
|
||||||
if(!linkResult)
|
|
||||||
|
if (!linkResult)
|
||||||
{
|
{
|
||||||
DEBUG_WARN("Failed to link elements.");
|
DEBUG_WARN("Failed to link elements.");
|
||||||
tsmf_gstreamer_clean_up(mdecoder);
|
tsmf_gstreamer_clean_up(mdecoder);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
tsmf_gstreamer_add_pad(mdecoder);
|
tsmf_gstreamer_add_pad(mdecoder);
|
||||||
tsmf_window_create(mdecoder);
|
tsmf_window_create(mdecoder);
|
||||||
tsmf_gstreamer_pipeline_set_state(mdecoder, GST_STATE_READY);
|
tsmf_gstreamer_pipeline_set_state(mdecoder, GST_STATE_READY);
|
||||||
@ -615,11 +701,13 @@ static BOOL tsmf_gstreamer_decodeEx(ITSMFDecoder *decoder, const BYTE *data, UIN
|
|||||||
TSMFGstreamerDecoder *mdecoder = (TSMFGstreamerDecoder *) decoder;
|
TSMFGstreamerDecoder *mdecoder = (TSMFGstreamerDecoder *) decoder;
|
||||||
UINT64 sample_time = tsmf_gstreamer_timestamp_ms_to_gst(start_time);
|
UINT64 sample_time = tsmf_gstreamer_timestamp_ms_to_gst(start_time);
|
||||||
UINT64 sample_duration = tsmf_gstreamer_timestamp_ms_to_gst(duration);
|
UINT64 sample_duration = tsmf_gstreamer_timestamp_ms_to_gst(duration);
|
||||||
if(!mdecoder)
|
|
||||||
|
if (!mdecoder)
|
||||||
{
|
{
|
||||||
DEBUG_WARN("Decoder not initialized!");
|
DEBUG_WARN("Decoder not initialized!");
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* This function is always called from a stream-specific thread.
|
* This function is always called from a stream-specific thread.
|
||||||
* It should be alright to block here if necessary.
|
* It should be alright to block here if necessary.
|
||||||
@ -629,39 +717,48 @@ static BOOL tsmf_gstreamer_decodeEx(ITSMFDecoder *decoder, const BYTE *data, UIN
|
|||||||
DEBUG_TSMF("%s. Start:(%llu) End:(%llu) Duration:(%llu) Last End:(%llu)",
|
DEBUG_TSMF("%s. Start:(%llu) End:(%llu) Duration:(%llu) Last End:(%llu)",
|
||||||
get_type(mdecoder), start_time, end_time, duration,
|
get_type(mdecoder), start_time, end_time, duration,
|
||||||
mdecoder->last_sample_end_time);
|
mdecoder->last_sample_end_time);
|
||||||
if(mdecoder->gst_caps == NULL)
|
|
||||||
|
if (mdecoder->gst_caps == NULL)
|
||||||
{
|
{
|
||||||
DEBUG_WARN("tsmf_gstreamer_set_format not called or invalid format.");
|
DEBUG_WARN("tsmf_gstreamer_set_format not called or invalid format.");
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
if(!mdecoder->src)
|
|
||||||
|
if (!mdecoder->src)
|
||||||
{
|
{
|
||||||
DEBUG_WARN("failed to construct pipeline correctly. Unable to push buffer to source element.");
|
DEBUG_WARN("failed to construct pipeline correctly. Unable to push buffer to source element.");
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
gst_buf = tsmf_get_buffer_from_data(data, data_size);
|
gst_buf = tsmf_get_buffer_from_data(data, data_size);
|
||||||
if(gst_buf == NULL)
|
|
||||||
|
if (gst_buf == NULL)
|
||||||
{
|
{
|
||||||
DEBUG_WARN("tsmf_get_buffer_from_data(%p, %d) failed.", data, data_size);
|
DEBUG_WARN("tsmf_get_buffer_from_data(%p, %d) failed.", data, data_size);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
if(mdecoder->pipeline_start_time_valid)
|
|
||||||
|
if (mdecoder->pipeline_start_time_valid)
|
||||||
{
|
{
|
||||||
long long diff = start_time;
|
long long diff = start_time;
|
||||||
diff -= mdecoder->last_sample_end_time;
|
diff -= mdecoder->last_sample_end_time;
|
||||||
if(diff < 0)
|
|
||||||
|
if (diff < 0)
|
||||||
diff *= -1;
|
diff *= -1;
|
||||||
|
|
||||||
/* The pipe is initialized, but there is a discontinuity.
|
/* The pipe is initialized, but there is a discontinuity.
|
||||||
* Seek to the start position... */
|
* Seek to the start position... */
|
||||||
if(diff > 50)
|
if (diff > 50)
|
||||||
{
|
{
|
||||||
DEBUG_TSMF("%s seeking to %lld", get_type(mdecoder), start_time);
|
DEBUG_TSMF("%s seeking to %lld", get_type(mdecoder), start_time);
|
||||||
if(!gst_element_seek(mdecoder->pipe, 1.0, GST_FORMAT_TIME, GST_SEEK_FLAG_FLUSH | GST_SEEK_FLAG_ACCURATE,
|
|
||||||
GST_SEEK_TYPE_SET, sample_time,
|
if (!gst_element_seek(mdecoder->pipe, 1.0, GST_FORMAT_TIME, GST_SEEK_FLAG_FLUSH | GST_SEEK_FLAG_ACCURATE,
|
||||||
GST_SEEK_TYPE_NONE, GST_CLOCK_TIME_NONE))
|
GST_SEEK_TYPE_SET, sample_time,
|
||||||
|
GST_SEEK_TYPE_NONE, GST_CLOCK_TIME_NONE))
|
||||||
{
|
{
|
||||||
DEBUG_WARN("seek failed");
|
DEBUG_WARN("seek failed");
|
||||||
}
|
}
|
||||||
|
|
||||||
mdecoder->pipeline_start_time_valid = 0;
|
mdecoder->pipeline_start_time_valid = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -670,36 +767,48 @@ static BOOL tsmf_gstreamer_decodeEx(ITSMFDecoder *decoder, const BYTE *data, UIN
|
|||||||
DEBUG_TSMF("%s start time %llu", get_type(mdecoder), sample_time);
|
DEBUG_TSMF("%s start time %llu", get_type(mdecoder), sample_time);
|
||||||
mdecoder->pipeline_start_time_valid = 1;
|
mdecoder->pipeline_start_time_valid = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
GST_BUFFER_PTS(gst_buf) = sample_time;
|
GST_BUFFER_PTS(gst_buf) = sample_time;
|
||||||
GST_BUFFER_DURATION(gst_buf) = sample_duration;
|
GST_BUFFER_DURATION(gst_buf) = sample_duration;
|
||||||
gst_app_src_push_buffer(GST_APP_SRC(mdecoder->src), gst_buf);
|
gst_app_src_push_buffer(GST_APP_SRC(mdecoder->src), gst_buf);
|
||||||
if(mdecoder->ack_cb)
|
|
||||||
|
if (mdecoder->ack_cb)
|
||||||
mdecoder->ack_cb(mdecoder->stream, TRUE);
|
mdecoder->ack_cb(mdecoder->stream, TRUE);
|
||||||
|
|
||||||
mdecoder->last_sample_end_time = end_time;
|
mdecoder->last_sample_end_time = end_time;
|
||||||
if(GST_STATE(mdecoder->pipe) != GST_STATE_PLAYING)
|
|
||||||
|
if (GST_STATE(mdecoder->pipe) != GST_STATE_PLAYING)
|
||||||
{
|
{
|
||||||
DEBUG_TSMF("state=%s", tsmf_gstreamer_state_name(GST_STATE(mdecoder->pipe)));
|
DEBUG_TSMF("state=%s", tsmf_gstreamer_state_name(GST_STATE(mdecoder->pipe)));
|
||||||
if(!mdecoder->paused && !mdecoder->shutdown && mdecoder->ready)
|
|
||||||
|
if (!mdecoder->paused && !mdecoder->shutdown && mdecoder->ready)
|
||||||
tsmf_gstreamer_pipeline_set_state(mdecoder, GST_STATE_PLAYING);
|
tsmf_gstreamer_pipeline_set_state(mdecoder, GST_STATE_PLAYING);
|
||||||
}
|
}
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void tsmf_gstreamer_change_volume(ITSMFDecoder *decoder, UINT32 newVolume, UINT32 muted)
|
static void tsmf_gstreamer_change_volume(ITSMFDecoder *decoder, UINT32 newVolume, UINT32 muted)
|
||||||
{
|
{
|
||||||
TSMFGstreamerDecoder *mdecoder = (TSMFGstreamerDecoder *) decoder;
|
TSMFGstreamerDecoder *mdecoder = (TSMFGstreamerDecoder *) decoder;
|
||||||
if(!mdecoder || !mdecoder->pipe)
|
|
||||||
|
if (!mdecoder || !mdecoder->pipe)
|
||||||
return;
|
return;
|
||||||
if(mdecoder->media_type == TSMF_MAJOR_TYPE_VIDEO)
|
|
||||||
|
if (mdecoder->media_type == TSMF_MAJOR_TYPE_VIDEO)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
mdecoder->gstMuted = (BOOL) muted;
|
mdecoder->gstMuted = (BOOL) muted;
|
||||||
DEBUG_TSMF("mute=[%d]", mdecoder->gstMuted);
|
DEBUG_TSMF("mute=[%d]", mdecoder->gstMuted);
|
||||||
mdecoder->gstVolume = (double) newVolume / (double) 10000;
|
mdecoder->gstVolume = (double) newVolume / (double) 10000;
|
||||||
DEBUG_TSMF("gst_new_vol=[%f]", mdecoder->gstVolume);
|
DEBUG_TSMF("gst_new_vol=[%f]", mdecoder->gstVolume);
|
||||||
if(!mdecoder->volume)
|
|
||||||
|
if (!mdecoder->volume)
|
||||||
return;
|
return;
|
||||||
if(!G_IS_OBJECT(mdecoder->volume))
|
|
||||||
|
if (!G_IS_OBJECT(mdecoder->volume))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
g_object_set(mdecoder->volume, "mute", mdecoder->gstMuted, NULL);
|
g_object_set(mdecoder->volume, "mute", mdecoder->gstMuted, NULL);
|
||||||
g_object_set(mdecoder->volume, "volume", mdecoder->gstVolume, NULL);
|
g_object_set(mdecoder->volume, "volume", mdecoder->gstVolume, NULL);
|
||||||
}
|
}
|
||||||
@ -707,65 +816,78 @@ static void tsmf_gstreamer_change_volume(ITSMFDecoder *decoder, UINT32 newVolume
|
|||||||
static void tsmf_gstreamer_control(ITSMFDecoder *decoder, ITSMFControlMsg control_msg, UINT32 *arg)
|
static void tsmf_gstreamer_control(ITSMFDecoder *decoder, ITSMFControlMsg control_msg, UINT32 *arg)
|
||||||
{
|
{
|
||||||
TSMFGstreamerDecoder *mdecoder = (TSMFGstreamerDecoder *) decoder;
|
TSMFGstreamerDecoder *mdecoder = (TSMFGstreamerDecoder *) decoder;
|
||||||
if(!mdecoder)
|
|
||||||
|
if (!mdecoder)
|
||||||
return;
|
return;
|
||||||
if(control_msg == Control_Pause)
|
|
||||||
|
if (control_msg == Control_Pause)
|
||||||
{
|
{
|
||||||
DEBUG_TSMF("Control_Pause %s", get_type(mdecoder));
|
DEBUG_TSMF("Control_Pause %s", get_type(mdecoder));
|
||||||
if(mdecoder->paused)
|
|
||||||
|
if (mdecoder->paused)
|
||||||
{
|
{
|
||||||
DEBUG_WARN("%s: Ignoring control PAUSE, already received!", get_type(mdecoder));
|
DEBUG_WARN("%s: Ignoring control PAUSE, already received!", get_type(mdecoder));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
tsmf_gstreamer_pipeline_set_state(mdecoder, GST_STATE_PAUSED);
|
tsmf_gstreamer_pipeline_set_state(mdecoder, GST_STATE_PAUSED);
|
||||||
mdecoder->paused = TRUE;
|
mdecoder->paused = TRUE;
|
||||||
if(mdecoder->media_type == TSMF_MAJOR_TYPE_VIDEO)
|
|
||||||
|
if (mdecoder->media_type == TSMF_MAJOR_TYPE_VIDEO)
|
||||||
tsmf_window_pause(mdecoder);
|
tsmf_window_pause(mdecoder);
|
||||||
}
|
}
|
||||||
else
|
else if (control_msg == Control_Resume)
|
||||||
if(control_msg == Control_Resume)
|
{
|
||||||
{
|
DEBUG_TSMF("Control_Resume %s", get_type(mdecoder));
|
||||||
DEBUG_TSMF("Control_Resume %s", get_type(mdecoder));
|
|
||||||
if(!mdecoder->paused && !mdecoder->shutdown)
|
|
||||||
{
|
|
||||||
DEBUG_WARN("%s: Ignoring control RESUME, already received!", get_type(mdecoder));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
mdecoder->paused = FALSE;
|
if (!mdecoder->paused && !mdecoder->shutdown)
|
||||||
mdecoder->shutdown = FALSE;
|
{
|
||||||
if(mdecoder->media_type == TSMF_MAJOR_TYPE_VIDEO)
|
DEBUG_WARN("%s: Ignoring control RESUME, already received!", get_type(mdecoder));
|
||||||
tsmf_window_resume(mdecoder);
|
return;
|
||||||
tsmf_gstreamer_pipeline_set_state(mdecoder, GST_STATE_PLAYING);
|
|
||||||
}
|
}
|
||||||
else
|
|
||||||
if(control_msg == Control_Stop)
|
mdecoder->paused = FALSE;
|
||||||
{
|
mdecoder->shutdown = FALSE;
|
||||||
DEBUG_WARN("Control_Stop %s", get_type(mdecoder));
|
|
||||||
if(mdecoder->shutdown)
|
if (mdecoder->media_type == TSMF_MAJOR_TYPE_VIDEO)
|
||||||
{
|
tsmf_window_resume(mdecoder);
|
||||||
DEBUG_WARN("%s: Ignoring control STOP, already received!", get_type(mdecoder));
|
|
||||||
return;
|
tsmf_gstreamer_pipeline_set_state(mdecoder, GST_STATE_PLAYING);
|
||||||
}
|
}
|
||||||
mdecoder->shutdown = TRUE;
|
else if (control_msg == Control_Stop)
|
||||||
/* Reset stamps, flush buffers, etc */
|
{
|
||||||
tsmf_gstreamer_pipeline_set_state(mdecoder, GST_STATE_PAUSED);
|
DEBUG_WARN("Control_Stop %s", get_type(mdecoder));
|
||||||
if(mdecoder->media_type == TSMF_MAJOR_TYPE_VIDEO)
|
|
||||||
tsmf_window_pause(mdecoder);
|
if (mdecoder->shutdown)
|
||||||
gst_app_src_end_of_stream((GstAppSrc *)mdecoder->src);
|
{
|
||||||
}
|
DEBUG_WARN("%s: Ignoring control STOP, already received!", get_type(mdecoder));
|
||||||
else
|
return;
|
||||||
DEBUG_WARN("Unknown control message %08x", control_msg);
|
}
|
||||||
|
|
||||||
|
mdecoder->shutdown = TRUE;
|
||||||
|
/* Reset stamps, flush buffers, etc */
|
||||||
|
tsmf_gstreamer_pipeline_set_state(mdecoder, GST_STATE_PAUSED);
|
||||||
|
|
||||||
|
if (mdecoder->media_type == TSMF_MAJOR_TYPE_VIDEO)
|
||||||
|
tsmf_window_pause(mdecoder);
|
||||||
|
|
||||||
|
gst_app_src_end_of_stream((GstAppSrc *)mdecoder->src);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
DEBUG_WARN("Unknown control message %08x", control_msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
static BOOL tsmf_gstreamer_buffer_filled(ITSMFDecoder *decoder)
|
static BOOL tsmf_gstreamer_buffer_filled(ITSMFDecoder *decoder)
|
||||||
{
|
{
|
||||||
TSMFGstreamerDecoder *mdecoder = (TSMFGstreamerDecoder *) decoder;
|
TSMFGstreamerDecoder *mdecoder = (TSMFGstreamerDecoder *) decoder;
|
||||||
DEBUG_TSMF("");
|
DEBUG_TSMF("");
|
||||||
if(!mdecoder)
|
|
||||||
|
if (!mdecoder)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
if(!G_IS_OBJECT(mdecoder->queue))
|
|
||||||
|
if (!G_IS_OBJECT(mdecoder->queue))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
guint buff_max = 0;
|
guint buff_max = 0;
|
||||||
g_object_get(mdecoder->queue, "max-size-buffers", &buff_max, NULL);
|
g_object_get(mdecoder->queue, "max-size-buffers", &buff_max, NULL);
|
||||||
guint clbuff = 0;
|
guint clbuff = 0;
|
||||||
@ -778,12 +900,15 @@ static void tsmf_gstreamer_free(ITSMFDecoder *decoder)
|
|||||||
{
|
{
|
||||||
TSMFGstreamerDecoder *mdecoder = (TSMFGstreamerDecoder *) decoder;
|
TSMFGstreamerDecoder *mdecoder = (TSMFGstreamerDecoder *) decoder;
|
||||||
DEBUG_WARN("%s", get_type(mdecoder));
|
DEBUG_WARN("%s", get_type(mdecoder));
|
||||||
if(mdecoder)
|
|
||||||
|
if (mdecoder)
|
||||||
{
|
{
|
||||||
mdecoder->shutdown = 1;
|
mdecoder->shutdown = 1;
|
||||||
tsmf_gstreamer_clean_up(mdecoder);
|
tsmf_gstreamer_clean_up(mdecoder);
|
||||||
if(mdecoder->gst_caps)
|
|
||||||
|
if (mdecoder->gst_caps)
|
||||||
gst_caps_unref(mdecoder->gst_caps);
|
gst_caps_unref(mdecoder->gst_caps);
|
||||||
|
|
||||||
tsmf_platform_free(mdecoder);
|
tsmf_platform_free(mdecoder);
|
||||||
memset(mdecoder, 0, sizeof(TSMFGstreamerDecoder));
|
memset(mdecoder, 0, sizeof(TSMFGstreamerDecoder));
|
||||||
free(mdecoder);
|
free(mdecoder);
|
||||||
@ -794,12 +919,16 @@ static void tsmf_gstreamer_free(ITSMFDecoder *decoder)
|
|||||||
static UINT64 tsmf_gstreamer_get_running_time(ITSMFDecoder *decoder)
|
static UINT64 tsmf_gstreamer_get_running_time(ITSMFDecoder *decoder)
|
||||||
{
|
{
|
||||||
TSMFGstreamerDecoder *mdecoder = (TSMFGstreamerDecoder *) decoder;
|
TSMFGstreamerDecoder *mdecoder = (TSMFGstreamerDecoder *) decoder;
|
||||||
if(!mdecoder)
|
|
||||||
|
if (!mdecoder)
|
||||||
return 0;
|
return 0;
|
||||||
if(!mdecoder->outsink)
|
|
||||||
|
if (!mdecoder->outsink)
|
||||||
return mdecoder->last_sample_end_time;
|
return mdecoder->last_sample_end_time;
|
||||||
if(GST_STATE(mdecoder->pipe) != GST_STATE_PLAYING)
|
|
||||||
|
if (GST_STATE(mdecoder->pipe) != GST_STATE_PLAYING)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
GstFormat fmt = GST_FORMAT_TIME;
|
GstFormat fmt = GST_FORMAT_TIME;
|
||||||
gint64 pos = 0;
|
gint64 pos = 0;
|
||||||
gst_element_query_position(mdecoder->outsink, fmt, &pos);
|
gst_element_query_position(mdecoder->outsink, fmt, &pos);
|
||||||
@ -813,7 +942,8 @@ static void tsmf_gstreamer_update_rendering_area(ITSMFDecoder *decoder,
|
|||||||
TSMFGstreamerDecoder *mdecoder = (TSMFGstreamerDecoder *) decoder;
|
TSMFGstreamerDecoder *mdecoder = (TSMFGstreamerDecoder *) decoder;
|
||||||
DEBUG_TSMF("x=%d, y=%d, w=%d, h=%d, rect=%d", newX, newY, newWidth,
|
DEBUG_TSMF("x=%d, y=%d, w=%d, h=%d, rect=%d", newX, newY, newWidth,
|
||||||
newHeight, numRectangles);
|
newHeight, numRectangles);
|
||||||
if(mdecoder->media_type == TSMF_MAJOR_TYPE_VIDEO)
|
|
||||||
|
if (mdecoder->media_type == TSMF_MAJOR_TYPE_VIDEO)
|
||||||
tsmf_window_resize(mdecoder, newX, newY, newWidth, newHeight,
|
tsmf_window_resize(mdecoder, newX, newY, newWidth, newHeight,
|
||||||
numRectangles, rectangles);
|
numRectangles, rectangles);
|
||||||
}
|
}
|
||||||
@ -843,10 +973,12 @@ BOOL tsmf_gstreamer_sync(ITSMFDecoder *decoder, void (*cb)(void *), void *stream
|
|||||||
ITSMFDecoder *freerdp_tsmf_client_decoder_subsystem_entry(void)
|
ITSMFDecoder *freerdp_tsmf_client_decoder_subsystem_entry(void)
|
||||||
{
|
{
|
||||||
TSMFGstreamerDecoder *decoder;
|
TSMFGstreamerDecoder *decoder;
|
||||||
if(!gst_is_initialized())
|
|
||||||
|
if (!gst_is_initialized())
|
||||||
{
|
{
|
||||||
gst_init(NULL, NULL);
|
gst_init(NULL, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
decoder = malloc(sizeof(TSMFGstreamerDecoder));
|
decoder = malloc(sizeof(TSMFGstreamerDecoder));
|
||||||
memset(decoder, 0, sizeof(TSMFGstreamerDecoder));
|
memset(decoder, 0, sizeof(TSMFGstreamerDecoder));
|
||||||
decoder->iface.SetFormat = tsmf_gstreamer_set_format;
|
decoder->iface.SetFormat = tsmf_gstreamer_set_format;
|
||||||
|
Loading…
Reference in New Issue
Block a user