mirror of
https://github.com/tuxbox-fork-migrations/recycled-ni-libstb-hal.git
synced 2025-08-28 07:50:58 +02:00
Merge remote-tracking branch 'tangocash/master'
Origin commit data
------------------
Branch: master
Commit: 0a0cc742b3
Author: max_10 <max_10@gmx.de>
Date: 2017-10-15 (Sun, 15 Oct 2017)
------------------
No further description and justification available within origin commit message!
------------------
This commit was generated by Migit
This commit is contained in:
@@ -43,6 +43,10 @@
|
|||||||
#define lt_info_c(args...) _lt_info(HAL_DEBUG_PLAYBACK, NULL, args)
|
#define lt_info_c(args...) _lt_info(HAL_DEBUG_PLAYBACK, NULL, args)
|
||||||
|
|
||||||
static const char * FILENAME = "[playback.cpp]";
|
static const char * FILENAME = "[playback.cpp]";
|
||||||
|
extern cVideo * videoDecoder;
|
||||||
|
extern cAudio * audioDecoder;
|
||||||
|
extern cDemux * audioDemux;
|
||||||
|
extern cDemux * videoDemux;
|
||||||
|
|
||||||
#include <gst/gst.h>
|
#include <gst/gst.h>
|
||||||
#include <gst/pbutils/missing-plugins.h>
|
#include <gst/pbutils/missing-plugins.h>
|
||||||
@@ -78,9 +82,10 @@ gint match_sinktype(const GValue *velement, const gchar *type)
|
|||||||
return strcmp(g_type_name(G_OBJECT_TYPE(element)), type);
|
return strcmp(g_type_name(G_OBJECT_TYPE(element)), type);
|
||||||
}
|
}
|
||||||
|
|
||||||
void playbinNotifySource(GObject *object, GParamSpec *unused, gpointer /*user_data*/)
|
void playbinNotifySource(GObject *object, GParamSpec *unused, gpointer user_data)
|
||||||
{
|
{
|
||||||
GstElement *source = NULL;
|
GstElement *source = NULL;
|
||||||
|
cPlayback *_this = (cPlayback*)user_data;
|
||||||
g_object_get(object, "source", &source, NULL);
|
g_object_get(object, "source", &source, NULL);
|
||||||
|
|
||||||
if (source)
|
if (source)
|
||||||
@@ -97,12 +102,60 @@ void playbinNotifySource(GObject *object, GParamSpec *unused, gpointer /*user_da
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (g_object_class_find_property(G_OBJECT_GET_CLASS(source), "ssl-strict") != 0)
|
if (g_object_class_find_property(G_OBJECT_GET_CLASS(source), "ssl-strict") != 0)
|
||||||
{
|
{
|
||||||
g_object_set(G_OBJECT(source), "ssl-strict", FALSE, NULL);
|
g_object_set(G_OBJECT(source), "ssl-strict", FALSE, NULL);
|
||||||
}
|
}
|
||||||
|
if (g_object_class_find_property(G_OBJECT_GET_CLASS(source), "user-agent") != 0 && !_this->user_agent.empty())
|
||||||
|
{
|
||||||
|
g_object_set(G_OBJECT(source), "user-agent", _this->user_agent.c_str(), NULL);
|
||||||
|
}
|
||||||
|
if (g_object_class_find_property(G_OBJECT_GET_CLASS(source), "extra-headers") != 0 && !_this->extra_headers.empty())
|
||||||
|
{
|
||||||
|
GstStructure *extras = gst_structure_new_empty("extras");
|
||||||
|
size_t pos = 0;
|
||||||
|
while (pos != std::string::npos)
|
||||||
|
{
|
||||||
|
std::string name, value;
|
||||||
|
size_t start = pos;
|
||||||
|
size_t len = std::string::npos;
|
||||||
|
pos = _this->extra_headers.find('=', pos);
|
||||||
|
if (pos != std::string::npos)
|
||||||
|
{
|
||||||
|
len = pos - start;
|
||||||
|
pos++;
|
||||||
|
name = _this->extra_headers.substr(start, len);
|
||||||
|
start = pos;
|
||||||
|
len = std::string::npos;
|
||||||
|
pos = _this->extra_headers.find('&', pos);
|
||||||
|
if (pos != std::string::npos)
|
||||||
|
{
|
||||||
|
len = pos - start;
|
||||||
|
pos++;
|
||||||
|
}
|
||||||
|
value = _this->extra_headers.substr(start, len);
|
||||||
|
}
|
||||||
|
if (!name.empty() && !value.empty())
|
||||||
|
{
|
||||||
|
GValue header;
|
||||||
|
lt_info_c( "%s:%s setting extra-header '%s:%s'\n", FILENAME, __FUNCTION__, name.c_str(), value.c_str());
|
||||||
|
memset(&header, 0, sizeof(GValue));
|
||||||
|
g_value_init(&header, G_TYPE_STRING);
|
||||||
|
g_value_set_string(&header, value.c_str());
|
||||||
|
gst_structure_set_value(extras, name.c_str(), &header);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
lt_info_c( "%s:%s Invalid header format %s\n", FILENAME, __FUNCTION__, _this->extra_headers.c_str());
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (gst_structure_n_fields(extras) > 0)
|
||||||
|
{
|
||||||
|
g_object_set(G_OBJECT(source), "extra-headers", extras, NULL);
|
||||||
|
}
|
||||||
|
gst_structure_free(extras);
|
||||||
|
}
|
||||||
gst_object_unref(source);
|
gst_object_unref(source);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -195,7 +248,7 @@ GstBusSyncReply Gst_bus_call(GstBus * bus, GstMessage *msg, gpointer user_data)
|
|||||||
int ret = write(fd, Info.data, Info.size);
|
int ret = write(fd, Info.data, Info.size);
|
||||||
close(fd);
|
close(fd);
|
||||||
gst_buffer_unmap(buf_image, &Info);
|
gst_buffer_unmap(buf_image, &Info);
|
||||||
lt_info_c( "%s:%s - GST_MESSAGE_INFO: cPlayback::state /tmp/.id3coverart %d bytes written\n", FILENAME, __FUNCTION__ , ret);
|
lt_info_c( "%s:%s - GST_MESSAGE_INFO: cPlayback::state /tmp/.id3coverart %d bytes written\n", FILENAME, __FUNCTION__, ret);
|
||||||
}
|
}
|
||||||
//FIXME: how shall playback handle this event???
|
//FIXME: how shall playback handle this event???
|
||||||
}
|
}
|
||||||
@@ -222,8 +275,7 @@ GstBusSyncReply Gst_bus_call(GstBus * bus, GstMessage *msg, gpointer user_data)
|
|||||||
{
|
{
|
||||||
case GST_STATE_CHANGE_NULL_TO_READY:
|
case GST_STATE_CHANGE_NULL_TO_READY:
|
||||||
{
|
{
|
||||||
}
|
} break;
|
||||||
break;
|
|
||||||
case GST_STATE_CHANGE_READY_TO_PAUSED:
|
case GST_STATE_CHANGE_READY_TO_PAUSED:
|
||||||
{
|
{
|
||||||
GstIterator *children;
|
GstIterator *children;
|
||||||
@@ -240,8 +292,6 @@ GstBusSyncReply Gst_bus_call(GstBus * bus, GstMessage *msg, gpointer user_data)
|
|||||||
gst_object_unref(GST_OBJECT(videoSink));
|
gst_object_unref(GST_OBJECT(videoSink));
|
||||||
videoSink = NULL;
|
videoSink = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
// set audio sink
|
|
||||||
children = gst_bin_iterate_recurse(GST_BIN(m_gst_playbin));
|
children = gst_bin_iterate_recurse(GST_BIN(m_gst_playbin));
|
||||||
|
|
||||||
if (gst_iterator_find_custom(children, (GCompareFunc)match_sinktype, &r, (gpointer)"GstDVBAudioSink"))
|
if (gst_iterator_find_custom(children, (GCompareFunc)match_sinktype, &r, (gpointer)"GstDVBAudioSink"))
|
||||||
@@ -252,8 +302,6 @@ GstBusSyncReply Gst_bus_call(GstBus * bus, GstMessage *msg, gpointer user_data)
|
|||||||
}
|
}
|
||||||
|
|
||||||
gst_iterator_free(children);
|
gst_iterator_free(children);
|
||||||
|
|
||||||
// set video sink
|
|
||||||
children = gst_bin_iterate_recurse(GST_BIN(m_gst_playbin));
|
children = gst_bin_iterate_recurse(GST_BIN(m_gst_playbin));
|
||||||
|
|
||||||
if (gst_iterator_find_custom(children, (GCompareFunc)match_sinktype, &r, (gpointer)"GstDVBVideoSink"))
|
if (gst_iterator_find_custom(children, (GCompareFunc)match_sinktype, &r, (gpointer)"GstDVBVideoSink"))
|
||||||
@@ -262,21 +310,16 @@ GstBusSyncReply Gst_bus_call(GstBus * bus, GstMessage *msg, gpointer user_data)
|
|||||||
g_value_unset (&r);
|
g_value_unset (&r);
|
||||||
lt_info_c( "%s %s - video sink created\n", FILENAME, __FUNCTION__);
|
lt_info_c( "%s %s - video sink created\n", FILENAME, __FUNCTION__);
|
||||||
}
|
}
|
||||||
|
|
||||||
gst_iterator_free(children);
|
gst_iterator_free(children);
|
||||||
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case GST_STATE_CHANGE_PAUSED_TO_PLAYING:
|
case GST_STATE_CHANGE_PAUSED_TO_PLAYING:
|
||||||
{
|
{
|
||||||
}
|
} break;
|
||||||
break;
|
|
||||||
|
|
||||||
case GST_STATE_CHANGE_PLAYING_TO_PAUSED:
|
case GST_STATE_CHANGE_PLAYING_TO_PAUSED:
|
||||||
{
|
{
|
||||||
}
|
} break;
|
||||||
break;
|
|
||||||
|
|
||||||
case GST_STATE_CHANGE_PAUSED_TO_READY:
|
case GST_STATE_CHANGE_PAUSED_TO_READY:
|
||||||
{
|
{
|
||||||
if (audioSink)
|
if (audioSink)
|
||||||
@@ -291,11 +334,9 @@ GstBusSyncReply Gst_bus_call(GstBus * bus, GstMessage *msg, gpointer user_data)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case GST_STATE_CHANGE_READY_TO_NULL:
|
case GST_STATE_CHANGE_READY_TO_NULL:
|
||||||
{
|
{
|
||||||
}
|
} break;
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -307,13 +348,13 @@ GstBusSyncReply Gst_bus_call(GstBus * bus, GstMessage *msg, gpointer user_data)
|
|||||||
return GST_BUS_DROP;
|
return GST_BUS_DROP;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
cPlayback::cPlayback(int num)
|
cPlayback::cPlayback(int num)
|
||||||
{
|
{
|
||||||
lt_info( "%s:%s\n", FILENAME, __FUNCTION__);
|
lt_info( "%s:%s\n", FILENAME, __FUNCTION__);
|
||||||
const gchar *nano_str;
|
const gchar *nano_str;
|
||||||
guint major, minor, micro, nano;
|
guint major, minor, micro, nano;
|
||||||
|
|
||||||
/* init gstreamer */
|
|
||||||
gst_init(NULL, NULL);
|
gst_init(NULL, NULL);
|
||||||
|
|
||||||
gst_version (&major, &minor, µ, &nano);
|
gst_version (&major, &minor, µ, &nano);
|
||||||
@@ -336,7 +377,6 @@ cPlayback::cPlayback(int num)
|
|||||||
playstate = STATE_STOP;
|
playstate = STATE_STOP;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* called at housekepping */
|
|
||||||
cPlayback::~cPlayback()
|
cPlayback::~cPlayback()
|
||||||
{
|
{
|
||||||
lt_info( "%s:%s\n", FILENAME, __FUNCTION__);
|
lt_info( "%s:%s\n", FILENAME, __FUNCTION__);
|
||||||
@@ -394,7 +434,14 @@ void cPlayback::Close(void)
|
|||||||
lt_info( "%s:%s - GST playbin closed\n", FILENAME, __FUNCTION__);
|
lt_info( "%s:%s - GST playbin closed\n", FILENAME, __FUNCTION__);
|
||||||
|
|
||||||
m_gst_playbin = NULL;
|
m_gst_playbin = NULL;
|
||||||
|
|
||||||
|
videoDecoder->openDevice();
|
||||||
|
audioDecoder->openDevice();
|
||||||
|
|
||||||
|
videoDemux->Start();
|
||||||
|
audioDemux->Start();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// start
|
// start
|
||||||
@@ -407,6 +454,11 @@ bool cPlayback::Start(char *filename, int /*vpid*/, int /*vtype*/, int /*apid*/,
|
|||||||
{
|
{
|
||||||
lt_info( "%s:%s\n", FILENAME, __FUNCTION__);
|
lt_info( "%s:%s\n", FILENAME, __FUNCTION__);
|
||||||
|
|
||||||
|
if (!headers.empty())
|
||||||
|
extra_headers = headers;
|
||||||
|
else
|
||||||
|
extra_headers.clear();
|
||||||
|
|
||||||
mAudioStream = 0;
|
mAudioStream = 0;
|
||||||
|
|
||||||
//create playback path
|
//create playback path
|
||||||
@@ -464,11 +516,18 @@ bool cPlayback::Start(char *filename, int /*vpid*/, int /*vtype*/, int /*apid*/,
|
|||||||
|
|
||||||
if(m_gst_playbin)
|
if(m_gst_playbin)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
videoDemux->Stop();
|
||||||
|
audioDemux->Stop();
|
||||||
|
|
||||||
|
videoDecoder->closeDevice();
|
||||||
|
audioDecoder->closeDevice();
|
||||||
|
|
||||||
lt_info("%s:%s - m_gst_playbin\n", FILENAME, __FUNCTION__);
|
lt_info("%s:%s - m_gst_playbin\n", FILENAME, __FUNCTION__);
|
||||||
|
|
||||||
if(isHTTP)
|
if(isHTTP)
|
||||||
{
|
{
|
||||||
g_signal_connect (G_OBJECT (m_gst_playbin), "notify::source", G_CALLBACK (playbinNotifySource), NULL);
|
g_signal_connect (G_OBJECT (m_gst_playbin), "notify::source", G_CALLBACK (playbinNotifySource), this);
|
||||||
|
|
||||||
// set buffer size
|
// set buffer size
|
||||||
g_object_set(G_OBJECT(m_gst_playbin), "buffer-size", m_buffer_size, NULL);
|
g_object_set(G_OBJECT(m_gst_playbin), "buffer-size", m_buffer_size, NULL);
|
||||||
@@ -476,14 +535,12 @@ bool cPlayback::Start(char *filename, int /*vpid*/, int /*vtype*/, int /*apid*/,
|
|||||||
flags |= GST_PLAY_FLAG_BUFFERING;
|
flags |= GST_PLAY_FLAG_BUFFERING;
|
||||||
}
|
}
|
||||||
|
|
||||||
// set flags
|
|
||||||
g_object_set(G_OBJECT (m_gst_playbin), "flags", flags, NULL);
|
g_object_set(G_OBJECT (m_gst_playbin), "flags", flags, NULL);
|
||||||
|
|
||||||
// set uri
|
|
||||||
g_object_set(G_OBJECT (m_gst_playbin), "uri", uri, NULL);
|
g_object_set(G_OBJECT (m_gst_playbin), "uri", uri, NULL);
|
||||||
|
|
||||||
//gstbus handler
|
//gstbus handler
|
||||||
GstBus * bus = gst_pipeline_get_bus(GST_PIPELINE(m_gst_playbin));
|
GstBus * bus = gst_pipeline_get_bus( GST_PIPELINE(m_gst_playbin) );
|
||||||
gst_bus_set_sync_handler(bus, Gst_bus_call, NULL, NULL);
|
gst_bus_set_sync_handler(bus, Gst_bus_call, NULL, NULL);
|
||||||
gst_object_unref(bus);
|
gst_object_unref(bus);
|
||||||
|
|
||||||
@@ -529,7 +586,6 @@ bool cPlayback::Stop(void)
|
|||||||
{
|
{
|
||||||
if(playing == false)
|
if(playing == false)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
lt_info( "%s:%s playing %d\n", FILENAME, __FUNCTION__, playing);
|
lt_info( "%s:%s playing %d\n", FILENAME, __FUNCTION__, playing);
|
||||||
|
|
||||||
// stop
|
// stop
|
||||||
@@ -547,7 +603,7 @@ bool cPlayback::Stop(void)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool cPlayback::SetAPid(int pid , bool /*ac3*/)
|
bool cPlayback::SetAPid(int pid, bool /*ac3*/)
|
||||||
{
|
{
|
||||||
lt_info("%s: pid %i\n", __func__, pid);
|
lt_info("%s: pid %i\n", __func__, pid);
|
||||||
|
|
||||||
@@ -711,12 +767,15 @@ bool cPlayback::SetPosition(int position, bool absolute)
|
|||||||
|
|
||||||
if(m_gst_playbin)
|
if(m_gst_playbin)
|
||||||
{
|
{
|
||||||
if (!absolute) {
|
if (!absolute)
|
||||||
|
{
|
||||||
gst_element_query_position(m_gst_playbin, fmt, &pos);
|
gst_element_query_position(m_gst_playbin, fmt, &pos);
|
||||||
time_nanoseconds = pos + (position * 1000000.0);
|
time_nanoseconds = pos + (position * 1000000.0);
|
||||||
if(time_nanoseconds < 0)
|
if(time_nanoseconds < 0)
|
||||||
time_nanoseconds = 0;
|
time_nanoseconds = 0;
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
time_nanoseconds = position * 1000000.0;
|
time_nanoseconds = position * 1000000.0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -745,7 +804,7 @@ void cPlayback::FindAllPids(int *apids, unsigned int *ac3flags, unsigned int *nu
|
|||||||
for (i = 0; i < n_audio; i++)
|
for (i = 0; i < n_audio; i++)
|
||||||
{
|
{
|
||||||
// apids
|
// apids
|
||||||
apids[i] = i;
|
apids[i]=i;
|
||||||
|
|
||||||
GstPad * pad = 0;
|
GstPad * pad = 0;
|
||||||
g_signal_emit_by_name (m_gst_playbin, "get-audio-pad", i, &pad);
|
g_signal_emit_by_name (m_gst_playbin, "get-audio-pad", i, &pad);
|
||||||
@@ -809,7 +868,7 @@ void cPlayback::FindAllPids(int *apids, unsigned int *ac3flags, unsigned int *nu
|
|||||||
}
|
}
|
||||||
|
|
||||||
// numpids
|
// numpids
|
||||||
*numpida = i;
|
*numpida=i;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -823,7 +882,7 @@ bool cPlayback::SyncAV(void)
|
|||||||
{
|
{
|
||||||
lt_info( "%s:%s playing %d\n", FILENAME, __FUNCTION__, playing);
|
lt_info( "%s:%s playing %d\n", FILENAME, __FUNCTION__, playing);
|
||||||
|
|
||||||
if(playing == false)
|
if(playing == false )
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
@@ -26,7 +26,8 @@
|
|||||||
#include <config.h>
|
#include <config.h>
|
||||||
|
|
||||||
|
|
||||||
typedef enum {
|
typedef enum
|
||||||
|
{
|
||||||
STATE_STOP,
|
STATE_STOP,
|
||||||
STATE_PLAY,
|
STATE_PLAY,
|
||||||
STATE_PAUSE,
|
STATE_PAUSE,
|
||||||
@@ -35,7 +36,8 @@ typedef enum {
|
|||||||
STATE_SLOW
|
STATE_SLOW
|
||||||
} playstate_t;
|
} playstate_t;
|
||||||
|
|
||||||
typedef enum {
|
typedef enum
|
||||||
|
{
|
||||||
PLAYMODE_TS = 0,
|
PLAYMODE_TS = 0,
|
||||||
PLAYMODE_FILE,
|
PLAYMODE_FILE,
|
||||||
} playmode_t;
|
} playmode_t;
|
||||||
@@ -44,13 +46,13 @@ struct AVFormatContext;
|
|||||||
|
|
||||||
class cPlayback
|
class cPlayback
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
bool playing;
|
bool playing;
|
||||||
|
|
||||||
int mSpeed;
|
int mSpeed;
|
||||||
int mAudioStream;
|
int mAudioStream;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
playstate_t playstate;
|
playstate_t playstate;
|
||||||
|
|
||||||
cPlayback(int);
|
cPlayback(int);
|
||||||
@@ -87,6 +89,8 @@ class cPlayback
|
|||||||
void GetMetadata(std::vector<std::string> &keys, std::vector<std::string> &values);
|
void GetMetadata(std::vector<std::string> &keys, std::vector<std::string> &values);
|
||||||
AVFormatContext *GetAVFormatContext();
|
AVFormatContext *GetAVFormatContext();
|
||||||
void ReleaseAVFormatContext();
|
void ReleaseAVFormatContext();
|
||||||
|
std::string extra_headers;
|
||||||
|
std::string user_agent;
|
||||||
|
|
||||||
//
|
//
|
||||||
~cPlayback();
|
~cPlayback();
|
||||||
|
Reference in New Issue
Block a user