3 /* note: this requires gstreamer 0.10.x and a big list of plugins. */
4 /* it's currently hardcoded to use a big-endian alsasink as sink. */
5 #include <lib/base/ebase.h>
6 #include <lib/base/eerror.h>
7 #include <lib/base/init_num.h>
8 #include <lib/base/init.h>
9 #include <lib/base/nconfig.h>
10 #include <lib/base/object.h>
11 #include <lib/dvb/decoder.h>
12 #include <lib/components/file_eraser.h>
13 #include <lib/gui/esubtitle.h>
14 #include <lib/service/servicemp3.h>
15 #include <lib/service/service.h>
20 #include <gst/pbutils/missing-plugins.h>
23 #define HTTP_TIMEOUT 10
27 eServiceFactoryMP3::eServiceFactoryMP3()
29 ePtr<eServiceCenter> sc;
31 eServiceCenter::getPrivInstance(sc);
34 std::list<std::string> extensions;
35 extensions.push_back("mp2");
36 extensions.push_back("mp3");
37 extensions.push_back("ogg");
38 extensions.push_back("mpg");
39 extensions.push_back("vob");
40 extensions.push_back("wav");
41 extensions.push_back("wave");
42 extensions.push_back("m4v");
43 extensions.push_back("mkv");
44 extensions.push_back("avi");
45 extensions.push_back("divx");
46 extensions.push_back("dat");
47 extensions.push_back("flac");
48 extensions.push_back("mp4");
49 extensions.push_back("mov");
50 extensions.push_back("m4a");
51 extensions.push_back("m2ts");
52 sc->addServiceFactory(eServiceFactoryMP3::id, this, extensions);
55 m_service_info = new eStaticServiceMP3Info();
58 eServiceFactoryMP3::~eServiceFactoryMP3()
60 ePtr<eServiceCenter> sc;
62 eServiceCenter::getPrivInstance(sc);
64 sc->removeServiceFactory(eServiceFactoryMP3::id);
67 DEFINE_REF(eServiceFactoryMP3)
70 RESULT eServiceFactoryMP3::play(const eServiceReference &ref, ePtr<iPlayableService> &ptr)
73 ptr = new eServiceMP3(ref);
77 RESULT eServiceFactoryMP3::record(const eServiceReference &ref, ePtr<iRecordableService> &ptr)
83 RESULT eServiceFactoryMP3::list(const eServiceReference &, ePtr<iListableService> &ptr)
89 RESULT eServiceFactoryMP3::info(const eServiceReference &ref, ePtr<iStaticServiceInformation> &ptr)
95 class eMP3ServiceOfflineOperations: public iServiceOfflineOperations
97 DECLARE_REF(eMP3ServiceOfflineOperations);
98 eServiceReference m_ref;
100 eMP3ServiceOfflineOperations(const eServiceReference &ref);
102 RESULT deleteFromDisk(int simulate);
103 RESULT getListOfFilenames(std::list<std::string> &);
107 DEFINE_REF(eMP3ServiceOfflineOperations);
109 eMP3ServiceOfflineOperations::eMP3ServiceOfflineOperations(const eServiceReference &ref): m_ref((const eServiceReference&)ref)
113 RESULT eMP3ServiceOfflineOperations::deleteFromDisk(int simulate)
119 std::list<std::string> res;
120 if (getListOfFilenames(res))
123 eBackgroundFileEraser *eraser = eBackgroundFileEraser::getInstance();
125 eDebug("FATAL !! can't get background file eraser");
127 for (std::list<std::string>::iterator i(res.begin()); i != res.end(); ++i)
129 eDebug("Removing %s...", i->c_str());
131 eraser->erase(i->c_str());
133 ::unlink(i->c_str());
140 RESULT eMP3ServiceOfflineOperations::getListOfFilenames(std::list<std::string> &res)
143 res.push_back(m_ref.path);
147 RESULT eMP3ServiceOfflineOperations::reindex()
153 RESULT eServiceFactoryMP3::offlineOperations(const eServiceReference &ref, ePtr<iServiceOfflineOperations> &ptr)
155 ptr = new eMP3ServiceOfflineOperations(ref);
159 // eStaticServiceMP3Info
162 // eStaticServiceMP3Info is seperated from eServiceMP3 to give information
163 // about unopened files.
165 // probably eServiceMP3 should use this class as well, and eStaticServiceMP3Info
166 // should have a database backend where ID3-files etc. are cached.
167 // this would allow listing the mp3 database based on certain filters.
169 DEFINE_REF(eStaticServiceMP3Info)
171 eStaticServiceMP3Info::eStaticServiceMP3Info()
175 RESULT eStaticServiceMP3Info::getName(const eServiceReference &ref, std::string &name)
177 if ( ref.name.length() )
181 size_t last = ref.path.rfind('/');
182 if (last != std::string::npos)
183 name = ref.path.substr(last+1);
190 int eStaticServiceMP3Info::getLength(const eServiceReference &ref)
195 int eStaticServiceMP3Info::getInfo(const eServiceReference &ref, int w)
199 case iServiceInformation::sTimeCreate:
202 if(stat(ref.path.c_str(), &s) == 0)
206 return iServiceInformation::resNA;
210 return iServiceInformation::resNA;
215 int eServiceMP3::ac3_delay,
216 eServiceMP3::pcm_delay;
218 eServiceMP3::eServiceMP3(eServiceReference ref)
219 :m_ref(ref), m_pump(eApp, 1)
221 m_seekTimeout = eTimer::create(eApp);
222 m_subtitle_sync_timer = eTimer::create(eApp);
223 m_streamingsrc_timeout = 0;
225 m_currentAudioStream = -1;
226 m_currentSubtitleStream = 0;
227 m_subtitle_widget = 0;
228 m_currentTrickRatio = 0;
230 m_buffer_size = 1*1024*1024;
231 CONNECT(m_seekTimeout->timeout, eServiceMP3::seekTimeoutCB);
232 CONNECT(m_subtitle_sync_timer->timeout, eServiceMP3::pushSubtitles);
233 CONNECT(m_pump.recv_msg, eServiceMP3::gstPoll);
234 m_aspect = m_width = m_height = m_framerate = m_progressive = -1;
237 eDebug("eServiceMP3::construct!");
239 const char *filename = m_ref.path.c_str();
240 const char *ext = strrchr(filename, '.');
244 m_sourceinfo.is_video = FALSE;
245 m_sourceinfo.audiotype = atUnknown;
246 if ( (strcasecmp(ext, ".mpeg") && strcasecmp(ext, ".mpg") && strcasecmp(ext, ".vob") && strcasecmp(ext, ".bin") && strcasecmp(ext, ".dat") ) == 0 )
248 m_sourceinfo.containertype = ctMPEGPS;
249 m_sourceinfo.is_video = TRUE;
251 else if ( strcasecmp(ext, ".ts") == 0 )
253 m_sourceinfo.containertype = ctMPEGTS;
254 m_sourceinfo.is_video = TRUE;
256 else if ( strcasecmp(ext, ".mkv") == 0 )
258 m_sourceinfo.containertype = ctMKV;
259 m_sourceinfo.is_video = TRUE;
261 else if ( strcasecmp(ext, ".avi") == 0 || strcasecmp(ext, ".divx") == 0)
263 m_sourceinfo.containertype = ctAVI;
264 m_sourceinfo.is_video = TRUE;
266 else if ( strcasecmp(ext, ".mp4") == 0 || strcasecmp(ext, ".mov") == 0 || strcasecmp(ext, ".m4v") == 0)
268 m_sourceinfo.containertype = ctMP4;
269 m_sourceinfo.is_video = TRUE;
271 else if ( strcasecmp(ext, ".m4a") == 0 )
273 m_sourceinfo.containertype = ctMP4;
274 m_sourceinfo.audiotype = atAAC;
276 else if ( strcasecmp(ext, ".mp3") == 0 )
277 m_sourceinfo.audiotype = atMP3;
278 else if ( (strncmp(filename, "/autofs/", 8) || strncmp(filename+strlen(filename)-13, "/track-", 7) || strcasecmp(ext, ".wav")) == 0 )
279 m_sourceinfo.containertype = ctCDA;
280 if ( strcasecmp(ext, ".dat") == 0 )
282 m_sourceinfo.containertype = ctVCD;
283 m_sourceinfo.is_video = TRUE;
285 if ( (strncmp(filename, "http://", 7)) == 0 || (strncmp(filename, "udp://", 6)) == 0 || (strncmp(filename, "rtp://", 6)) == 0 || (strncmp(filename, "https://", 8)) == 0 || (strncmp(filename, "mms://", 6)) == 0 || (strncmp(filename, "rtsp://", 7)) == 0 || (strncmp(filename, "rtspt://", 7)) == 0 )
286 m_sourceinfo.is_streaming = TRUE;
290 if ( m_sourceinfo.is_streaming )
292 uri = g_strdup_printf ("%s", filename);
293 m_streamingsrc_timeout = eTimer::create(eApp);;
294 CONNECT(m_streamingsrc_timeout->timeout, eServiceMP3::sourceTimeout);
296 std::string config_str;
297 if( ePythonConfigQuery::getConfigValue("config.mediaplayer.useAlternateUserAgent", config_str) == 0 )
299 if ( config_str == "True" )
300 ePythonConfigQuery::getConfigValue("config.mediaplayer.alternateUserAgent", m_useragent);
302 if ( m_useragent.length() == 0 )
303 m_useragent = "Dream Multimedia Dreambox Enigma2 Mediaplayer";
305 else if ( m_sourceinfo.containertype == ctCDA )
307 int i_track = atoi(filename+18);
308 uri = g_strdup_printf ("cdda://%i", i_track);
310 else if ( m_sourceinfo.containertype == ctVCD )
312 int fd = open(filename,O_RDONLY);
314 int ret = read(fd, tmp, 128*1024);
316 if ( ret == -1 ) // this is a "REAL" VCD
317 uri = g_strdup_printf ("vcd://");
319 uri = g_filename_to_uri(filename, NULL, NULL);
323 uri = g_filename_to_uri(filename, NULL, NULL);
325 eDebug("eServiceMP3::playbin2 uri=%s", uri);
327 m_gst_playbin = gst_element_factory_make("playbin2", "playbin");
329 m_error_message = "failed to create GStreamer pipeline!\n";
331 g_object_set (G_OBJECT (m_gst_playbin), "uri", uri, NULL);
333 int flags = 0x47; // ( == GST_PLAY_FLAG_VIDEO | GST_PLAY_FLAG_AUDIO | GST_PLAY_FLAG_NATIVE_VIDEO | GST_PLAY_FLAG_TEXT )
334 g_object_set (G_OBJECT (m_gst_playbin), "flags", flags, NULL);
338 GstElement *subsink = gst_element_factory_make("appsink", "subtitle_sink");
340 eDebug("eServiceMP3::sorry, can't play: missing gst-plugin-appsink");
343 m_subs_to_pull_handler_id = g_signal_connect (subsink, "new-buffer", G_CALLBACK (gstCBsubtitleAvail), this);
344 g_object_set (G_OBJECT (subsink), "caps", gst_caps_from_string("text/plain; text/x-plain; text/x-pango-markup"), NULL);
345 g_object_set (G_OBJECT (m_gst_playbin), "text-sink", subsink, NULL);
350 gst_bus_set_sync_handler(gst_pipeline_get_bus (GST_PIPELINE (m_gst_playbin)), gstBusSyncHandler, this);
351 char srt_filename[strlen(filename)+1];
352 strncpy(srt_filename,filename,strlen(filename)-3);
353 srt_filename[strlen(filename)-3]='\0';
354 strcat(srt_filename, "srt");
356 if (stat(srt_filename, &buffer) == 0)
358 eDebug("eServiceMP3::subtitle uri: %s", g_filename_to_uri(srt_filename, NULL, NULL));
359 g_object_set (G_OBJECT (m_gst_playbin), "suburi", g_filename_to_uri(srt_filename, NULL, NULL), NULL);
362 subs.language_code = std::string("und");
363 m_subtitleStreams.push_back(subs);
365 if ( m_sourceinfo.is_streaming )
367 g_signal_connect (G_OBJECT (m_gst_playbin), "notify::source", G_CALLBACK (gstHTTPSourceSetAgent), this);
371 m_event((iPlayableService*)this, evUser+12);
374 gst_object_unref(GST_OBJECT(m_gst_playbin));
376 eDebug("eServiceMP3::sorry, can't play: %s",m_error_message.c_str());
380 setBufferSize(m_buffer_size);
383 eServiceMP3::~eServiceMP3()
385 // disconnect subtitle callback
387 g_object_get (G_OBJECT (m_gst_playbin), "text-sink", &sink, NULL);
390 g_signal_handler_disconnect (sink, m_subs_to_pull_handler_id);
391 gst_object_unref(sink);
394 delete m_subtitle_widget;
396 // disconnect sync handler callback
397 gst_bus_set_sync_handler(gst_pipeline_get_bus (GST_PIPELINE (m_gst_playbin)), NULL, NULL);
399 if (m_state == stRunning)
403 gst_tag_list_free(m_stream_tags);
407 gst_object_unref (GST_OBJECT (m_gst_playbin));
408 eDebug("eServiceMP3::destruct!");
412 DEFINE_REF(eServiceMP3);
414 RESULT eServiceMP3::connectEvent(const Slot2<void,iPlayableService*,int> &event, ePtr<eConnection> &connection)
416 connection = new eConnection((iPlayableService*)this, m_event.connect(event));
420 RESULT eServiceMP3::start()
422 ASSERT(m_state == stIdle);
427 eDebug("eServiceMP3::starting pipeline");
428 gst_element_set_state (m_gst_playbin, GST_STATE_PLAYING);
431 m_event(this, evStart);
436 void eServiceMP3::sourceTimeout()
438 eDebug("eServiceMP3::http source timeout! issuing eof...");
439 m_event((iPlayableService*)this, evEOF);
442 RESULT eServiceMP3::stop()
444 ASSERT(m_state != stIdle);
446 if (m_state == stStopped)
449 eDebug("eServiceMP3::stop %s", m_ref.path.c_str());
450 gst_element_set_state(m_gst_playbin, GST_STATE_NULL);
456 RESULT eServiceMP3::setTarget(int target)
461 RESULT eServiceMP3::pause(ePtr<iPauseableService> &ptr)
467 RESULT eServiceMP3::setSlowMotion(int ratio)
471 eDebug("eServiceMP3::setSlowMotion ratio=%f",1/(float)ratio);
472 return trickSeek(1/(float)ratio);
475 RESULT eServiceMP3::setFastForward(int ratio)
477 eDebug("eServiceMP3::setFastForward ratio=%i",ratio);
478 return trickSeek(ratio);
481 void eServiceMP3::seekTimeoutCB()
484 getPlayPosition(ppos);
486 ppos += 90000*m_currentTrickRatio;
491 m_seekTimeout->stop();
497 m_seekTimeout->stop();
504 RESULT eServiceMP3::pause()
506 if (!m_gst_playbin || m_state != stRunning)
509 gst_element_set_state(m_gst_playbin, GST_STATE_PAUSED);
514 RESULT eServiceMP3::unpause()
516 if (!m_gst_playbin || m_state != stRunning)
519 gst_element_set_state(m_gst_playbin, GST_STATE_PLAYING);
524 /* iSeekableService */
525 RESULT eServiceMP3::seek(ePtr<iSeekableService> &ptr)
531 RESULT eServiceMP3::getLength(pts_t &pts)
536 if (m_state != stRunning)
539 GstFormat fmt = GST_FORMAT_TIME;
542 if (!gst_element_query_duration(m_gst_playbin, &fmt, &len))
544 /* len is in nanoseconds. we have 90 000 pts per second. */
550 RESULT eServiceMP3::seekToImpl(pts_t to)
552 /* convert pts to nanoseconds */
553 gint64 time_nanoseconds = to * 11111LL;
554 if (!gst_element_seek (m_gst_playbin, 1.0, GST_FORMAT_TIME, GST_SEEK_FLAG_FLUSH,
555 GST_SEEK_TYPE_SET, time_nanoseconds,
556 GST_SEEK_TYPE_NONE, GST_CLOCK_TIME_NONE))
558 eDebug("eServiceMP3::seekTo failed");
565 RESULT eServiceMP3::seekTo(pts_t to)
570 eSingleLocker l(m_subs_to_pull_lock); // this is needed to dont handle incomming subtitles during seek!
571 if (!(ret = seekToImpl(to)))
573 m_subtitle_pages.clear();
582 RESULT eServiceMP3::trickSeek(gdouble ratio)
587 return seekRelative(0, 0);
591 flags = GST_SEEK_FLAG_NONE;
592 flags |= GST_SEEK_FLAG_FLUSH;
593 // flags |= GstSeekFlags (GST_SEEK_FLAG_ACCURATE);
594 flags |= GST_SEEK_FLAG_KEY_UNIT;
595 // flags |= GstSeekFlags (GST_SEEK_FLAG_SEGMENT);
596 // flags |= GstSeekFlags (GST_SEEK_FLAG_SKIP);
598 GstFormat fmt = GST_FORMAT_TIME;
600 gst_element_query_duration(m_gst_playbin, &fmt, &len);
601 gst_element_query_position(m_gst_playbin, &fmt, &pos);
605 s_event = gst_event_new_seek (ratio, GST_FORMAT_TIME, (GstSeekFlags)flags, GST_SEEK_TYPE_SET, pos, GST_SEEK_TYPE_SET, len);
607 eDebug("eServiceMP3::trickSeek with rate %lf to %" GST_TIME_FORMAT " ", ratio, GST_TIME_ARGS (pos));
611 s_event = gst_event_new_seek (ratio, GST_FORMAT_TIME, (GstSeekFlags)(GST_SEEK_FLAG_SKIP|GST_SEEK_FLAG_FLUSH), GST_SEEK_TYPE_NONE, -1, GST_SEEK_TYPE_NONE, -1);
614 if (!gst_element_send_event ( GST_ELEMENT (m_gst_playbin), s_event))
616 eDebug("eServiceMP3::trickSeek failed");
624 RESULT eServiceMP3::seekRelative(int direction, pts_t to)
630 getPlayPosition(ppos);
631 ppos += to * direction;
639 RESULT eServiceMP3::getPlayPosition(pts_t &pts)
641 GstFormat fmt = GST_FORMAT_TIME;
648 if (m_state != stRunning)
651 g_object_get (G_OBJECT (m_gst_playbin), "audio-sink", &sink, NULL);
654 g_object_get (G_OBJECT (m_gst_playbin), "video-sink", &sink, NULL);
659 gchar *name = gst_element_get_name(sink);
660 gboolean use_get_decoder_time = strstr(name, "dvbaudiosink") || strstr(name, "dvbvideosink");
663 if (use_get_decoder_time)
664 g_signal_emit_by_name(sink, "get-decoder-time", &pos);
666 gst_object_unref(sink);
668 if (!use_get_decoder_time && !gst_element_query_position(m_gst_playbin, &fmt, &pos)) {
669 eDebug("gst_element_query_position failed in getPlayPosition");
673 /* pos is in nanoseconds. we have 90 000 pts per second. */
678 RESULT eServiceMP3::setTrickmode(int trick)
680 /* trickmode is not yet supported by our dvbmediasinks. */
684 RESULT eServiceMP3::isCurrentlySeekable()
686 int ret = 3; // seeking and fast/slow winding possible
691 if (m_state != stRunning)
694 g_object_get (G_OBJECT (m_gst_playbin), "video-sink", &sink, NULL);
696 // disable fast winding yet when a dvbvideosink or dvbaudiosink is used
697 // for this we must do some changes on different places.. (gstreamer.. our sinks.. enigma2)
699 ret &= ~2; // only seeking possible
700 gst_object_unref(sink);
703 g_object_get (G_OBJECT (m_gst_playbin), "audio-sink", &sink, NULL);
705 ret &= ~2; // only seeking possible
706 gst_object_unref(sink);
713 RESULT eServiceMP3::info(ePtr<iServiceInformation>&i)
719 RESULT eServiceMP3::getName(std::string &name)
721 std::string title = m_ref.getName();
725 size_t n = name.rfind('/');
726 if (n != std::string::npos)
727 name = name.substr(n + 1);
734 int eServiceMP3::getInfo(int w)
736 const gchar *tag = 0;
740 case sServiceref: return m_ref;
741 case sVideoHeight: return m_height;
742 case sVideoWidth: return m_width;
743 case sFrameRate: return m_framerate;
744 case sProgressive: return m_progressive;
745 case sAspect: return m_aspect;
749 case sTagTitleSortname:
750 case sTagArtistSortname:
751 case sTagAlbumSortname:
756 case sTagExtendedComment:
759 case sTagDescription:
762 case sTagOrganization:
764 case sTagCopyrightURI:
772 case sTagLanguageCode:
774 case sTagChannelMode:
781 case sTagReferenceLevel:
782 case sTagBeatsPerMinute:
784 case sTagPreviewImage:
786 return resIsPyObject;
787 case sTagTrackNumber:
788 tag = GST_TAG_TRACK_NUMBER;
791 tag = GST_TAG_TRACK_COUNT;
793 case sTagAlbumVolumeNumber:
794 tag = GST_TAG_ALBUM_VOLUME_NUMBER;
796 case sTagAlbumVolumeCount:
797 tag = GST_TAG_ALBUM_VOLUME_COUNT;
800 tag = GST_TAG_BITRATE;
802 case sTagNominalBitrate:
803 tag = GST_TAG_NOMINAL_BITRATE;
805 case sTagMinimumBitrate:
806 tag = GST_TAG_MINIMUM_BITRATE;
808 case sTagMaximumBitrate:
809 tag = GST_TAG_MAXIMUM_BITRATE;
812 tag = GST_TAG_SERIAL;
814 case sTagEncoderVersion:
815 tag = GST_TAG_ENCODER_VERSION;
824 if (!m_stream_tags || !tag)
828 if (gst_tag_list_get_uint(m_stream_tags, tag, &value))
834 std::string eServiceMP3::getInfoString(int w)
836 if ( !m_stream_tags && w < sUser && w > 26 )
838 const gchar *tag = 0;
845 tag = GST_TAG_ARTIST;
850 case sTagTitleSortname:
851 tag = GST_TAG_TITLE_SORTNAME;
853 case sTagArtistSortname:
854 tag = GST_TAG_ARTIST_SORTNAME;
856 case sTagAlbumSortname:
857 tag = GST_TAG_ALBUM_SORTNAME;
861 if (gst_tag_list_get_date(m_stream_tags, GST_TAG_DATE, &date))
864 g_date_strftime (res, sizeof(res), "%Y-%M-%D", date);
865 return (std::string)res;
869 tag = GST_TAG_COMPOSER;
875 tag = GST_TAG_COMMENT;
877 case sTagExtendedComment:
878 tag = GST_TAG_EXTENDED_COMMENT;
881 tag = GST_TAG_LOCATION;
884 tag = GST_TAG_HOMEPAGE;
886 case sTagDescription:
887 tag = GST_TAG_DESCRIPTION;
890 tag = GST_TAG_VERSION;
895 case sTagOrganization:
896 tag = GST_TAG_ORGANIZATION;
899 tag = GST_TAG_COPYRIGHT;
901 case sTagCopyrightURI:
902 tag = GST_TAG_COPYRIGHT_URI;
905 tag = GST_TAG_CONTACT;
908 tag = GST_TAG_LICENSE;
911 tag = GST_TAG_LICENSE_URI;
917 tag = GST_TAG_AUDIO_CODEC;
920 tag = GST_TAG_VIDEO_CODEC;
923 tag = GST_TAG_ENCODER;
925 case sTagLanguageCode:
926 tag = GST_TAG_LANGUAGE_CODE;
929 tag = GST_TAG_KEYWORDS;
931 case sTagChannelMode:
932 tag = "channel-mode";
935 return m_error_message;
942 if (gst_tag_list_get_string(m_stream_tags, tag, &value))
944 std::string res = value;
951 PyObject *eServiceMP3::getInfoObject(int w)
953 const gchar *tag = 0;
954 bool isBuffer = false;
958 tag = GST_TAG_TRACK_GAIN;
961 tag = GST_TAG_TRACK_PEAK;
964 tag = GST_TAG_ALBUM_GAIN;
967 tag = GST_TAG_ALBUM_PEAK;
969 case sTagReferenceLevel:
970 tag = GST_TAG_REFERENCE_LEVEL;
972 case sTagBeatsPerMinute:
973 tag = GST_TAG_BEATS_PER_MINUTE;
979 case sTagPreviewImage:
980 tag = GST_TAG_PREVIEW_IMAGE;
984 tag = GST_TAG_ATTACHMENT;
993 const GValue *gv_buffer = gst_tag_list_get_value_index(m_stream_tags, tag, 0);
997 buffer = gst_value_get_buffer (gv_buffer);
998 return PyBuffer_FromMemory(GST_BUFFER_DATA(buffer), GST_BUFFER_SIZE(buffer));
1003 gdouble value = 0.0;
1004 gst_tag_list_get_double(m_stream_tags, tag, &value);
1005 return PyFloat_FromDouble(value);
1011 RESULT eServiceMP3::audioChannel(ePtr<iAudioChannelSelection> &ptr)
1017 RESULT eServiceMP3::audioTracks(ePtr<iAudioTrackSelection> &ptr)
1023 RESULT eServiceMP3::subtitle(ePtr<iSubtitleOutput> &ptr)
1029 RESULT eServiceMP3::audioDelay(ePtr<iAudioDelay> &ptr)
1035 int eServiceMP3::getNumberOfTracks()
1037 return m_audioStreams.size();
1040 int eServiceMP3::getCurrentTrack()
1042 if (m_currentAudioStream == -1)
1043 g_object_get (G_OBJECT (m_gst_playbin), "current-audio", &m_currentAudioStream, NULL);
1044 return m_currentAudioStream;
1047 RESULT eServiceMP3::selectTrack(unsigned int i)
1050 getPlayPosition(ppos);
1055 int ret = selectAudioStream(i);
1064 int eServiceMP3::selectAudioStream(int i)
1067 g_object_set (G_OBJECT (m_gst_playbin), "current-audio", i, NULL);
1068 g_object_get (G_OBJECT (m_gst_playbin), "current-audio", ¤t_audio, NULL);
1069 if ( current_audio == i )
1071 eDebug ("eServiceMP3::switched to audio stream %i", current_audio);
1072 m_currentAudioStream = i;
1078 int eServiceMP3::getCurrentChannel()
1083 RESULT eServiceMP3::selectChannel(int i)
1085 eDebug("eServiceMP3::selectChannel(%i)",i);
1089 RESULT eServiceMP3::getTrackInfo(struct iAudioTrackInfo &info, unsigned int i)
1091 if (i >= m_audioStreams.size())
1093 info.m_description = m_audioStreams[i].codec;
1094 /* if (m_audioStreams[i].type == atMPEG)
1095 info.m_description = "MPEG";
1096 else if (m_audioStreams[i].type == atMP3)
1097 info.m_description = "MP3";
1098 else if (m_audioStreams[i].type == atAC3)
1099 info.m_description = "AC3";
1100 else if (m_audioStreams[i].type == atAAC)
1101 info.m_description = "AAC";
1102 else if (m_audioStreams[i].type == atDTS)
1103 info.m_description = "DTS";
1104 else if (m_audioStreams[i].type == atPCM)
1105 info.m_description = "PCM";
1106 else if (m_audioStreams[i].type == atOGG)
1107 info.m_description = "OGG";
1108 else if (m_audioStreams[i].type == atFLAC)
1109 info.m_description = "FLAC";
1111 info.m_description = "???";*/
1112 if (info.m_language.empty())
1113 info.m_language = m_audioStreams[i].language_code;
1117 void eServiceMP3::gstBusCall(GstBus *bus, GstMessage *msg)
1124 source = GST_MESSAGE_SRC(msg);
1125 sourceName = gst_object_get_name(source);
1127 if (gst_message_get_structure(msg))
1129 gchar *string = gst_structure_to_string(gst_message_get_structure(msg));
1130 eDebug("eServiceMP3::gst_message from %s: %s", sourceName, string);
1134 eDebug("eServiceMP3::gst_message from %s: %s (without structure)", sourceName, GST_MESSAGE_TYPE_NAME(msg));
1136 switch (GST_MESSAGE_TYPE (msg))
1138 case GST_MESSAGE_EOS:
1139 m_event((iPlayableService*)this, evEOF);
1141 case GST_MESSAGE_STATE_CHANGED:
1143 if(GST_MESSAGE_SRC(msg) != GST_OBJECT(m_gst_playbin))
1146 GstState old_state, new_state;
1147 gst_message_parse_state_changed(msg, &old_state, &new_state, NULL);
1149 if(old_state == new_state)
1152 eDebug("eServiceMP3::state transition %s -> %s", gst_element_state_get_name(old_state), gst_element_state_get_name(new_state));
1154 GstStateChange transition = (GstStateChange)GST_STATE_TRANSITION(old_state, new_state);
1158 case GST_STATE_CHANGE_NULL_TO_READY:
1161 case GST_STATE_CHANGE_READY_TO_PAUSED:
1164 g_object_get (G_OBJECT (m_gst_playbin), "text-sink", &sink, NULL);
1167 g_object_set (G_OBJECT (sink), "max-buffers", 2, NULL);
1168 g_object_set (G_OBJECT (sink), "sync", FALSE, NULL);
1169 g_object_set (G_OBJECT (sink), "async", FALSE, NULL);
1170 g_object_set (G_OBJECT (sink), "emit-signals", TRUE, NULL);
1171 gst_object_unref(sink);
1173 setAC3Delay(ac3_delay);
1174 setPCMDelay(pcm_delay);
1176 case GST_STATE_CHANGE_PAUSED_TO_PLAYING:
1178 if ( m_sourceinfo.is_streaming && m_streamingsrc_timeout )
1179 m_streamingsrc_timeout->stop();
1181 case GST_STATE_CHANGE_PLAYING_TO_PAUSED:
1184 case GST_STATE_CHANGE_PAUSED_TO_READY:
1187 case GST_STATE_CHANGE_READY_TO_NULL:
1193 case GST_MESSAGE_ERROR:
1197 gst_message_parse_error (msg, &err, &debug);
1199 eWarning("Gstreamer error: %s (%i) from %s", err->message, err->code, sourceName );
1200 if ( err->domain == GST_STREAM_ERROR )
1202 if ( err->code == GST_STREAM_ERROR_CODEC_NOT_FOUND )
1204 if ( g_strrstr(sourceName, "videosink") )
1205 m_event((iPlayableService*)this, evUser+11);
1206 else if ( g_strrstr(sourceName, "audiosink") )
1207 m_event((iPlayableService*)this, evUser+10);
1213 case GST_MESSAGE_INFO:
1218 gst_message_parse_info (msg, &inf, &debug);
1220 if ( inf->domain == GST_STREAM_ERROR && inf->code == GST_STREAM_ERROR_DECODE )
1222 if ( g_strrstr(sourceName, "videosink") )
1223 m_event((iPlayableService*)this, evUser+14);
1228 case GST_MESSAGE_TAG:
1230 GstTagList *tags, *result;
1231 gst_message_parse_tag(msg, &tags);
1233 result = gst_tag_list_merge(m_stream_tags, tags, GST_TAG_MERGE_REPLACE);
1237 gst_tag_list_free(m_stream_tags);
1238 m_stream_tags = result;
1241 const GValue *gv_image = gst_tag_list_get_value_index(tags, GST_TAG_IMAGE, 0);
1244 GstBuffer *buf_image;
1245 buf_image = gst_value_get_buffer (gv_image);
1246 int fd = open("/tmp/.id3coverart", O_CREAT|O_WRONLY|O_TRUNC, 0644);
1247 int ret = write(fd, GST_BUFFER_DATA(buf_image), GST_BUFFER_SIZE(buf_image));
1249 eDebug("eServiceMP3::/tmp/.id3coverart %d bytes written ", ret);
1250 m_event((iPlayableService*)this, evUser+13);
1252 gst_tag_list_free(tags);
1253 m_event((iPlayableService*)this, evUpdatedInfo);
1256 case GST_MESSAGE_ASYNC_DONE:
1258 if(GST_MESSAGE_SRC(msg) != GST_OBJECT(m_gst_playbin))
1262 gint i, active_idx, n_video = 0, n_audio = 0, n_text = 0;
1264 g_object_get (m_gst_playbin, "n-video", &n_video, NULL);
1265 g_object_get (m_gst_playbin, "n-audio", &n_audio, NULL);
1266 g_object_get (m_gst_playbin, "n-text", &n_text, NULL);
1268 eDebug("eServiceMP3::async-done - %d video, %d audio, %d subtitle", n_video, n_audio, n_text);
1270 if ( n_video + n_audio <= 0 )
1275 m_audioStreams.clear();
1276 m_subtitleStreams.clear();
1278 for (i = 0; i < n_audio; i++)
1281 gchar *g_codec, *g_lang;
1283 g_signal_emit_by_name (m_gst_playbin, "get-audio-pad", i, &pad);
1284 GstCaps* caps = gst_pad_get_negotiated_caps(pad);
1287 GstStructure* str = gst_caps_get_structure(caps, 0);
1288 const gchar *g_type = gst_structure_get_name(str);
1289 eDebug("AUDIO STRUCT=%s", g_type);
1290 audio.type = gstCheckAudioPad(str);
1291 g_codec = g_strdup(g_type);
1292 g_lang = g_strdup_printf ("und");
1293 g_signal_emit_by_name (m_gst_playbin, "get-audio-tags", i, &tags);
1294 if ( tags && gst_is_tag_list(tags) )
1296 gst_tag_list_get_string(tags, GST_TAG_AUDIO_CODEC, &g_codec);
1297 gst_tag_list_get_string(tags, GST_TAG_LANGUAGE_CODE, &g_lang);
1298 gst_tag_list_free(tags);
1300 audio.language_code = std::string(g_lang);
1301 audio.codec = std::string(g_codec);
1302 eDebug("eServiceMP3::audio stream=%i codec=%s language=%s", i, g_codec, g_lang);
1303 m_audioStreams.push_back(audio);
1306 gst_caps_unref(caps);
1309 for (i = 0; i < n_text; i++)
1314 // g_signal_emit_by_name (m_gst_playbin, "get-text-pad", i, &pad);
1315 // GstCaps* caps = gst_pad_get_negotiated_caps(pad);
1316 // GstStructure* str = gst_caps_get_structure(caps, 0);
1317 // g_type = gst_structure_get_name(str);
1318 // g_signal_emit_by_name (m_gst_playbin, "get-text-tags", i, &tags);
1319 subtitleStream subs;
1320 subs.type = stPlainText;
1321 g_lang = g_strdup_printf ("und");
1322 if ( tags && gst_is_tag_list(tags) )
1323 gst_tag_list_get_string(tags, GST_TAG_LANGUAGE_CODE, &g_lang);
1324 subs.language_code = std::string(g_lang);
1325 eDebug("eServiceMP3::subtitle stream=%i language=%s"/* type=%s*/, i, g_lang/*, g_type*/);
1326 m_subtitleStreams.push_back(subs);
1330 m_event((iPlayableService*)this, evUpdatedEventInfo);
1333 case GST_MESSAGE_ELEMENT:
1335 if ( gst_is_missing_plugin_message(msg) )
1337 gchar *description = gst_missing_plugin_message_get_description(msg);
1340 m_error_message = "GStreamer plugin " + (std::string)description + " not available!\n";
1341 g_free(description);
1342 m_event((iPlayableService*)this, evUser+12);
1345 else if (const GstStructure *msgstruct = gst_message_get_structure(msg))
1347 const gchar *eventname = gst_structure_get_name(msgstruct);
1350 if (!strcmp(eventname, "eventSizeChanged") || !strcmp(eventname, "eventSizeAvail"))
1352 gst_structure_get_int (msgstruct, "aspect_ratio", &m_aspect);
1353 gst_structure_get_int (msgstruct, "width", &m_width);
1354 gst_structure_get_int (msgstruct, "height", &m_height);
1355 if (strstr(eventname, "Changed"))
1356 m_event((iPlayableService*)this, evVideoSizeChanged);
1358 else if (!strcmp(eventname, "eventFrameRateChanged") || !strcmp(eventname, "eventFrameRateAvail"))
1360 gst_structure_get_int (msgstruct, "frame_rate", &m_framerate);
1361 if (strstr(eventname, "Changed"))
1362 m_event((iPlayableService*)this, evVideoFramerateChanged);
1364 else if (!strcmp(eventname, "eventProgressiveChanged") || !strcmp(eventname, "eventProgressiveAvail"))
1366 gst_structure_get_int (msgstruct, "progressive", &m_progressive);
1367 if (strstr(eventname, "Changed"))
1368 m_event((iPlayableService*)this, evVideoProgressiveChanged);
1374 case GST_MESSAGE_BUFFERING:
1376 GstBufferingMode mode;
1377 gst_message_parse_buffering(msg, &(m_bufferInfo.bufferPercent));
1378 gst_message_parse_buffering_stats(msg, &mode, &(m_bufferInfo.avgInRate), &(m_bufferInfo.avgOutRate), &(m_bufferInfo.bufferingLeft));
1379 m_event((iPlayableService*)this, evBuffering);
1382 case GST_MESSAGE_STREAM_STATUS:
1384 GstStreamStatusType type;
1386 gst_message_parse_stream_status (msg, &type, &owner);
1387 if ( type == GST_STREAM_STATUS_TYPE_CREATE && m_sourceinfo.is_streaming )
1389 if ( GST_IS_PAD(source) )
1390 owner = gst_pad_get_parent_element(GST_PAD(source));
1391 else if ( GST_IS_ELEMENT(source) )
1392 owner = GST_ELEMENT(source);
1397 GstElementFactory *factory = gst_element_get_factory(GST_ELEMENT(owner));
1398 const gchar *name = gst_plugin_feature_get_name(GST_PLUGIN_FEATURE(factory));
1399 if (!strcmp(name, "souphttpsrc"))
1401 m_streamingsrc_timeout->start(HTTP_TIMEOUT*1000, true);
1402 g_object_set (G_OBJECT (owner), "timeout", HTTP_TIMEOUT, NULL);
1403 eDebug("eServiceMP3::GST_STREAM_STATUS_TYPE_CREATE -> setting timeout on %s to %is", name, HTTP_TIMEOUT);
1407 if ( GST_IS_PAD(source) )
1408 gst_object_unref(owner);
1415 g_free (sourceName);
1418 GstBusSyncReply eServiceMP3::gstBusSyncHandler(GstBus *bus, GstMessage *message, gpointer user_data)
1420 eServiceMP3 *_this = (eServiceMP3*)user_data;
1421 _this->m_pump.send(1);
1423 return GST_BUS_PASS;
1426 void eServiceMP3::gstHTTPSourceSetAgent(GObject *object, GParamSpec *unused, gpointer user_data)
1428 eServiceMP3 *_this = (eServiceMP3*)user_data;
1430 g_object_get(_this->m_gst_playbin, "source", &source, NULL);
1431 g_object_set (G_OBJECT (source), "user-agent", _this->m_useragent.c_str(), NULL);
1432 gst_object_unref(source);
1435 audiotype_t eServiceMP3::gstCheckAudioPad(GstStructure* structure)
1440 if ( gst_structure_has_name (structure, "audio/mpeg"))
1442 gint mpegversion, layer = -1;
1443 if (!gst_structure_get_int (structure, "mpegversion", &mpegversion))
1446 switch (mpegversion) {
1449 gst_structure_get_int (structure, "layer", &layer);
1465 else if ( gst_structure_has_name (structure, "audio/x-ac3") || gst_structure_has_name (structure, "audio/ac3") )
1467 else if ( gst_structure_has_name (structure, "audio/x-dts") || gst_structure_has_name (structure, "audio/dts") )
1469 else if ( gst_structure_has_name (structure, "audio/x-raw-int") )
1475 void eServiceMP3::gstPoll(const int &msg)
1477 /* ok, we have a serious problem here. gstBusSyncHandler sends
1478 us the wakup signal, but likely before it was posted.
1479 the usleep, an EVIL HACK (DON'T DO THAT!!!) works around this.
1481 I need to understand the API a bit more to make this work
1485 GstBus *bus = gst_pipeline_get_bus (GST_PIPELINE (m_gst_playbin));
1486 GstMessage *message;
1488 while ((message = gst_bus_pop (bus)))
1490 gstBusCall(bus, message);
1491 gst_message_unref (message);
1498 eAutoInitPtr<eServiceFactoryMP3> init_eServiceFactoryMP3(eAutoInitNumbers::service+1, "eServiceFactoryMP3");
1500 void eServiceMP3::gstCBsubtitleAvail(GstElement *appsink, gpointer user_data)
1502 eServiceMP3 *_this = (eServiceMP3*)user_data;
1503 eSingleLocker l(_this->m_subs_to_pull_lock);
1504 ++_this->m_subs_to_pull;
1505 _this->m_pump.send(2);
1508 void eServiceMP3::pullSubtitle()
1511 g_object_get (G_OBJECT (m_gst_playbin), "text-sink", &sink, NULL);
1514 while (m_subs_to_pull && m_subtitle_pages.size() < 2)
1518 eSingleLocker l(m_subs_to_pull_lock);
1520 g_signal_emit_by_name (sink, "pull-buffer", &buffer);
1524 gint64 buf_pos = GST_BUFFER_TIMESTAMP(buffer);
1525 gint64 duration_ns = GST_BUFFER_DURATION(buffer);
1526 size_t len = GST_BUFFER_SIZE(buffer);
1527 unsigned char line[len+1];
1528 memcpy(line, GST_BUFFER_DATA(buffer), len);
1530 eDebug("got new subtitle @ buf_pos = %lld ns (in pts=%lld): '%s' ", buf_pos, buf_pos/11111, line);
1531 ePangoSubtitlePage page;
1532 gRGB rgbcol(0xD0,0xD0,0xD0);
1533 page.m_elements.push_back(ePangoSubtitlePageElement(rgbcol, (const char*)line));
1534 page.show_pts = buf_pos / 11111L;
1535 page.m_timeout = duration_ns / 1000000;
1536 m_subtitle_pages.push_back(page);
1538 gst_buffer_unref(buffer);
1541 gst_object_unref(sink);
1544 eDebug("no subtitle sink!");
1547 void eServiceMP3::pushSubtitles()
1549 ePangoSubtitlePage page;
1551 while ( !m_subtitle_pages.empty() )
1553 getPlayPosition(running_pts);
1554 page = m_subtitle_pages.front();
1555 gint64 diff_ms = ( page.show_pts - running_pts ) / 90;
1556 eDebug("eServiceMP3::pushSubtitles show_pts = %lld running_pts = %lld diff = %lld", page.show_pts, running_pts, diff_ms);
1559 GstFormat fmt = GST_FORMAT_TIME;
1561 if (gst_element_query_position(m_gst_playbin, &fmt, &now) != -1)
1564 diff_ms = abs((now - running_pts) / 90);
1565 eDebug("diff < -100ms check decoder/pipeline diff: decoder: %lld, pipeline: %lld, diff: %lld", running_pts, now, diff_ms);
1566 if (diff_ms > 100000)
1568 eDebug("high decoder/pipeline difference.. assume decoder has now started yet.. check again in 1sec");
1569 m_subtitle_sync_timer->start(1000, true);
1574 eDebug("query position for decoder/pipeline check failed!");
1575 eDebug("subtitle to late... drop");
1576 m_subtitle_pages.pop_front();
1578 else if ( diff_ms > 20 )
1580 // eDebug("start recheck timer");
1581 m_subtitle_sync_timer->start(diff_ms > 1000 ? 1000 : diff_ms, true);
1584 else // immediate show
1586 if (m_subtitle_widget)
1587 m_subtitle_widget->setPage(page);
1588 m_subtitle_pages.pop_front();
1591 if (m_subtitle_pages.empty())
1595 RESULT eServiceMP3::enableSubtitles(eWidget *parent, ePyObject tuple)
1598 int tuplesize = PyTuple_Size(tuple);
1602 if (!PyTuple_Check(tuple))
1606 entry = PyTuple_GET_ITEM(tuple, 1);
1607 if (!PyInt_Check(entry))
1609 pid = PyInt_AsLong(entry);
1610 entry = PyTuple_GET_ITEM(tuple, 2);
1611 if (!PyInt_Check(entry))
1613 type = PyInt_AsLong(entry);
1615 if (m_currentSubtitleStream != pid)
1617 eSingleLocker l(m_subs_to_pull_lock);
1618 g_object_set (G_OBJECT (m_gst_playbin), "current-text", pid, NULL);
1619 m_currentSubtitleStream = pid;
1621 m_subtitle_pages.clear();
1624 m_subtitle_widget = 0;
1625 m_subtitle_widget = new eSubtitleWidget(parent);
1626 m_subtitle_widget->resize(parent->size()); /* full size */
1628 g_object_get (G_OBJECT (m_gst_playbin), "current-text", &text_pid, NULL);
1630 eDebug ("eServiceMP3::switched to subtitle stream %i", text_pid);
1635 eDebug("eServiceMP3::enableSubtitles needs a tuple as 2nd argument!\n"
1636 "for gst subtitles (2, subtitle_stream_count, subtitle_type)");
1640 RESULT eServiceMP3::disableSubtitles(eWidget *parent)
1642 eDebug("eServiceMP3::disableSubtitles");
1643 m_subtitle_pages.clear();
1644 delete m_subtitle_widget;
1645 m_subtitle_widget = 0;
1649 PyObject *eServiceMP3::getCachedSubtitle()
1651 // eDebug("eServiceMP3::getCachedSubtitle");
1655 PyObject *eServiceMP3::getSubtitleList()
1657 eDebug("eServiceMP3::getSubtitleList");
1659 ePyObject l = PyList_New(0);
1660 int stream_count[sizeof(subtype_t)];
1661 for ( unsigned int i = 0; i < sizeof(subtype_t); i++ )
1662 stream_count[i] = 0;
1664 for (std::vector<subtitleStream>::iterator IterSubtitleStream(m_subtitleStreams.begin()); IterSubtitleStream != m_subtitleStreams.end(); ++IterSubtitleStream)
1666 subtype_t type = IterSubtitleStream->type;
1667 ePyObject tuple = PyTuple_New(5);
1668 PyTuple_SET_ITEM(tuple, 0, PyInt_FromLong(2));
1669 PyTuple_SET_ITEM(tuple, 1, PyInt_FromLong(stream_count[type]));
1670 PyTuple_SET_ITEM(tuple, 2, PyInt_FromLong(int(type)));
1671 PyTuple_SET_ITEM(tuple, 3, PyInt_FromLong(0));
1672 PyTuple_SET_ITEM(tuple, 4, PyString_FromString((IterSubtitleStream->language_code).c_str()));
1673 PyList_Append(l, tuple);
1675 stream_count[type]++;
1680 RESULT eServiceMP3::streamed(ePtr<iStreamedService> &ptr)
1686 PyObject *eServiceMP3::getBufferCharge()
1688 ePyObject tuple = PyTuple_New(5);
1689 PyTuple_SET_ITEM(tuple, 0, PyInt_FromLong(m_bufferInfo.bufferPercent));
1690 PyTuple_SET_ITEM(tuple, 1, PyInt_FromLong(m_bufferInfo.avgInRate));
1691 PyTuple_SET_ITEM(tuple, 2, PyInt_FromLong(m_bufferInfo.avgOutRate));
1692 PyTuple_SET_ITEM(tuple, 3, PyInt_FromLong(m_bufferInfo.bufferingLeft));
1693 PyTuple_SET_ITEM(tuple, 4, PyInt_FromLong(m_buffer_size));
1697 int eServiceMP3::setBufferSize(int size)
1699 m_buffer_size = size;
1700 g_object_set (G_OBJECT (m_gst_playbin), "buffer-size", m_buffer_size, NULL);
1704 int eServiceMP3::getAC3Delay()
1709 int eServiceMP3::getPCMDelay()
1714 void eServiceMP3::setAC3Delay(int delay)
1717 if (!m_gst_playbin || m_state != stRunning)
1722 int config_delay_int = delay;
1723 g_object_get (G_OBJECT (m_gst_playbin), "video-sink", &sink, NULL);
1727 std::string config_delay;
1728 if(ePythonConfigQuery::getConfigValue("config.av.generalAC3delay", config_delay) == 0)
1729 config_delay_int += atoi(config_delay.c_str());
1730 gst_object_unref(sink);
1734 eDebug("dont apply ac3 delay when no video is running!");
1735 config_delay_int = 0;
1738 g_object_get (G_OBJECT (m_gst_playbin), "audio-sink", &sink, NULL);
1742 gchar *name = gst_element_get_name(sink);
1743 if (strstr(name, "dvbaudiosink"))
1744 eTSMPEGDecoder::setHwAC3Delay(config_delay_int);
1746 gst_object_unref(sink);
1751 void eServiceMP3::setPCMDelay(int delay)
1754 if (!m_gst_playbin || m_state != stRunning)
1759 int config_delay_int = delay;
1760 g_object_get (G_OBJECT (m_gst_playbin), "video-sink", &sink, NULL);
1764 std::string config_delay;
1765 if(ePythonConfigQuery::getConfigValue("config.av.generalPCMdelay", config_delay) == 0)
1766 config_delay_int += atoi(config_delay.c_str());
1767 gst_object_unref(sink);
1771 eDebug("dont apply pcm delay when no video is running!");
1772 config_delay_int = 0;
1775 g_object_get (G_OBJECT (m_gst_playbin), "audio-sink", &sink, NULL);
1779 gchar *name = gst_element_get_name(sink);
1780 if (strstr(name, "dvbaudiosink"))
1781 eTSMPEGDecoder::setHwPCMDelay(config_delay_int);
1784 // this is realy untested..and not used yet
1785 gint64 offset = config_delay_int;
1786 offset *= 1000000; // milli to nano
1787 g_object_set (G_OBJECT (m_gst_playbin), "ts-offset", offset, NULL);
1790 gst_object_unref(sink);
1796 #warning gstreamer not available, not building media player