2012-06-13 23:45:58 +04:00
|
|
|
/*
|
2012-10-09 07:02:04 +04:00
|
|
|
* FreeRDP: A Remote Desktop Protocol Implementation
|
2012-06-13 23:45:58 +04:00
|
|
|
* Video Redirection Virtual Channel - GStreamer Decoder
|
|
|
|
*
|
2014-05-23 15:46:37 +04:00
|
|
|
* (C) Copyright 2012 HP Development Company, LLC
|
|
|
|
* (C) Copyright 2014 Thincast Technologies GmbH
|
|
|
|
* (C) Copyright 2014 Armin Novak <armin.novak@thincast.com>
|
|
|
|
*
|
2012-06-13 23:45:58 +04:00
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
|
* You may obtain a copy of the License at
|
|
|
|
*
|
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
*
|
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
* See the License for the specific language governing permissions and
|
|
|
|
* limitations under the License.
|
|
|
|
*/
|
|
|
|
|
2012-08-15 01:09:01 +04:00
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
#include "config.h"
|
|
|
|
#endif
|
|
|
|
|
2014-05-23 15:46:37 +04:00
|
|
|
#include <assert.h>
|
2012-10-09 22:26:07 +04:00
|
|
|
|
2012-06-13 23:45:58 +04:00
|
|
|
#include <fcntl.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <unistd.h>
|
2012-10-09 22:26:07 +04:00
|
|
|
|
2012-06-13 23:45:58 +04:00
|
|
|
#include <gst/gst.h>
|
|
|
|
#include <gst/app/gstappsrc.h>
|
|
|
|
#include <gst/app/gstappsink.h>
|
|
|
|
|
|
|
|
#include "tsmf_constants.h"
|
|
|
|
#include "tsmf_decoder.h"
|
2014-05-23 15:46:37 +04:00
|
|
|
#include "tsmf_platform.h"
|
2012-06-13 23:45:58 +04:00
|
|
|
|
2012-10-09 22:52:07 +04:00
|
|
|
#ifdef HAVE_INTTYPES_H
|
|
|
|
#include <inttypes.h>
|
|
|
|
#endif
|
|
|
|
|
2014-05-23 15:46:37 +04:00
|
|
|
static BOOL tsmf_gstreamer_pipeline_build(TSMFGstreamerDecoder *mdecoder);
|
|
|
|
static void tsmf_gstreamer_clean_up(TSMFGstreamerDecoder *mdecoder);
|
|
|
|
static void tsmf_gstreamer_clean_up_pad(TSMFGstreamerDecoder *mdecoder);
|
|
|
|
static int tsmf_gstreamer_pipeline_set_state(TSMFGstreamerDecoder *mdecoder,
|
|
|
|
GstState desired_state);
|
2012-06-13 23:45:58 +04:00
|
|
|
|
2014-05-23 15:46:37 +04:00
|
|
|
const char *get_type(TSMFGstreamerDecoder *mdecoder)
|
|
|
|
{
|
|
|
|
assert(mdecoder);
|
2014-05-23 17:35:25 +04:00
|
|
|
|
|
|
|
if (mdecoder->media_type == TSMF_MAJOR_TYPE_VIDEO)
|
2014-05-23 15:46:37 +04:00
|
|
|
return "VIDEO";
|
|
|
|
else
|
|
|
|
return "AUDIO";
|
|
|
|
}
|
2012-06-13 23:45:58 +04:00
|
|
|
|
2014-05-23 15:46:37 +04:00
|
|
|
static void tsmf_gstreamer_enough_data(GstAppSrc *src, gpointer user_data)
|
|
|
|
{
|
|
|
|
TSMFGstreamerDecoder *mdecoder = user_data;
|
|
|
|
(void)mdecoder;
|
|
|
|
DEBUG_TSMF("%s", get_type(mdecoder));
|
|
|
|
}
|
2012-06-13 23:45:58 +04:00
|
|
|
|
2014-05-23 15:46:37 +04:00
|
|
|
static void tsmf_gstreamer_need_data(GstAppSrc *src, guint length, gpointer user_data)
|
|
|
|
{
|
|
|
|
TSMFGstreamerDecoder *mdecoder = user_data;
|
|
|
|
(void)mdecoder;
|
|
|
|
DEBUG_TSMF("%s length=%lu", get_type(mdecoder), length);
|
|
|
|
}
|
2012-06-13 23:45:58 +04:00
|
|
|
|
2014-05-23 15:46:37 +04:00
|
|
|
static gboolean tsmf_gstreamer_seek_data(GstAppSrc *src, guint64 offset, gpointer user_data)
|
|
|
|
{
|
|
|
|
TSMFGstreamerDecoder *mdecoder = user_data;
|
|
|
|
(void)mdecoder;
|
|
|
|
DEBUG_TSMF("%s offset=%llu", get_type(mdecoder), offset);
|
2014-05-23 17:35:25 +04:00
|
|
|
|
|
|
|
if (!mdecoder->paused)
|
2014-05-23 15:46:37 +04:00
|
|
|
gst_element_set_state(mdecoder->pipe, GST_STATE_PAUSED);
|
2014-05-23 17:35:25 +04:00
|
|
|
|
2014-05-23 15:46:37 +04:00
|
|
|
gst_app_src_end_of_stream((GstAppSrc *)mdecoder->src);
|
2014-05-23 17:35:25 +04:00
|
|
|
|
|
|
|
if (!mdecoder->paused)
|
2014-05-23 15:46:37 +04:00
|
|
|
gst_element_set_state(mdecoder->pipe, GST_STATE_PLAYING);
|
2014-05-23 17:35:25 +04:00
|
|
|
|
|
|
|
if (mdecoder->sync_cb)
|
2014-05-23 15:46:37 +04:00
|
|
|
mdecoder->sync_cb(mdecoder->stream);
|
2014-05-23 17:35:25 +04:00
|
|
|
|
2014-05-23 15:46:37 +04:00
|
|
|
return TRUE;
|
|
|
|
}
|
2012-06-13 23:45:58 +04:00
|
|
|
|
2012-10-09 11:26:39 +04:00
|
|
|
static inline const GstClockTime tsmf_gstreamer_timestamp_ms_to_gst(UINT64 ms_timestamp)
|
2012-06-13 23:45:58 +04:00
|
|
|
{
|
2014-05-23 15:46:37 +04:00
|
|
|
/*
|
2012-06-13 23:45:58 +04:00
|
|
|
* Convert Microsoft 100ns timestamps to Gstreamer 1ns units.
|
|
|
|
*/
|
|
|
|
return (GstClockTime)(ms_timestamp * 100);
|
|
|
|
}
|
|
|
|
|
2014-05-23 15:46:37 +04:00
|
|
|
int tsmf_gstreamer_pipeline_set_state(TSMFGstreamerDecoder *mdecoder, GstState desired_state)
|
2012-06-13 23:45:58 +04:00
|
|
|
{
|
|
|
|
GstStateChangeReturn state_change;
|
|
|
|
const char *name;
|
2014-05-23 17:35:25 +04:00
|
|
|
|
|
|
|
if (!mdecoder)
|
2014-05-23 15:46:37 +04:00
|
|
|
return 0;
|
2014-05-23 17:35:25 +04:00
|
|
|
|
|
|
|
if (!mdecoder->pipe)
|
2012-06-13 23:45:58 +04:00
|
|
|
return 0; /* Just in case this is called during startup or shutdown when we don't expect it */
|
2014-05-23 17:35:25 +04:00
|
|
|
|
|
|
|
if (desired_state == mdecoder->state)
|
2012-06-13 23:45:58 +04:00
|
|
|
return 0; /* Redundant request - Nothing to do */
|
2014-05-23 17:35:25 +04:00
|
|
|
|
2014-05-25 00:22:33 +04:00
|
|
|
name = gst_element_state_get_name(desired_state); /* For debug */
|
2014-05-23 15:46:37 +04:00
|
|
|
DEBUG_TSMF("%s to %s", get_type(mdecoder), name);
|
|
|
|
state_change = gst_element_set_state(mdecoder->pipe, desired_state);
|
2014-05-23 17:35:25 +04:00
|
|
|
|
|
|
|
if (state_change == GST_STATE_CHANGE_FAILURE)
|
2014-05-23 15:46:37 +04:00
|
|
|
DEBUG_WARN("(%s) GST_STATE_CHANGE_FAILURE.", name);
|
2014-05-23 17:35:25 +04:00
|
|
|
else if (state_change == GST_STATE_CHANGE_ASYNC)
|
|
|
|
{
|
|
|
|
DEBUG_WARN("(%s) GST_STATE_CHANGE_ASYNC.", name);
|
|
|
|
mdecoder->state = desired_state;
|
|
|
|
}
|
2012-06-13 23:45:58 +04:00
|
|
|
else
|
2014-05-23 17:35:25 +04:00
|
|
|
mdecoder->state = desired_state;
|
|
|
|
|
2012-06-13 23:45:58 +04:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2014-05-23 15:46:37 +04:00
|
|
|
static GstBuffer *tsmf_get_buffer_from_data(const void *raw_data, gsize size)
|
2012-06-13 23:45:58 +04:00
|
|
|
{
|
2014-05-25 00:22:33 +04:00
|
|
|
GstBuffer *buffer;
|
2014-05-23 15:46:37 +04:00
|
|
|
gpointer data;
|
2014-05-25 00:22:33 +04:00
|
|
|
assert(raw_data);
|
2014-05-23 15:46:37 +04:00
|
|
|
assert(size > 0);
|
|
|
|
data = g_malloc(size);
|
2014-05-25 00:22:33 +04:00
|
|
|
|
|
|
|
if (!data)
|
|
|
|
{
|
|
|
|
DEBUG_WARN("Could not allocate %d bytes of data.", size);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2014-05-23 15:46:37 +04:00
|
|
|
memcpy(data, raw_data, size);
|
2014-05-25 00:22:33 +04:00
|
|
|
#if GST_VERSION_MAJOR > 0
|
|
|
|
buffer = gst_buffer_new_wrapped(data, size);
|
|
|
|
#else
|
|
|
|
buffer = gst_buffer_new();
|
2012-06-13 23:45:58 +04:00
|
|
|
|
2014-05-25 00:22:33 +04:00
|
|
|
if (!buffer)
|
|
|
|
{
|
|
|
|
DEBUG_WARN("Could not create GstBuffer");
|
|
|
|
free(data);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
GST_BUFFER_MALLOCDATA(buffer) = data;
|
|
|
|
GST_BUFFER_SIZE(buffer) = size;
|
|
|
|
GST_BUFFER_DATA(buffer) = GST_BUFFER_MALLOCDATA(buffer);
|
|
|
|
#endif
|
|
|
|
return buffer;
|
2014-05-23 15:46:37 +04:00
|
|
|
}
|
2012-06-13 23:45:58 +04:00
|
|
|
|
2014-05-23 15:46:37 +04:00
|
|
|
static BOOL tsmf_gstreamer_set_format(ITSMFDecoder *decoder, TS_AM_MEDIA_TYPE *media_type)
|
|
|
|
{
|
|
|
|
TSMFGstreamerDecoder *mdecoder = (TSMFGstreamerDecoder *) decoder;
|
2014-05-23 17:35:25 +04:00
|
|
|
|
|
|
|
if (!mdecoder)
|
2014-05-23 15:46:37 +04:00
|
|
|
return FALSE;
|
2014-05-23 17:35:25 +04:00
|
|
|
|
2014-05-23 15:46:37 +04:00
|
|
|
DEBUG_TSMF("");
|
2014-05-23 17:35:25 +04:00
|
|
|
|
|
|
|
switch (media_type->MajorType)
|
2012-06-13 23:45:58 +04:00
|
|
|
{
|
|
|
|
case TSMF_MAJOR_TYPE_VIDEO:
|
|
|
|
mdecoder->media_type = TSMF_MAJOR_TYPE_VIDEO;
|
|
|
|
break;
|
2014-05-23 17:35:25 +04:00
|
|
|
|
2012-06-13 23:45:58 +04:00
|
|
|
case TSMF_MAJOR_TYPE_AUDIO:
|
|
|
|
mdecoder->media_type = TSMF_MAJOR_TYPE_AUDIO;
|
|
|
|
break;
|
2014-05-23 17:35:25 +04:00
|
|
|
|
2012-06-13 23:45:58 +04:00
|
|
|
default:
|
|
|
|
return FALSE;
|
|
|
|
}
|
2014-05-23 17:35:25 +04:00
|
|
|
|
|
|
|
switch (media_type->SubType)
|
2012-06-13 23:45:58 +04:00
|
|
|
{
|
|
|
|
case TSMF_SUB_TYPE_WVC1:
|
2014-05-23 15:46:37 +04:00
|
|
|
mdecoder->gst_caps = gst_caps_new_simple("video/x-wmv",
|
|
|
|
"bitrate", G_TYPE_UINT, media_type->BitRate,
|
|
|
|
"width", G_TYPE_INT, media_type->Width,
|
|
|
|
"height", G_TYPE_INT, media_type->Height,
|
|
|
|
"wmvversion", G_TYPE_INT, 3,
|
|
|
|
"format", G_TYPE_STRING, "WVC1",
|
|
|
|
//"framerate", GST_TYPE_FRACTION, media_type->SamplesPerSecond.Numerator, media_type->SamplesPerSecond.Denominator,
|
|
|
|
NULL);
|
2012-06-13 23:45:58 +04:00
|
|
|
break;
|
2014-05-23 17:35:25 +04:00
|
|
|
|
2012-06-13 23:45:58 +04:00
|
|
|
case TSMF_SUB_TYPE_MP4S:
|
2014-05-23 15:46:37 +04:00
|
|
|
mdecoder->gst_caps = gst_caps_new_simple("video/x-divx",
|
|
|
|
"divxversion", G_TYPE_INT, 5,
|
|
|
|
"bitrate", G_TYPE_UINT, media_type->BitRate,
|
|
|
|
"width", G_TYPE_INT, media_type->Width,
|
|
|
|
"height", G_TYPE_INT, media_type->Height,
|
|
|
|
NULL);
|
2012-06-13 23:45:58 +04:00
|
|
|
break;
|
2014-05-23 17:35:25 +04:00
|
|
|
|
2012-06-13 23:45:58 +04:00
|
|
|
case TSMF_SUB_TYPE_MP42:
|
2014-05-23 15:46:37 +04:00
|
|
|
mdecoder->gst_caps = gst_caps_new_simple("video/x-msmpeg",
|
|
|
|
"msmpegversion", G_TYPE_INT, 42,
|
|
|
|
"bitrate", G_TYPE_UINT, media_type->BitRate,
|
|
|
|
"width", G_TYPE_INT, media_type->Width,
|
|
|
|
"height", G_TYPE_INT, media_type->Height,
|
|
|
|
NULL);
|
2012-06-13 23:45:58 +04:00
|
|
|
break;
|
2014-05-23 17:35:25 +04:00
|
|
|
|
2012-06-13 23:45:58 +04:00
|
|
|
case TSMF_SUB_TYPE_MP43:
|
2014-05-23 15:46:37 +04:00
|
|
|
mdecoder->gst_caps = gst_caps_new_simple("video/x-msmpeg",
|
|
|
|
"bitrate", G_TYPE_UINT, media_type->BitRate,
|
|
|
|
"width", G_TYPE_INT, media_type->Width,
|
|
|
|
"height", G_TYPE_INT, media_type->Height,
|
|
|
|
"format", G_TYPE_STRING, "MP43",
|
|
|
|
NULL);
|
2012-06-13 23:45:58 +04:00
|
|
|
break;
|
2014-05-23 17:35:25 +04:00
|
|
|
|
2012-06-13 23:45:58 +04:00
|
|
|
case TSMF_SUB_TYPE_WMA9:
|
2014-05-23 15:46:37 +04:00
|
|
|
mdecoder->gst_caps = gst_caps_new_simple("audio/x-wma",
|
|
|
|
"wmaversion", G_TYPE_INT, 3,
|
|
|
|
"rate", G_TYPE_INT, media_type->SamplesPerSecond.Numerator,
|
|
|
|
"channels", G_TYPE_INT, media_type->Channels,
|
|
|
|
"bitrate", G_TYPE_INT, media_type->BitRate,
|
|
|
|
"depth", G_TYPE_INT, media_type->BitsPerSample,
|
|
|
|
"width", G_TYPE_INT, media_type->BitsPerSample,
|
|
|
|
"block_align", G_TYPE_INT, media_type->BlockAlign,
|
|
|
|
NULL);
|
2012-06-13 23:45:58 +04:00
|
|
|
break;
|
2014-05-23 17:35:25 +04:00
|
|
|
|
2012-06-13 23:45:58 +04:00
|
|
|
case TSMF_SUB_TYPE_WMA2:
|
2014-05-23 15:46:37 +04:00
|
|
|
mdecoder->gst_caps = gst_caps_new_simple("audio/x-wma",
|
|
|
|
"wmaversion", G_TYPE_INT, 2,
|
|
|
|
"rate", G_TYPE_INT, media_type->SamplesPerSecond.Numerator,
|
|
|
|
"channels", G_TYPE_INT, media_type->Channels,
|
|
|
|
"bitrate", G_TYPE_INT, media_type->BitRate,
|
|
|
|
"depth", G_TYPE_INT, media_type->BitsPerSample,
|
|
|
|
"width", G_TYPE_INT, media_type->BitsPerSample,
|
|
|
|
"block_align", G_TYPE_INT, media_type->BlockAlign,
|
|
|
|
NULL);
|
2012-06-13 23:45:58 +04:00
|
|
|
break;
|
2014-05-23 17:35:25 +04:00
|
|
|
|
2012-06-13 23:45:58 +04:00
|
|
|
case TSMF_SUB_TYPE_MP3:
|
2014-05-23 15:46:37 +04:00
|
|
|
mdecoder->gst_caps = gst_caps_new_simple("audio/mpeg",
|
|
|
|
"mpegversion", G_TYPE_INT, 1,
|
|
|
|
"layer", G_TYPE_INT, 3,
|
|
|
|
"rate", G_TYPE_INT, media_type->SamplesPerSecond.Numerator,
|
|
|
|
"channels", G_TYPE_INT, media_type->Channels,
|
|
|
|
NULL);
|
2012-06-13 23:45:58 +04:00
|
|
|
break;
|
2014-05-23 17:35:25 +04:00
|
|
|
|
2012-06-13 23:45:58 +04:00
|
|
|
case TSMF_SUB_TYPE_WMV1:
|
2014-05-23 15:46:37 +04:00
|
|
|
mdecoder->gst_caps = gst_caps_new_simple("video/x-wmv",
|
|
|
|
"bitrate", G_TYPE_UINT, media_type->BitRate,
|
|
|
|
"width", G_TYPE_INT, media_type->Width,
|
|
|
|
"height", G_TYPE_INT, media_type->Height,
|
|
|
|
"wmvversion", G_TYPE_INT, 1,
|
|
|
|
"format", G_TYPE_STRING, "WMV1",
|
|
|
|
NULL);
|
2012-06-13 23:45:58 +04:00
|
|
|
break;
|
2014-05-23 17:35:25 +04:00
|
|
|
|
2012-06-13 23:45:58 +04:00
|
|
|
case TSMF_SUB_TYPE_WMV2:
|
2014-05-23 15:46:37 +04:00
|
|
|
mdecoder->gst_caps = gst_caps_new_simple("video/x-wmv",
|
|
|
|
"width", G_TYPE_INT, media_type->Width,
|
|
|
|
"height", G_TYPE_INT, media_type->Height,
|
|
|
|
"wmvversion", G_TYPE_INT, 2,
|
|
|
|
"format", G_TYPE_STRING, "WMV2",
|
|
|
|
NULL);
|
2012-06-13 23:45:58 +04:00
|
|
|
break;
|
2014-05-23 17:35:25 +04:00
|
|
|
|
2012-06-13 23:45:58 +04:00
|
|
|
case TSMF_SUB_TYPE_WMV3:
|
2014-05-23 15:46:37 +04:00
|
|
|
mdecoder->gst_caps = gst_caps_new_simple("video/x-wmv",
|
|
|
|
"bitrate", G_TYPE_UINT, media_type->BitRate,
|
|
|
|
"width", G_TYPE_INT, media_type->Width,
|
|
|
|
"height", G_TYPE_INT, media_type->Height,
|
|
|
|
"wmvversion", G_TYPE_INT, 3,
|
|
|
|
"format", G_TYPE_STRING, "WMV3",
|
|
|
|
//"framerate", GST_TYPE_FRACTION, media_type->SamplesPerSecond.Numerator, media_type->SamplesPerSecond.Denominator,
|
|
|
|
NULL);
|
2012-06-13 23:45:58 +04:00
|
|
|
break;
|
2014-05-23 17:35:25 +04:00
|
|
|
|
2012-06-13 23:45:58 +04:00
|
|
|
case TSMF_SUB_TYPE_AVC1:
|
|
|
|
case TSMF_SUB_TYPE_H264:
|
2014-05-23 15:46:37 +04:00
|
|
|
mdecoder->gst_caps = gst_caps_new_simple("video/x-h264",
|
|
|
|
"width", G_TYPE_INT, media_type->Width,
|
|
|
|
"height", G_TYPE_INT, media_type->Height,
|
|
|
|
//"framerate", GST_TYPE_FRACTION, media_type->SamplesPerSecond.Numerator, media_type->SamplesPerSecond.Denominator,
|
|
|
|
NULL);
|
2012-06-13 23:45:58 +04:00
|
|
|
break;
|
2014-05-23 17:35:25 +04:00
|
|
|
|
2012-06-13 23:45:58 +04:00
|
|
|
case TSMF_SUB_TYPE_AC3:
|
2014-05-23 15:46:37 +04:00
|
|
|
mdecoder->gst_caps = gst_caps_new_simple("audio/x-ac3",
|
|
|
|
"rate", G_TYPE_INT, media_type->SamplesPerSecond.Numerator,
|
|
|
|
"channels", G_TYPE_INT, media_type->Channels,
|
|
|
|
NULL);
|
2012-06-13 23:45:58 +04:00
|
|
|
break;
|
2014-05-23 17:35:25 +04:00
|
|
|
|
2012-06-13 23:45:58 +04:00
|
|
|
case TSMF_SUB_TYPE_AAC:
|
2014-05-23 17:35:25 +04:00
|
|
|
|
2012-06-13 23:45:58 +04:00
|
|
|
/* For AAC the pFormat is a HEAACWAVEINFO struct, and the codec data
|
|
|
|
is at the end of it. See
|
|
|
|
http://msdn.microsoft.com/en-us/library/dd757806.aspx */
|
2014-05-23 17:35:25 +04:00
|
|
|
if (media_type->ExtraData)
|
2012-06-13 23:45:58 +04:00
|
|
|
{
|
|
|
|
media_type->ExtraData += 12;
|
|
|
|
media_type->ExtraDataSize -= 12;
|
|
|
|
}
|
2014-05-23 17:35:25 +04:00
|
|
|
|
2014-05-23 15:46:37 +04:00
|
|
|
mdecoder->gst_caps = gst_caps_new_simple("audio/mpeg",
|
|
|
|
"rate", G_TYPE_INT, media_type->SamplesPerSecond.Numerator,
|
|
|
|
"channels", G_TYPE_INT, media_type->Channels,
|
|
|
|
"mpegversion", G_TYPE_INT, 4,
|
|
|
|
NULL);
|
2012-06-13 23:45:58 +04:00
|
|
|
break;
|
2014-05-23 17:35:25 +04:00
|
|
|
|
2012-06-13 23:45:58 +04:00
|
|
|
case TSMF_SUB_TYPE_MP1A:
|
2014-05-23 15:46:37 +04:00
|
|
|
mdecoder->gst_caps = gst_caps_new_simple("audio/mpeg",
|
|
|
|
"mpegversion", G_TYPE_INT, 1,
|
|
|
|
"channels", G_TYPE_INT, media_type->Channels,
|
|
|
|
NULL);
|
2012-06-13 23:45:58 +04:00
|
|
|
break;
|
2014-05-23 17:35:25 +04:00
|
|
|
|
2012-06-13 23:45:58 +04:00
|
|
|
case TSMF_SUB_TYPE_MP1V:
|
2014-05-23 15:46:37 +04:00
|
|
|
mdecoder->gst_caps = gst_caps_new_simple("video/mpeg",
|
|
|
|
"mpegversion", G_TYPE_INT, 1,
|
|
|
|
"width", G_TYPE_INT, media_type->Width,
|
|
|
|
"height", G_TYPE_INT, media_type->Height,
|
|
|
|
"systemstream", G_TYPE_BOOLEAN, FALSE,
|
|
|
|
NULL);
|
2012-06-13 23:45:58 +04:00
|
|
|
break;
|
2014-05-23 17:35:25 +04:00
|
|
|
|
2012-06-13 23:45:58 +04:00
|
|
|
case TSMF_SUB_TYPE_YUY2:
|
2014-05-23 15:46:37 +04:00
|
|
|
mdecoder->gst_caps = gst_caps_new_simple("video/x-raw-yuv",
|
|
|
|
"format", G_TYPE_STRING, "YUY2",
|
|
|
|
//"bitrate", G_TYPE_UINT, media_type->BitRate,
|
|
|
|
"width", G_TYPE_INT, media_type->Width,
|
|
|
|
"height", G_TYPE_INT, media_type->Height,
|
|
|
|
NULL);
|
2012-06-13 23:45:58 +04:00
|
|
|
break;
|
2014-05-23 17:35:25 +04:00
|
|
|
|
2012-06-13 23:45:58 +04:00
|
|
|
case TSMF_SUB_TYPE_MP2V:
|
2014-05-23 15:46:37 +04:00
|
|
|
mdecoder->gst_caps = gst_caps_new_simple("video/mpeg",
|
|
|
|
//"bitrate", G_TYPE_UINT, media_type->BitRate,
|
|
|
|
//"width", G_TYPE_INT, media_type->Width,
|
|
|
|
//"height", G_TYPE_INT, media_type->Height,
|
|
|
|
"mpegversion", G_TYPE_INT, 2,
|
|
|
|
"systemstream", G_TYPE_BOOLEAN, FALSE,
|
|
|
|
NULL);
|
2012-06-13 23:45:58 +04:00
|
|
|
break;
|
2014-05-23 17:35:25 +04:00
|
|
|
|
2012-06-13 23:45:58 +04:00
|
|
|
case TSMF_SUB_TYPE_MP2A:
|
2014-05-23 15:46:37 +04:00
|
|
|
mdecoder->gst_caps = gst_caps_new_simple("audio/mpeg",
|
|
|
|
"mpegversion", G_TYPE_INT, 2,
|
|
|
|
"rate", G_TYPE_INT, media_type->SamplesPerSecond.Numerator,
|
|
|
|
"channels", G_TYPE_INT, media_type->Channels,
|
|
|
|
NULL);
|
2012-06-13 23:45:58 +04:00
|
|
|
break;
|
2014-05-23 17:35:25 +04:00
|
|
|
|
2012-06-13 23:45:58 +04:00
|
|
|
default:
|
2014-05-23 15:46:37 +04:00
|
|
|
DEBUG_WARN("unknown format:(%d).", media_type->SubType);
|
2012-06-13 23:45:58 +04:00
|
|
|
return FALSE;
|
|
|
|
}
|
2014-05-23 17:35:25 +04:00
|
|
|
|
|
|
|
if (media_type->ExtraDataSize > 0)
|
2014-05-23 15:46:37 +04:00
|
|
|
{
|
2014-05-25 00:22:33 +04:00
|
|
|
GstBuffer *buffer;
|
2014-05-23 15:46:37 +04:00
|
|
|
DEBUG_TSMF("Extra data available (%d)", media_type->ExtraDataSize);
|
2014-05-25 00:22:33 +04:00
|
|
|
buffer = tsmf_get_buffer_from_data(media_type->ExtraData, media_type->ExtraDataSize);
|
|
|
|
|
|
|
|
if (!buffer)
|
|
|
|
{
|
|
|
|
DEBUG_WARN("could not allocate GstBuffer!");
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
gst_caps_set_simple(mdecoder->gst_caps, "codec_data", GST_TYPE_BUFFER, buffer, NULL);
|
2014-05-23 15:46:37 +04:00
|
|
|
}
|
2014-05-23 17:35:25 +04:00
|
|
|
|
2014-05-23 15:46:37 +04:00
|
|
|
DEBUG_TSMF("%p format '%s'", mdecoder, gst_caps_to_string(mdecoder->gst_caps));
|
|
|
|
tsmf_platform_set_format(mdecoder);
|
2014-05-23 17:35:25 +04:00
|
|
|
|
2014-05-23 15:46:37 +04:00
|
|
|
/* Create the pipeline... */
|
2014-05-23 17:35:25 +04:00
|
|
|
if (!tsmf_gstreamer_pipeline_build(mdecoder))
|
2014-05-23 15:46:37 +04:00
|
|
|
return FALSE;
|
2014-05-23 17:35:25 +04:00
|
|
|
|
2012-06-13 23:45:58 +04:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2014-05-23 15:46:37 +04:00
|
|
|
void tsmf_gstreamer_clean_up_pad(TSMFGstreamerDecoder *mdecoder)
|
2012-06-13 23:45:58 +04:00
|
|
|
{
|
2014-05-23 17:35:25 +04:00
|
|
|
if (!mdecoder || !mdecoder->pipe)
|
2014-05-23 15:46:37 +04:00
|
|
|
return;
|
2014-05-23 17:35:25 +04:00
|
|
|
|
2014-05-23 15:46:37 +04:00
|
|
|
mdecoder->outconv = NULL;
|
2014-05-25 00:22:33 +04:00
|
|
|
mdecoder->outrate = NULL;
|
2014-05-23 15:46:37 +04:00
|
|
|
mdecoder->outresample = NULL;
|
|
|
|
mdecoder->outsink = NULL;
|
|
|
|
mdecoder->volume = NULL;
|
2012-06-13 23:45:58 +04:00
|
|
|
}
|
|
|
|
|
2014-05-23 15:46:37 +04:00
|
|
|
void tsmf_gstreamer_clean_up(TSMFGstreamerDecoder *mdecoder)
|
2012-06-13 23:45:58 +04:00
|
|
|
{
|
2014-05-23 15:46:37 +04:00
|
|
|
//Cleaning up elements
|
2014-05-23 17:35:25 +04:00
|
|
|
if (!mdecoder || !mdecoder->pipe)
|
2014-05-23 15:46:37 +04:00
|
|
|
return;
|
2014-05-23 17:35:25 +04:00
|
|
|
|
|
|
|
if (mdecoder->pipe && GST_OBJECT_REFCOUNT_VALUE(mdecoder->pipe) > 0)
|
2014-05-23 15:46:37 +04:00
|
|
|
{
|
|
|
|
gst_element_set_state(mdecoder->pipe, GST_STATE_NULL);
|
|
|
|
gst_object_unref(mdecoder->pipe);
|
|
|
|
}
|
2014-05-23 17:35:25 +04:00
|
|
|
|
2014-05-23 15:46:37 +04:00
|
|
|
tsmf_gstreamer_clean_up_pad(mdecoder);
|
|
|
|
tsmf_window_destroy(mdecoder);
|
|
|
|
mdecoder->ready = FALSE;
|
|
|
|
mdecoder->pipe = NULL;
|
|
|
|
mdecoder->src = NULL;
|
|
|
|
mdecoder->queue = NULL;
|
|
|
|
mdecoder->decbin = NULL;
|
|
|
|
mdecoder->outbin = NULL;
|
|
|
|
}
|
2012-06-13 23:45:58 +04:00
|
|
|
|
2014-05-23 15:46:37 +04:00
|
|
|
static void
|
|
|
|
cb_newpad(GstElement *decodebin,
|
|
|
|
GstPad *pad,
|
|
|
|
gpointer data)
|
|
|
|
{
|
|
|
|
GstPad *outpad;
|
|
|
|
TSMFGstreamerDecoder *mdecoder = data;
|
|
|
|
/* only link once */
|
|
|
|
outpad = gst_element_get_static_pad(mdecoder->outbin, "sink");
|
2014-05-23 17:35:25 +04:00
|
|
|
|
|
|
|
if (GST_PAD_IS_LINKED(outpad))
|
2014-05-23 15:46:37 +04:00
|
|
|
{
|
|
|
|
DEBUG_WARN("sink already linded!");
|
|
|
|
gst_object_unref(outpad);
|
|
|
|
return;
|
2012-06-13 23:45:58 +04:00
|
|
|
}
|
2014-05-23 17:35:25 +04:00
|
|
|
|
2014-05-23 15:46:37 +04:00
|
|
|
/* link'n'play */
|
|
|
|
gst_pad_link(pad, outpad);
|
|
|
|
gst_object_unref(outpad);
|
|
|
|
}
|
2012-06-13 23:45:58 +04:00
|
|
|
|
2014-05-23 15:46:37 +04:00
|
|
|
static void
|
|
|
|
cb_freepad(GstElement *decodebin,
|
|
|
|
GstPad *pad,
|
|
|
|
gpointer data)
|
|
|
|
{
|
|
|
|
GstPad *outpad;
|
|
|
|
TSMFGstreamerDecoder *mdecoder = data;
|
|
|
|
outpad = gst_element_get_static_pad(mdecoder->outbin, "sink");
|
2014-05-23 17:35:25 +04:00
|
|
|
|
|
|
|
if (!outpad)
|
2012-06-13 23:45:58 +04:00
|
|
|
{
|
2014-05-23 15:46:37 +04:00
|
|
|
DEBUG_WARN("sink pad does not exist!");
|
|
|
|
return;
|
2012-06-13 23:45:58 +04:00
|
|
|
}
|
2014-05-23 17:35:25 +04:00
|
|
|
|
|
|
|
if (!GST_PAD_IS_LINKED(outpad))
|
2012-06-13 23:45:58 +04:00
|
|
|
{
|
2014-05-23 15:46:37 +04:00
|
|
|
DEBUG_WARN("sink not linded!");
|
|
|
|
gst_object_unref(outpad);
|
|
|
|
return;
|
2012-06-13 23:45:58 +04:00
|
|
|
}
|
2014-05-23 17:35:25 +04:00
|
|
|
|
2014-05-23 15:46:37 +04:00
|
|
|
/* link'n'play */
|
|
|
|
gst_pad_unlink(pad, outpad);
|
|
|
|
gst_object_unref(outpad);
|
2012-06-13 23:45:58 +04:00
|
|
|
}
|
|
|
|
|
2014-05-23 15:46:37 +04:00
|
|
|
void tsmf_gstreamer_remove_pad(TSMFGstreamerDecoder *mdecoder)
|
2012-06-13 23:45:58 +04:00
|
|
|
{
|
2014-05-23 17:35:25 +04:00
|
|
|
if (mdecoder->outbin)
|
2012-06-13 23:45:58 +04:00
|
|
|
{
|
2014-05-23 15:46:37 +04:00
|
|
|
gst_element_remove_pad(mdecoder->outbin, mdecoder->ghost_pad);
|
|
|
|
gst_object_unref(mdecoder->ghost_pad);
|
|
|
|
mdecoder->ghost_pad = NULL;
|
2012-06-13 23:45:58 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-05-23 15:46:37 +04:00
|
|
|
BOOL tsmf_gstreamer_add_pad(TSMFGstreamerDecoder *mdecoder)
|
2012-06-13 23:45:58 +04:00
|
|
|
{
|
|
|
|
GstPad *out_pad;
|
2014-05-23 15:46:37 +04:00
|
|
|
gboolean linkResult = FALSE;
|
2014-05-23 17:35:25 +04:00
|
|
|
|
|
|
|
switch (mdecoder->media_type)
|
2012-06-13 23:45:58 +04:00
|
|
|
{
|
2014-05-23 15:46:37 +04:00
|
|
|
case TSMF_MAJOR_TYPE_VIDEO:
|
2012-06-13 23:45:58 +04:00
|
|
|
{
|
2014-05-25 00:22:33 +04:00
|
|
|
#if GST_VERSION_MAJOR > 0
|
2014-05-23 15:46:37 +04:00
|
|
|
mdecoder->outconv = gst_element_factory_make("videoconvert", "videoconvert");
|
2014-05-25 00:22:33 +04:00
|
|
|
#else
|
|
|
|
mdecoder->outconv = gst_element_factory_make("ffmpegcolorspace", "videoconvert");
|
|
|
|
#endif
|
|
|
|
mdecoder->outrate = gst_element_factory_make("videorate", "videorate");
|
2014-05-23 15:46:37 +04:00
|
|
|
mdecoder->outsink = gst_element_factory_make(tsmf_platform_get_video_sink(), "videosink");
|
|
|
|
mdecoder->outresample = gst_element_factory_make("videoscale", "videoscale");
|
|
|
|
mdecoder->volume = NULL;
|
|
|
|
DEBUG_TSMF("building Video Pipe");
|
|
|
|
break;
|
2012-06-13 23:45:58 +04:00
|
|
|
}
|
2014-05-23 17:35:25 +04:00
|
|
|
|
2014-05-23 15:46:37 +04:00
|
|
|
case TSMF_MAJOR_TYPE_AUDIO:
|
2012-06-13 23:45:58 +04:00
|
|
|
{
|
2014-05-23 15:46:37 +04:00
|
|
|
mdecoder->outconv = gst_element_factory_make("audioconvert", "audioconvert");
|
2014-05-25 00:22:33 +04:00
|
|
|
mdecoder->outrate = gst_element_factory_make("audiorate", "audiorate");
|
2014-05-23 15:46:37 +04:00
|
|
|
mdecoder->outresample = gst_element_factory_make("audioresample", "audioresample");
|
|
|
|
mdecoder->volume = gst_element_factory_make("volume", "audiovolume");
|
|
|
|
mdecoder->outsink = gst_element_factory_make(tsmf_platform_get_audio_sink(), "audiosink");
|
|
|
|
DEBUG_TSMF("building Audio Pipe");
|
|
|
|
break;
|
2012-06-13 23:45:58 +04:00
|
|
|
}
|
2014-05-23 17:35:25 +04:00
|
|
|
|
2012-06-13 23:45:58 +04:00
|
|
|
default:
|
2014-05-23 15:46:37 +04:00
|
|
|
DEBUG_WARN("Invalid media type %08X", mdecoder->media_type);
|
|
|
|
tsmf_gstreamer_clean_up_pad(mdecoder);
|
2012-06-13 23:45:58 +04:00
|
|
|
return FALSE;
|
|
|
|
}
|
2014-05-23 17:35:25 +04:00
|
|
|
|
2014-05-25 00:22:33 +04:00
|
|
|
/* Add audio / video specific elements to pipe */
|
2014-05-23 17:35:25 +04:00
|
|
|
if (mdecoder->outconv)
|
2014-05-25 00:22:33 +04:00
|
|
|
gst_bin_add(GST_BIN(mdecoder->pipe), mdecoder->outconv);
|
|
|
|
|
|
|
|
if (mdecoder->outrate)
|
|
|
|
gst_bin_add(GST_BIN(mdecoder->pipe), mdecoder->outrate);
|
2014-05-23 17:35:25 +04:00
|
|
|
|
|
|
|
if (mdecoder->outresample)
|
2014-05-25 00:22:33 +04:00
|
|
|
gst_bin_add(GST_BIN(mdecoder->pipe), mdecoder->outresample);
|
2014-05-23 17:35:25 +04:00
|
|
|
|
|
|
|
if (mdecoder->volume)
|
2014-05-25 00:22:33 +04:00
|
|
|
gst_bin_add(GST_BIN(mdecoder->pipe), mdecoder->volume);
|
2014-05-23 17:35:25 +04:00
|
|
|
|
|
|
|
if (mdecoder->outsink)
|
2014-05-25 00:22:33 +04:00
|
|
|
gst_bin_add(GST_BIN(mdecoder->pipe), mdecoder->outsink);
|
2014-05-23 17:35:25 +04:00
|
|
|
|
2014-05-25 00:22:33 +04:00
|
|
|
if (!mdecoder->outconv || !mdecoder->outrate || ! mdecoder->outsink || !mdecoder->outresample)
|
2014-05-23 15:46:37 +04:00
|
|
|
{
|
|
|
|
DEBUG_WARN("Failed to load (some) output pipe elements");
|
2014-05-25 00:22:33 +04:00
|
|
|
DEBUG_WARN("converter=%p, rate=%p, sink=%p, resample=%p",
|
|
|
|
mdecoder->outconv, mdecoder->outrate, mdecoder->outsink, mdecoder->outresample);
|
2014-05-23 15:46:37 +04:00
|
|
|
tsmf_gstreamer_clean_up_pad(mdecoder);
|
2012-06-13 23:45:58 +04:00
|
|
|
return FALSE;
|
|
|
|
}
|
2014-05-23 17:35:25 +04:00
|
|
|
|
|
|
|
if (mdecoder->media_type == TSMF_MAJOR_TYPE_AUDIO)
|
2012-06-13 23:45:58 +04:00
|
|
|
{
|
2014-05-23 17:35:25 +04:00
|
|
|
if (!mdecoder->volume)
|
2012-06-13 23:45:58 +04:00
|
|
|
{
|
2014-05-23 15:46:37 +04:00
|
|
|
DEBUG_WARN("Failed to load (some) audio output pipe elements");
|
|
|
|
DEBUG_WARN("volume=%p", mdecoder->volume);
|
|
|
|
tsmf_gstreamer_clean_up_pad(mdecoder);
|
|
|
|
return FALSE;
|
2012-06-13 23:45:58 +04:00
|
|
|
}
|
|
|
|
}
|
2014-05-23 17:35:25 +04:00
|
|
|
|
2012-06-13 23:45:58 +04:00
|
|
|
out_pad = gst_element_get_static_pad(mdecoder->outconv, "sink");
|
2014-05-23 17:35:25 +04:00
|
|
|
|
|
|
|
if (mdecoder->media_type == TSMF_MAJOR_TYPE_AUDIO)
|
2012-06-13 23:45:58 +04:00
|
|
|
{
|
2014-05-23 15:46:37 +04:00
|
|
|
g_object_set(mdecoder->volume, "mute", mdecoder->gstMuted, NULL);
|
|
|
|
g_object_set(mdecoder->volume, "volume", mdecoder->gstVolume, NULL);
|
|
|
|
linkResult = gst_element_link_many(mdecoder->outconv, mdecoder->outresample,
|
|
|
|
mdecoder->volume, mdecoder->outsink, NULL);
|
2012-06-13 23:45:58 +04:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2014-05-23 15:46:37 +04:00
|
|
|
linkResult = gst_element_link_many(mdecoder->outconv,
|
|
|
|
mdecoder->outresample, mdecoder->outsink, NULL);
|
2012-06-13 23:45:58 +04:00
|
|
|
}
|
2014-05-23 17:35:25 +04:00
|
|
|
|
|
|
|
if (!linkResult)
|
2012-06-13 23:45:58 +04:00
|
|
|
{
|
2014-05-23 15:46:37 +04:00
|
|
|
DEBUG_WARN("Failed to link these elements: converter->sink");
|
|
|
|
tsmf_gstreamer_clean_up_pad(mdecoder);
|
2012-06-13 23:45:58 +04:00
|
|
|
return FALSE;
|
|
|
|
}
|
2014-05-23 17:35:25 +04:00
|
|
|
|
2014-05-23 15:46:37 +04:00
|
|
|
mdecoder->ghost_pad = gst_ghost_pad_new("sink", out_pad);
|
|
|
|
gst_element_add_pad(mdecoder->outbin, mdecoder->ghost_pad);
|
2012-06-13 23:45:58 +04:00
|
|
|
gst_object_unref(out_pad);
|
2014-05-23 15:46:37 +04:00
|
|
|
return TRUE;
|
|
|
|
}
|
2012-06-13 23:45:58 +04:00
|
|
|
|
2014-05-23 15:46:37 +04:00
|
|
|
BOOL tsmf_gstreamer_pipeline_build(TSMFGstreamerDecoder *mdecoder)
|
|
|
|
{
|
|
|
|
gboolean linkResult;
|
2014-05-23 17:35:25 +04:00
|
|
|
|
|
|
|
if (!mdecoder)
|
2014-05-23 15:46:37 +04:00
|
|
|
return FALSE;
|
2014-05-23 17:35:25 +04:00
|
|
|
|
2014-05-23 15:46:37 +04:00
|
|
|
mdecoder->pipe = gst_pipeline_new("pipeline");
|
2014-05-23 17:35:25 +04:00
|
|
|
|
|
|
|
if (!mdecoder->pipe)
|
2012-06-13 23:45:58 +04:00
|
|
|
{
|
2014-05-23 15:46:37 +04:00
|
|
|
DEBUG_WARN("Failed to create new pipe");
|
2012-06-13 23:45:58 +04:00
|
|
|
return FALSE;
|
|
|
|
}
|
2014-05-23 17:35:25 +04:00
|
|
|
|
2014-05-23 15:46:37 +04:00
|
|
|
tsmf_platform_register_handler(mdecoder);
|
|
|
|
mdecoder->src = gst_element_factory_make("appsrc", "source");
|
|
|
|
mdecoder->queue = gst_element_factory_make("queue2", "queue");
|
|
|
|
mdecoder->decbin = gst_element_factory_make("decodebin", "decoder");
|
|
|
|
mdecoder->outbin = gst_bin_new("outbin");
|
2014-05-23 17:35:25 +04:00
|
|
|
|
2014-05-23 15:46:37 +04:00
|
|
|
/* Add all elements to the bin allowing proper resource cleanup,
|
|
|
|
* if any step failed. */
|
2014-05-23 17:35:25 +04:00
|
|
|
if (mdecoder->src)
|
2014-05-23 15:46:37 +04:00
|
|
|
gst_bin_add(GST_BIN(mdecoder->pipe), mdecoder->src);
|
2014-05-23 17:35:25 +04:00
|
|
|
|
|
|
|
if (mdecoder->queue)
|
2014-05-23 15:46:37 +04:00
|
|
|
gst_bin_add(GST_BIN(mdecoder->pipe), mdecoder->queue);
|
2014-05-23 17:35:25 +04:00
|
|
|
|
|
|
|
if (mdecoder->decbin)
|
2014-05-23 15:46:37 +04:00
|
|
|
gst_bin_add(GST_BIN(mdecoder->pipe), mdecoder->decbin);
|
2014-05-23 17:35:25 +04:00
|
|
|
|
|
|
|
if (mdecoder->outbin)
|
2014-05-23 15:46:37 +04:00
|
|
|
gst_bin_add(GST_BIN(mdecoder->pipe), mdecoder->outbin);
|
2014-05-23 17:35:25 +04:00
|
|
|
|
2014-05-23 15:46:37 +04:00
|
|
|
/* Check, if everything was loaded correctly. */
|
2014-05-23 17:35:25 +04:00
|
|
|
if (!mdecoder->src || !mdecoder->queue || !mdecoder->decbin ||
|
2014-05-23 15:46:37 +04:00
|
|
|
!mdecoder->outbin)
|
|
|
|
{
|
|
|
|
DEBUG_WARN("Failed to load (some) pipeline stage");
|
|
|
|
DEBUG_WARN("src=%p, queue=%p, decoder=%p, output=%p",
|
|
|
|
mdecoder->src, mdecoder->queue, mdecoder->decbin, mdecoder->outbin);
|
2012-06-13 23:45:58 +04:00
|
|
|
tsmf_gstreamer_clean_up(mdecoder);
|
|
|
|
return FALSE;
|
|
|
|
}
|
2014-05-23 17:35:25 +04:00
|
|
|
|
2014-05-23 15:46:37 +04:00
|
|
|
gst_pipeline_set_delay((GstPipeline *)mdecoder->pipe, 5000);
|
|
|
|
/* AppSrc settings */
|
|
|
|
GstAppSrcCallbacks callbacks =
|
2012-06-13 23:45:58 +04:00
|
|
|
{
|
2014-05-23 15:46:37 +04:00
|
|
|
tsmf_gstreamer_need_data,
|
|
|
|
tsmf_gstreamer_enough_data,
|
|
|
|
tsmf_gstreamer_seek_data
|
|
|
|
};
|
|
|
|
g_object_set(mdecoder->src, "format", GST_FORMAT_TIME, NULL);
|
|
|
|
g_object_set(mdecoder->src, "is-live", TRUE, NULL);
|
|
|
|
g_object_set(mdecoder->src, "block", TRUE, NULL);
|
|
|
|
gst_app_src_set_callbacks((GstAppSrc *)mdecoder->src, &callbacks, mdecoder, NULL);
|
|
|
|
gst_app_src_set_stream_type((GstAppSrc *) mdecoder->src, GST_APP_STREAM_TYPE_SEEKABLE);
|
|
|
|
gst_app_src_set_caps((GstAppSrc *) mdecoder->src, mdecoder->gst_caps);
|
|
|
|
/* Queue2 settings */
|
|
|
|
g_object_set(mdecoder->queue, "use-buffering", FALSE, NULL);
|
|
|
|
g_object_set(mdecoder->queue, "max-size-buffers", 2, NULL);
|
|
|
|
/* DecodeBin settings */
|
|
|
|
g_signal_connect(mdecoder->decbin, "pad-added", G_CALLBACK(cb_newpad), mdecoder);
|
|
|
|
g_signal_connect(mdecoder->decbin, "pad-removed", G_CALLBACK(cb_freepad), mdecoder);
|
|
|
|
/* Sink settings */
|
|
|
|
linkResult = gst_element_link_many(mdecoder->src, mdecoder->queue,
|
|
|
|
mdecoder->decbin, NULL);
|
2014-05-23 17:35:25 +04:00
|
|
|
|
|
|
|
if (!linkResult)
|
2014-05-23 15:46:37 +04:00
|
|
|
{
|
|
|
|
DEBUG_WARN("Failed to link elements.");
|
|
|
|
tsmf_gstreamer_clean_up(mdecoder);
|
|
|
|
return FALSE;
|
2012-06-13 23:45:58 +04:00
|
|
|
}
|
2014-05-23 17:35:25 +04:00
|
|
|
|
2014-05-23 15:46:37 +04:00
|
|
|
tsmf_gstreamer_add_pad(mdecoder);
|
|
|
|
tsmf_window_create(mdecoder);
|
|
|
|
tsmf_gstreamer_pipeline_set_state(mdecoder, GST_STATE_READY);
|
|
|
|
tsmf_gstreamer_pipeline_set_state(mdecoder, GST_STATE_PLAYING);
|
|
|
|
mdecoder->pipeline_start_time_valid = 0;
|
|
|
|
mdecoder->shutdown = 0;
|
2012-06-13 23:45:58 +04:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2014-05-23 15:46:37 +04:00
|
|
|
static BOOL tsmf_gstreamer_decodeEx(ITSMFDecoder *decoder, const BYTE *data, UINT32 data_size, UINT32 extensions,
|
|
|
|
UINT64 start_time, UINT64 end_time, UINT64 duration)
|
2012-06-13 23:45:58 +04:00
|
|
|
{
|
2014-05-23 15:46:37 +04:00
|
|
|
GstBuffer *gst_buf;
|
|
|
|
TSMFGstreamerDecoder *mdecoder = (TSMFGstreamerDecoder *) decoder;
|
|
|
|
UINT64 sample_time = tsmf_gstreamer_timestamp_ms_to_gst(start_time);
|
|
|
|
UINT64 sample_duration = tsmf_gstreamer_timestamp_ms_to_gst(duration);
|
2014-05-23 17:35:25 +04:00
|
|
|
|
|
|
|
if (!mdecoder)
|
2012-06-13 23:45:58 +04:00
|
|
|
{
|
2014-05-23 15:46:37 +04:00
|
|
|
DEBUG_WARN("Decoder not initialized!");
|
2012-06-13 23:45:58 +04:00
|
|
|
return FALSE;
|
|
|
|
}
|
2014-05-23 17:35:25 +04:00
|
|
|
|
2014-05-23 15:46:37 +04:00
|
|
|
/*
|
|
|
|
* This function is always called from a stream-specific thread.
|
|
|
|
* It should be alright to block here if necessary.
|
|
|
|
* We don't expect to block here often, since the pipeline should
|
2012-06-13 23:45:58 +04:00
|
|
|
* have more than enough buffering.
|
2014-05-23 15:46:37 +04:00
|
|
|
*/
|
|
|
|
DEBUG_TSMF("%s. Start:(%llu) End:(%llu) Duration:(%llu) Last End:(%llu)",
|
|
|
|
get_type(mdecoder), start_time, end_time, duration,
|
|
|
|
mdecoder->last_sample_end_time);
|
2014-05-23 17:35:25 +04:00
|
|
|
|
|
|
|
if (mdecoder->gst_caps == NULL)
|
2012-06-13 23:45:58 +04:00
|
|
|
{
|
2014-05-23 15:46:37 +04:00
|
|
|
DEBUG_WARN("tsmf_gstreamer_set_format not called or invalid format.");
|
2012-06-13 23:45:58 +04:00
|
|
|
return FALSE;
|
|
|
|
}
|
2014-05-23 17:35:25 +04:00
|
|
|
|
|
|
|
if (!mdecoder->src)
|
2012-06-13 23:45:58 +04:00
|
|
|
{
|
2014-05-23 15:46:37 +04:00
|
|
|
DEBUG_WARN("failed to construct pipeline correctly. Unable to push buffer to source element.");
|
|
|
|
return FALSE;
|
2012-06-13 23:45:58 +04:00
|
|
|
}
|
2014-05-23 17:35:25 +04:00
|
|
|
|
2014-05-23 15:46:37 +04:00
|
|
|
gst_buf = tsmf_get_buffer_from_data(data, data_size);
|
2014-05-23 17:35:25 +04:00
|
|
|
|
|
|
|
if (gst_buf == NULL)
|
2012-06-13 23:45:58 +04:00
|
|
|
{
|
2014-05-23 15:46:37 +04:00
|
|
|
DEBUG_WARN("tsmf_get_buffer_from_data(%p, %d) failed.", data, data_size);
|
2012-06-13 23:45:58 +04:00
|
|
|
return FALSE;
|
|
|
|
}
|
2014-05-23 17:35:25 +04:00
|
|
|
|
|
|
|
if (mdecoder->pipeline_start_time_valid)
|
2012-06-13 23:45:58 +04:00
|
|
|
{
|
2014-05-23 15:46:37 +04:00
|
|
|
long long diff = start_time;
|
|
|
|
diff -= mdecoder->last_sample_end_time;
|
2014-05-23 17:35:25 +04:00
|
|
|
|
|
|
|
if (diff < 0)
|
2014-05-23 15:46:37 +04:00
|
|
|
diff *= -1;
|
2014-05-23 17:35:25 +04:00
|
|
|
|
2014-05-23 15:46:37 +04:00
|
|
|
/* The pipe is initialized, but there is a discontinuity.
|
|
|
|
* Seek to the start position... */
|
2014-05-23 17:35:25 +04:00
|
|
|
if (diff > 50)
|
2012-06-13 23:45:58 +04:00
|
|
|
{
|
2014-05-23 15:46:37 +04:00
|
|
|
DEBUG_TSMF("%s seeking to %lld", get_type(mdecoder), start_time);
|
2014-05-23 17:35:25 +04:00
|
|
|
|
|
|
|
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,
|
|
|
|
GST_SEEK_TYPE_NONE, GST_CLOCK_TIME_NONE))
|
2012-06-13 23:45:58 +04:00
|
|
|
{
|
2014-05-23 15:46:37 +04:00
|
|
|
DEBUG_WARN("seek failed");
|
2012-06-13 23:45:58 +04:00
|
|
|
}
|
2014-05-23 17:35:25 +04:00
|
|
|
|
2014-05-23 15:46:37 +04:00
|
|
|
mdecoder->pipeline_start_time_valid = 0;
|
2012-06-13 23:45:58 +04:00
|
|
|
}
|
|
|
|
}
|
2014-05-23 15:46:37 +04:00
|
|
|
else
|
2012-06-13 23:45:58 +04:00
|
|
|
{
|
2014-05-23 15:46:37 +04:00
|
|
|
DEBUG_TSMF("%s start time %llu", get_type(mdecoder), sample_time);
|
|
|
|
mdecoder->pipeline_start_time_valid = 1;
|
2013-06-19 20:33:46 +04:00
|
|
|
}
|
2014-05-23 17:35:25 +04:00
|
|
|
|
2014-05-25 00:22:33 +04:00
|
|
|
#if GST_VERSION_MAJOR > 0
|
2014-05-23 15:46:37 +04:00
|
|
|
GST_BUFFER_PTS(gst_buf) = sample_time;
|
2014-05-25 00:22:33 +04:00
|
|
|
#else
|
|
|
|
GST_BUFFER_TIMESTAMP(gst_buf) = sample_time;
|
|
|
|
#endif
|
2014-05-23 15:46:37 +04:00
|
|
|
GST_BUFFER_DURATION(gst_buf) = sample_duration;
|
2012-06-13 23:45:58 +04:00
|
|
|
gst_app_src_push_buffer(GST_APP_SRC(mdecoder->src), gst_buf);
|
2014-05-23 17:35:25 +04:00
|
|
|
|
|
|
|
if (mdecoder->ack_cb)
|
2014-05-23 15:46:37 +04:00
|
|
|
mdecoder->ack_cb(mdecoder->stream, TRUE);
|
2014-05-23 17:35:25 +04:00
|
|
|
|
2012-06-13 23:45:58 +04:00
|
|
|
mdecoder->last_sample_end_time = end_time;
|
2014-05-23 17:35:25 +04:00
|
|
|
|
|
|
|
if (GST_STATE(mdecoder->pipe) != GST_STATE_PLAYING)
|
2012-06-13 23:45:58 +04:00
|
|
|
{
|
2014-05-25 00:22:33 +04:00
|
|
|
DEBUG_TSMF("state=%s", gst_element_state_get_name(GST_STATE(mdecoder->pipe)));
|
2014-05-23 17:35:25 +04:00
|
|
|
|
|
|
|
if (!mdecoder->paused && !mdecoder->shutdown && mdecoder->ready)
|
2012-06-13 23:45:58 +04:00
|
|
|
tsmf_gstreamer_pipeline_set_state(mdecoder, GST_STATE_PLAYING);
|
|
|
|
}
|
2014-05-23 17:35:25 +04:00
|
|
|
|
2012-06-13 23:45:58 +04:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2014-05-23 15:46:37 +04:00
|
|
|
static void tsmf_gstreamer_change_volume(ITSMFDecoder *decoder, UINT32 newVolume, UINT32 muted)
|
2012-06-13 23:45:58 +04:00
|
|
|
{
|
2014-05-23 15:46:37 +04:00
|
|
|
TSMFGstreamerDecoder *mdecoder = (TSMFGstreamerDecoder *) decoder;
|
2014-05-23 17:35:25 +04:00
|
|
|
|
|
|
|
if (!mdecoder || !mdecoder->pipe)
|
2012-06-13 23:45:58 +04:00
|
|
|
return;
|
2014-05-23 17:35:25 +04:00
|
|
|
|
|
|
|
if (mdecoder->media_type == TSMF_MAJOR_TYPE_VIDEO)
|
2012-06-13 23:45:58 +04:00
|
|
|
return;
|
2014-05-23 17:35:25 +04:00
|
|
|
|
2013-06-19 20:33:46 +04:00
|
|
|
mdecoder->gstMuted = (BOOL) muted;
|
2014-05-23 15:46:37 +04:00
|
|
|
DEBUG_TSMF("mute=[%d]", mdecoder->gstMuted);
|
2013-06-19 20:33:46 +04:00
|
|
|
mdecoder->gstVolume = (double) newVolume / (double) 10000;
|
2014-05-23 15:46:37 +04:00
|
|
|
DEBUG_TSMF("gst_new_vol=[%f]", mdecoder->gstVolume);
|
2014-05-23 17:35:25 +04:00
|
|
|
|
|
|
|
if (!mdecoder->volume)
|
2012-06-13 23:45:58 +04:00
|
|
|
return;
|
2014-05-23 17:35:25 +04:00
|
|
|
|
|
|
|
if (!G_IS_OBJECT(mdecoder->volume))
|
2012-06-13 23:45:58 +04:00
|
|
|
return;
|
2014-05-23 17:35:25 +04:00
|
|
|
|
2014-05-23 15:46:37 +04:00
|
|
|
g_object_set(mdecoder->volume, "mute", mdecoder->gstMuted, NULL);
|
|
|
|
g_object_set(mdecoder->volume, "volume", mdecoder->gstVolume, NULL);
|
2012-06-13 23:45:58 +04:00
|
|
|
}
|
|
|
|
|
2014-05-23 15:46:37 +04:00
|
|
|
static void tsmf_gstreamer_control(ITSMFDecoder *decoder, ITSMFControlMsg control_msg, UINT32 *arg)
|
2012-06-13 23:45:58 +04:00
|
|
|
{
|
2014-05-23 15:46:37 +04:00
|
|
|
TSMFGstreamerDecoder *mdecoder = (TSMFGstreamerDecoder *) decoder;
|
2014-05-23 17:35:25 +04:00
|
|
|
|
|
|
|
if (!mdecoder)
|
2012-06-13 23:45:58 +04:00
|
|
|
return;
|
2014-05-23 17:35:25 +04:00
|
|
|
|
|
|
|
if (control_msg == Control_Pause)
|
2012-06-13 23:45:58 +04:00
|
|
|
{
|
2014-05-23 15:46:37 +04:00
|
|
|
DEBUG_TSMF("Control_Pause %s", get_type(mdecoder));
|
2014-05-23 17:35:25 +04:00
|
|
|
|
|
|
|
if (mdecoder->paused)
|
2012-06-13 23:45:58 +04:00
|
|
|
{
|
2014-05-23 15:46:37 +04:00
|
|
|
DEBUG_WARN("%s: Ignoring control PAUSE, already received!", get_type(mdecoder));
|
|
|
|
return;
|
2012-06-13 23:45:58 +04:00
|
|
|
}
|
2014-05-23 17:35:25 +04:00
|
|
|
|
2014-05-23 15:46:37 +04:00
|
|
|
tsmf_gstreamer_pipeline_set_state(mdecoder, GST_STATE_PAUSED);
|
|
|
|
mdecoder->paused = TRUE;
|
2014-05-23 17:35:25 +04:00
|
|
|
|
|
|
|
if (mdecoder->media_type == TSMF_MAJOR_TYPE_VIDEO)
|
2014-05-23 15:46:37 +04:00
|
|
|
tsmf_window_pause(mdecoder);
|
2012-06-13 23:45:58 +04:00
|
|
|
}
|
2014-05-23 17:35:25 +04:00
|
|
|
else if (control_msg == Control_Resume)
|
|
|
|
{
|
|
|
|
DEBUG_TSMF("Control_Resume %s", get_type(mdecoder));
|
|
|
|
|
|
|
|
if (!mdecoder->paused && !mdecoder->shutdown)
|
2012-06-13 23:45:58 +04:00
|
|
|
{
|
2014-05-23 17:35:25 +04:00
|
|
|
DEBUG_WARN("%s: Ignoring control RESUME, already received!", get_type(mdecoder));
|
|
|
|
return;
|
|
|
|
}
|
2014-05-23 15:46:37 +04:00
|
|
|
|
2014-05-23 17:35:25 +04:00
|
|
|
mdecoder->paused = FALSE;
|
|
|
|
mdecoder->shutdown = FALSE;
|
|
|
|
|
|
|
|
if (mdecoder->media_type == TSMF_MAJOR_TYPE_VIDEO)
|
|
|
|
tsmf_window_resume(mdecoder);
|
|
|
|
|
|
|
|
tsmf_gstreamer_pipeline_set_state(mdecoder, GST_STATE_PLAYING);
|
|
|
|
}
|
|
|
|
else if (control_msg == Control_Stop)
|
|
|
|
{
|
|
|
|
DEBUG_WARN("Control_Stop %s", get_type(mdecoder));
|
|
|
|
|
|
|
|
if (mdecoder->shutdown)
|
|
|
|
{
|
|
|
|
DEBUG_WARN("%s: Ignoring control STOP, already received!", get_type(mdecoder));
|
|
|
|
return;
|
2012-06-13 23:45:58 +04:00
|
|
|
}
|
2014-05-23 17:35:25 +04:00
|
|
|
|
|
|
|
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);
|
2012-06-13 23:45:58 +04:00
|
|
|
}
|
|
|
|
|
2014-05-23 15:46:37 +04:00
|
|
|
static BOOL tsmf_gstreamer_buffer_filled(ITSMFDecoder *decoder)
|
2012-06-13 23:45:58 +04:00
|
|
|
{
|
2014-05-23 15:46:37 +04:00
|
|
|
TSMFGstreamerDecoder *mdecoder = (TSMFGstreamerDecoder *) decoder;
|
|
|
|
DEBUG_TSMF("");
|
2014-05-23 17:35:25 +04:00
|
|
|
|
|
|
|
if (!mdecoder)
|
2014-05-23 15:46:37 +04:00
|
|
|
return FALSE;
|
2014-05-23 17:35:25 +04:00
|
|
|
|
|
|
|
if (!G_IS_OBJECT(mdecoder->queue))
|
2014-05-23 15:46:37 +04:00
|
|
|
return FALSE;
|
2014-05-23 17:35:25 +04:00
|
|
|
|
2014-05-23 15:46:37 +04:00
|
|
|
guint buff_max = 0;
|
|
|
|
g_object_get(mdecoder->queue, "max-size-buffers", &buff_max, NULL);
|
2012-06-13 23:45:58 +04:00
|
|
|
guint clbuff = 0;
|
|
|
|
g_object_get(mdecoder->queue, "current-level-buffers", &clbuff, NULL);
|
2014-05-23 15:46:37 +04:00
|
|
|
DEBUG_TSMF("%s buffer fill %u/%u", get_type(mdecoder), clbuff, buff_max);
|
|
|
|
return clbuff >= buff_max ? TRUE : FALSE;
|
2012-06-13 23:45:58 +04:00
|
|
|
}
|
|
|
|
|
2014-05-23 15:46:37 +04:00
|
|
|
static void tsmf_gstreamer_free(ITSMFDecoder *decoder)
|
2012-06-13 23:45:58 +04:00
|
|
|
{
|
2014-05-23 15:46:37 +04:00
|
|
|
TSMFGstreamerDecoder *mdecoder = (TSMFGstreamerDecoder *) decoder;
|
|
|
|
DEBUG_WARN("%s", get_type(mdecoder));
|
2014-05-23 17:35:25 +04:00
|
|
|
|
|
|
|
if (mdecoder)
|
2012-06-13 23:45:58 +04:00
|
|
|
{
|
|
|
|
mdecoder->shutdown = 1;
|
2014-05-23 15:46:37 +04:00
|
|
|
tsmf_gstreamer_clean_up(mdecoder);
|
2014-05-23 17:35:25 +04:00
|
|
|
|
|
|
|
if (mdecoder->gst_caps)
|
2012-06-13 23:45:58 +04:00
|
|
|
gst_caps_unref(mdecoder->gst_caps);
|
2014-05-23 17:35:25 +04:00
|
|
|
|
2014-05-23 15:46:37 +04:00
|
|
|
tsmf_platform_free(mdecoder);
|
|
|
|
memset(mdecoder, 0, sizeof(TSMFGstreamerDecoder));
|
2012-06-13 23:45:58 +04:00
|
|
|
free(mdecoder);
|
2014-05-23 15:46:37 +04:00
|
|
|
mdecoder = NULL;
|
2012-06-13 23:45:58 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-05-23 15:46:37 +04:00
|
|
|
static UINT64 tsmf_gstreamer_get_running_time(ITSMFDecoder *decoder)
|
2012-06-13 23:45:58 +04:00
|
|
|
{
|
|
|
|
TSMFGstreamerDecoder *mdecoder = (TSMFGstreamerDecoder *) decoder;
|
2014-05-23 17:35:25 +04:00
|
|
|
|
|
|
|
if (!mdecoder)
|
2012-06-13 23:45:58 +04:00
|
|
|
return 0;
|
2014-05-23 17:35:25 +04:00
|
|
|
|
|
|
|
if (!mdecoder->outsink)
|
2012-06-13 23:45:58 +04:00
|
|
|
return mdecoder->last_sample_end_time;
|
2014-05-23 17:35:25 +04:00
|
|
|
|
|
|
|
if (GST_STATE(mdecoder->pipe) != GST_STATE_PLAYING)
|
2012-06-13 23:45:58 +04:00
|
|
|
return 0;
|
2014-05-23 17:35:25 +04:00
|
|
|
|
2012-06-13 23:45:58 +04:00
|
|
|
GstFormat fmt = GST_FORMAT_TIME;
|
|
|
|
gint64 pos = 0;
|
2014-05-25 00:22:33 +04:00
|
|
|
#if GST_VERSION_MAJOR > 0
|
2014-05-23 15:46:37 +04:00
|
|
|
gst_element_query_position(mdecoder->outsink, fmt, &pos);
|
2014-05-25 00:22:33 +04:00
|
|
|
#else
|
2014-05-25 00:23:51 +04:00
|
|
|
gst_element_query_position(mdecoder->outsink, &fmt, &pos);
|
2014-05-25 00:22:33 +04:00
|
|
|
#endif
|
2012-06-13 23:45:58 +04:00
|
|
|
return pos/100;
|
|
|
|
}
|
|
|
|
|
2014-05-23 15:46:37 +04:00
|
|
|
static void tsmf_gstreamer_update_rendering_area(ITSMFDecoder *decoder,
|
|
|
|
int newX, int newY, int newWidth, int newHeight, int numRectangles,
|
|
|
|
RDP_RECT *rectangles)
|
2012-06-13 23:45:58 +04:00
|
|
|
{
|
|
|
|
TSMFGstreamerDecoder *mdecoder = (TSMFGstreamerDecoder *) decoder;
|
2014-05-23 15:46:37 +04:00
|
|
|
DEBUG_TSMF("x=%d, y=%d, w=%d, h=%d, rect=%d", newX, newY, newWidth,
|
|
|
|
newHeight, numRectangles);
|
2014-05-23 17:35:25 +04:00
|
|
|
|
|
|
|
if (mdecoder->media_type == TSMF_MAJOR_TYPE_VIDEO)
|
2014-05-23 15:46:37 +04:00
|
|
|
tsmf_window_resize(mdecoder, newX, newY, newWidth, newHeight,
|
|
|
|
numRectangles, rectangles);
|
|
|
|
}
|
2013-06-19 20:33:46 +04:00
|
|
|
|
2014-05-23 15:46:37 +04:00
|
|
|
BOOL tsmf_gstreamer_ack(ITSMFDecoder *decoder, BOOL (*cb)(void *, BOOL), void *stream)
|
|
|
|
{
|
|
|
|
TSMFGstreamerDecoder *mdecoder = (TSMFGstreamerDecoder *) decoder;
|
|
|
|
DEBUG_TSMF("");
|
|
|
|
mdecoder->ack_cb = cb;
|
|
|
|
mdecoder->stream = stream;
|
|
|
|
return TRUE;
|
2012-06-13 23:45:58 +04:00
|
|
|
}
|
|
|
|
|
2014-05-23 15:46:37 +04:00
|
|
|
BOOL tsmf_gstreamer_sync(ITSMFDecoder *decoder, void (*cb)(void *), void *stream)
|
|
|
|
{
|
|
|
|
TSMFGstreamerDecoder *mdecoder = (TSMFGstreamerDecoder *) decoder;
|
|
|
|
DEBUG_TSMF("");
|
|
|
|
mdecoder->sync_cb = NULL;
|
|
|
|
mdecoder->stream = stream;
|
|
|
|
return TRUE;
|
|
|
|
}
|
2012-06-13 23:45:58 +04:00
|
|
|
|
2012-11-20 07:31:15 +04:00
|
|
|
#ifdef STATIC_CHANNELS
|
|
|
|
#define freerdp_tsmf_client_decoder_subsystem_entry gstreamer_freerdp_tsmf_client_decoder_subsystem_entry
|
|
|
|
#endif
|
|
|
|
|
2014-05-23 15:46:37 +04:00
|
|
|
ITSMFDecoder *freerdp_tsmf_client_decoder_subsystem_entry(void)
|
2012-06-13 23:45:58 +04:00
|
|
|
{
|
2014-05-23 15:46:37 +04:00
|
|
|
TSMFGstreamerDecoder *decoder;
|
2014-05-23 17:35:25 +04:00
|
|
|
|
|
|
|
if (!gst_is_initialized())
|
2012-06-13 23:45:58 +04:00
|
|
|
{
|
2014-05-23 15:46:37 +04:00
|
|
|
gst_init(NULL, NULL);
|
2012-06-13 23:45:58 +04:00
|
|
|
}
|
2014-05-23 17:35:25 +04:00
|
|
|
|
2012-06-13 23:45:58 +04:00
|
|
|
decoder = malloc(sizeof(TSMFGstreamerDecoder));
|
|
|
|
memset(decoder, 0, sizeof(TSMFGstreamerDecoder));
|
|
|
|
decoder->iface.SetFormat = tsmf_gstreamer_set_format;
|
|
|
|
decoder->iface.Decode = NULL;
|
|
|
|
decoder->iface.GetDecodedData = NULL;
|
|
|
|
decoder->iface.GetDecodedFormat = NULL;
|
|
|
|
decoder->iface.GetDecodedDimension = NULL;
|
|
|
|
decoder->iface.GetRunningTime = tsmf_gstreamer_get_running_time;
|
|
|
|
decoder->iface.UpdateRenderingArea = tsmf_gstreamer_update_rendering_area;
|
|
|
|
decoder->iface.Free = tsmf_gstreamer_free;
|
|
|
|
decoder->iface.Control = tsmf_gstreamer_control;
|
|
|
|
decoder->iface.DecodeEx = tsmf_gstreamer_decodeEx;
|
|
|
|
decoder->iface.ChangeVolume = tsmf_gstreamer_change_volume;
|
2014-05-23 15:46:37 +04:00
|
|
|
decoder->iface.BufferFilled = tsmf_gstreamer_buffer_filled;
|
|
|
|
decoder->iface.SetAckFunc = tsmf_gstreamer_ack;
|
|
|
|
decoder->iface.SetSyncFunc = tsmf_gstreamer_sync;
|
2012-06-13 23:45:58 +04:00
|
|
|
decoder->paused = FALSE;
|
2013-06-19 20:33:46 +04:00
|
|
|
decoder->gstVolume = 0.5;
|
2012-06-13 23:45:58 +04:00
|
|
|
decoder->gstMuted = FALSE;
|
|
|
|
decoder->state = GST_STATE_VOID_PENDING; /* No real state yet */
|
2014-05-23 15:46:37 +04:00
|
|
|
tsmf_platform_create(decoder);
|
2012-06-13 23:45:58 +04:00
|
|
|
return (ITSMFDecoder *) decoder;
|
|
|
|
}
|