Changeset 30600


Ignore:
Timestamp:
10/18/14 16:03:50 (9 years ago)
Author:
obi
Message:

[tithek] mipsel add 10mb gst prefillbuffer without infos

Location:
titan
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • titan/plugins/tithek/tithek.h

    r30273 r30600  
    13541354                        else if(!ostrncmp("http://", tmpstr1, 7))
    13551355                        {
    1356 #ifdef EPLAYER3
     1356//#ifdef EPLAYER3
    13571357                                if(checkbox("UFS910") == 1 && !file_exist("/var/swapdir/swapfile"))
    13581358                                        addmenulist(&mlist, "Streaming Playback Caching (5MB)", _("Streaming Playback Caching (5MB)"), NULL, 0, 0);
     
    13611361                                        addmenulist(&mlist, "Streaming Playback Caching (10MB)", _("Streaming Playback Caching (10MB)"), NULL, 0, 0);
    13621362                                }
    1363 #endif
     1363//#endif
    13641364                                if(file_exist(getconfig("rec_streampath", NULL)) && (file_exist("/mnt/swapextensions/etc/.codecpack") || file_exist("/var/swap/etc/.codecpack") || file_exist("/var/etc/.codecpack")))
    13651365                                {
  • titan/titan/player.h

    r30594 r30600  
    2929
    3030#ifdef EPLAYER4
    31 GstElement *m_gst_playbin = NULL;
     31GstElement *pipeline = NULL;
    3232unsigned long long m_gst_startpts = 0;
    3333#endif
     
    590590}
    591591
     592typedef struct _CustomData {
     593  gboolean is_live;
     594  GstElement *pipeline;
     595  GMainLoop *loop;
     596} CustomData;
     597
     598CustomData data;
     599
    592600//extern player
    593 
    594601int playerstart(char* file)
    595602{
     
    695702
    696703#ifdef EPLAYER4
    697                 status.prefillbuffer = 1;
    698 
    699704                int flags = 0x47; //(GST_PLAY_FLAG_VIDEO | GST_PLAY_FLAG_AUDIO | GST_PLAY_FLAG_NATIVE_VIDEO | GST_PLAY_FLAG_TEXT);
    700705               
    701                 if(m_gst_playbin != NULL)
     706                if(pipeline != NULL)
    702707                {
    703708                        debug(150, "eplayer allready running");
     
    713718                {
    714719                        err("no mem");
    715                         free(m_gst_playbin); m_gst_playbin = NULL;
     720                        free(pipeline); pipeline = NULL;
    716721                        return 1;
    717722                }
     
    721726                else
    722727                        status.playercan = 0x7E7F;
    723                
    724                 m_gst_playbin = gst_element_factory_make("playbin2", "playbin");
     728       
     729                pipeline = gst_element_factory_make("playbin2", "playbin");
    725730
    726731// enable buffersize start
    727                 g_object_set(G_OBJECT(m_gst_playbin), "buffer-duration", 5LL * GST_SECOND, NULL);
    728                 g_object_set(G_OBJECT(m_gst_playbin), "buffer-size", 5*1024*1024, NULL);
     732                int size = getconfigint("playerbuffersize", NULL);
     733                printf("size: %d\n",size);
     734               
     735                if(size > 0)
     736                        status.prefillbuffer = 1;
     737
     738                g_object_set(G_OBJECT(pipeline), "buffer-duration", size * GST_SECOND, NULL);
     739                g_object_set(G_OBJECT(pipeline), "buffer-size", size, NULL);
    729740// enable buffersizeend
    730741
    731                 g_object_set(G_OBJECT (m_gst_playbin), "uri", tmpfile, NULL);
    732                 g_object_set(G_OBJECT (m_gst_playbin), "flags", flags, NULL);
     742                g_object_set(G_OBJECT(pipeline), "uri", tmpfile, NULL);
     743                g_object_set(G_OBJECT(pipeline), "flags", flags, NULL);
    733744                free(tmpfile); tmpfile = NULL;
    734745
     746///////////////////
    735747// srt subs start
    736748                const char *filename = file;
     
    746758//                      m_subs_to_pull_handler_id = g_signal_connect (subsink, "new-buffer", G_CALLBACK (gstCBsubtitleAvail), this);
    747759                        g_object_set (G_OBJECT (subsink), "caps", gst_caps_from_string("text/plain; text/x-plain; text/x-raw; text/x-pango-markup; video/x-dvd-subpicture; subpicture/x-pgs"), NULL);
    748                         g_object_set (G_OBJECT (m_gst_playbin), "text-sink", subsink, NULL);
    749                         g_object_set (G_OBJECT (m_gst_playbin), "current-text", -1, NULL);
    750                 }
    751 
    752                 GstBus *bus = gst_pipeline_get_bus(GST_PIPELINE (m_gst_playbin));
     760                        g_object_set (G_OBJECT (pipeline), "text-sink", subsink, NULL);
     761                        g_object_set (G_OBJECT (pipeline), "current-text", -1, NULL);
     762                }
     763
     764                GstBus *bus = gst_pipeline_get_bus(GST_PIPELINE(pipeline));
    753765#if GST_VERSION_MAJOR < 1
    754766//              gst_bus_set_sync_handler(bus, gstBusSyncHandler, this);
     
    769781                        printf("found srt1: %s\n",srt_filename);
    770782                        printf("found srt2: %s\n",g_filename_to_uri(srt_filename, NULL, NULL));
    771                         g_object_set(G_OBJECT (m_gst_playbin), "suburi", g_filename_to_uri(srt_filename, NULL, NULL), NULL);           
    772                 }
    773 // srt end             
    774 
    775                 if(m_gst_playbin)
    776                 {
    777                         gst_element_set_state(m_gst_playbin, GST_STATE_PLAYING);
    778                 }
     783                        g_object_set(G_OBJECT (pipeline), "suburi", g_filename_to_uri(srt_filename, NULL, NULL), NULL);         
     784                }
     785// srt end     
     786
     787///////////////////
     788//              CustomData data;
     789                memset (&data, 0, sizeof (data));
     790                data.pipeline = pipeline;
     791//              GstBus *bus;
     792//              bus = gst_element_get_bus (pipeline);
     793               
     794                // Start playing //
     795                GstStateChangeReturn ret;
     796                ret = gst_element_set_state (pipeline, GST_STATE_PLAYING);
     797                if(ret == GST_STATE_CHANGE_FAILURE)
     798                {
     799                        g_printerr ("Unable to set the pipeline to the playing state.\n");
     800                        gst_object_unref (pipeline);
     801                        return -1;
     802                }
     803                else if(ret == GST_STATE_CHANGE_NO_PREROLL)
     804                {
     805                        data.is_live = TRUE;
     806                }
     807
     808                data.loop = g_main_loop_new (NULL, FALSE);
     809                data.pipeline = pipeline;
     810                gst_bus_add_signal_watch (bus);
     811//              g_signal_connect (bus, "message", G_CALLBACK (cb_message), &data);
     812//              status.prefillbuffer = 1;
    779813
    780814                int count = 0;
     
    786820                        m_gst_startpts = playergetpts();
    787821                }
     822
    788823                return 0;
    789824#endif
     
    792827        return 1;
    793828}
     829
    794830
    795831#ifdef EPLAYER4
     
    797833{
    798834        int m_buffer_size = size;
    799         g_object_set (G_OBJECT (m_gst_playbin), "buffer-size", m_buffer_size, NULL);
     835        g_object_set (G_OBJECT (pipeline), "buffer-size", m_buffer_size, NULL);
    800836        return 0;
    801837}
     
    810846
    811847#ifdef EPLAYER4
    812 int gstbuscall(GstBus *bus, GstMessage *msg)
     848int gstbuscall(GstBus *bus, GstMessage *msg, CustomData *data)
    813849{
    814850
    815851        int ret = 1;
    816         if(!m_gst_playbin) return 0;
     852        if(!pipeline) return 0;
    817853        if(!msg) return ret;
    818854
     
    830866                        break;
    831867                case GST_MESSAGE_STATE_CHANGED:
    832                         if(GST_MESSAGE_SRC(msg) != GST_OBJECT(m_gst_playbin))
     868                        if(GST_MESSAGE_SRC(msg) != GST_OBJECT(pipeline))
    833869                                break;
    834870
     
    848884                                case GST_STATE_CHANGE_READY_TO_PAUSED:
    849885/*
    850                                         GstElement *appsink = gst_bin_get_by_name(GST_BIN(m_gst_playbin), "subtitle_sink");
     886                                        GstElement *appsink = gst_bin_get_by_name(GST_BIN(pipeline), "subtitle_sink");
    851887                                        if(appsink)
    852888                                        {
     
    928964                        //m_event((iPlayableService*)this, evBuffering);
    929965*/
     966
     967//debug(10, "gst player buffering");
     968                        if(status.prefillbuffer == 1)
     969                        {
     970
     971                                gint percent = 0;
     972                                if (data->is_live) break;
     973                                gst_message_parse_buffering (msg, &percent);
     974                                g_print ("Buffering (%3d%%)\r", percent);
     975                                if (percent < 100)
     976                                {
     977                                        gst_element_set_state (data->pipeline, GST_STATE_PAUSED);
     978                                }
     979                                else
     980                                {
     981                                        gst_element_set_state (data->pipeline, GST_STATE_PLAYING);
     982                                        status.prefillbuffer = 0;
     983                                }
     984                        }
     985                        break;
     986
     987/*
    930988                        GstBufferingMode mode;
    931989                        gst_message_parse_buffering(msg, &(status.bufferpercent));
    932990                        gst_message_parse_buffering_stats(msg, &mode, &(status.avgInRate), &(status.avgOutRate), &(status.bufferingLeft));
    933991
    934                         printf("#########################################################\n");
    935                         printf("Buffering %u percent done\n", status.bufferpercent);
    936                         printf("avgInRate %d\n", status.avgInRate);
    937                         printf("avgOutRate %d\n", status.avgOutRate);
    938                         printf("bufferingLeft %lld\n", status.bufferingLeft);
     992//                      printf("#########################################################\n");
     993//                      printf("Buffering %u percent done\n", status.bufferpercent);
     994//                      printf("avgInRate %d\n", status.avgInRate);
     995//                      printf("avgOutRate %d\n", status.avgOutRate);
     996//                      printf("bufferingLeft %lld\n", status.bufferingLeft);
    939997                                       
    940998                        if(status.prefillbuffer == 1)
     
    9451003                                {
    9461004                                        GstState state;
    947                                         gst_element_get_state(m_gst_playbin, &state, NULL, 0LL);
     1005                                        gst_element_get_state(pipeline, &state, NULL, 0LL);
    9481006                                        if (state != GST_STATE_PLAYING)
    9491007                                        {
    9501008                                                // eDebug("start playing");
    951                                                 gst_element_set_state (m_gst_playbin, GST_STATE_PLAYING);
     1009                                                gst_element_set_state (pipeline, GST_STATE_PLAYING);
    9521010                                        }
    9531011//                                      m_ignore_buffering_messages = 5;
     
    9571015                                {
    9581016                                        // eDebug("start pause");
    959                                         gst_element_set_state (m_gst_playbin, GST_STATE_PAUSED);
     1017                                        gst_element_set_state (pipeline, GST_STATE_PAUSED);
    9601018//                                      m_ignore_buffering_messages = 0;
    9611019                                }
    9621020                        }
    963 
     1021*/
    9641022/*
    9651023                                GstBufferingMode mode;
    9661024                                printf("GST_STATE_PAUSED\n");
    967                                 gst_element_set_state (m_gst_playbin, GST_STATE_PAUSED);
     1025                                gst_element_set_state (pipeline, GST_STATE_PAUSED);
    9681026
    9691027
     
    9771035                                        {
    9781036                                                GstState state;
    979                                                 gst_element_get_state(m_gst_playbin, &state, NULL, 0LL);
     1037                                                gst_element_get_state(pipeline, &state, NULL, 0LL);
    9801038                                                if (state != GST_STATE_PLAYING)
    9811039                                                {
    9821040                                                        // eDebug("start playing");
    983                                                         gst_element_set_state (m_gst_playbin, GST_STATE_PLAYING);
     1041                                                        gst_element_set_state (pipeline, GST_STATE_PLAYING);
    9841042                                                }
    9851043                                                m_ignore_buffering_messages = 5;
     
    9881046                                        {
    9891047                                                // eDebug("start pause");
    990                                                 gst_element_set_state (m_gst_playbin, GST_STATE_PAUSED);
     1048                                                gst_element_set_state (pipeline, GST_STATE_PAUSED);
    9911049                                                m_ignore_buffering_messages = 0;
    9921050                                        }
     
    10901148        int ret = 1;
    10911149
    1092         if(m_gst_playbin)
    1093         {
    1094                 GstBus *bus = gst_pipeline_get_bus(GST_PIPELINE(m_gst_playbin));
     1150        if(pipeline)
     1151        {
     1152                GstBus *bus = gst_pipeline_get_bus(GST_PIPELINE(pipeline));
    10951153                GstMessage *message = NULL;
     1154//use global variale, with static var crash
     1155//              CustomData *data = NULL;
    10961156                while((message = gst_bus_pop(bus)))
    10971157                {
    1098                         ret = gstbuscall(bus, message);
     1158                        ret = gstbuscall(bus, message, &data);
    10991159                        gst_message_unref(message);
    11001160                }
     
    11161176
    11171177#ifdef EPLAYER4
    1118         if(m_gst_playbin)
    1119                 gst_element_set_state(m_gst_playbin, GST_STATE_PLAYING);
     1178        if(pipeline)
     1179                gst_element_set_state(pipeline, GST_STATE_PLAYING);
    11201180#endif
    11211181}
     
    11451205
    11461206#ifdef EPLAYER4
    1147         if(m_gst_playbin)
    1148         {
    1149                 gst_element_set_state(m_gst_playbin, GST_STATE_NULL);
    1150                 gst_object_unref(GST_OBJECT(m_gst_playbin));
    1151                 m_gst_playbin = NULL;
     1207        if(pipeline)
     1208        {
     1209                gst_element_set_state(pipeline, GST_STATE_NULL);
     1210                gst_object_unref(GST_OBJECT(pipeline));
     1211                pipeline = NULL;
    11521212        }
    11531213#endif
     
    11651225
    11661226#ifdef EPLAYER4
    1167         if(m_gst_playbin)
     1227        if(pipeline)
    11681228                playerstop();
    11691229#endif
     
    11781238
    11791239#ifdef EPLAYER4
    1180         if(m_gst_playbin)
    1181                 gst_element_set_state(m_gst_playbin, GST_STATE_PAUSED);
     1240        if(pipeline)
     1241                gst_element_set_state(pipeline, GST_STATE_PAUSED);
    11821242#endif
    11831243}
     
    11911251
    11921252#ifdef EPLAYER4
    1193         if(m_gst_playbin)
    1194                 gst_element_set_state(m_gst_playbin, GST_STATE_PLAYING);
     1253        if(pipeline)
     1254                gst_element_set_state(pipeline, GST_STATE_PLAYING);
    11951255#endif
    11961256}
     
    12801340        //GstFormat fmt = GST_FORMAT_TIME;
    12811341               
    1282         if(m_gst_playbin)
     1342        if(pipeline)
    12831343        {
    12841344                len = playergetlength();
     
    12941354                        playerstop();
    12951355                else
    1296                         gst_element_seek(m_gst_playbin, 1.0, GST_FORMAT_TIME, GST_SEEK_FLAG_FLUSH, GST_SEEK_TYPE_SET, nanos_pts, GST_SEEK_TYPE_NONE, GST_CLOCK_TIME_NONE);
     1356                        gst_element_seek(pipeline, 1.0, GST_FORMAT_TIME, GST_SEEK_FLAG_FLUSH, GST_SEEK_TYPE_SET, nanos_pts, GST_SEEK_TYPE_NONE, GST_CLOCK_TIME_NONE);
    12971357        }
    12981358#endif
     
    14161476        //TrackList = tmpTrackList;
    14171477       
    1418         if(m_gst_playbin != NULL)
     1478        if(pipeline != NULL)
    14191479        {
    14201480                gint i, n_video = 0, n_audio = 0, n_text = 0;
    14211481               
    1422                 g_object_get(m_gst_playbin, "n-video", &n_video, NULL);
    1423                 g_object_get(m_gst_playbin, "n-audio", &n_audio, NULL);
    1424                 g_object_get(m_gst_playbin, "n-text", &n_text, NULL);
     1482                g_object_get(pipeline, "n-video", &n_video, NULL);
     1483                g_object_get(pipeline, "n-audio", &n_audio, NULL);
     1484                g_object_get(pipeline, "n-text", &n_text, NULL);
    14251485               
    14261486                switch(type)
     
    14341494                                        GstPad* pad = 0;
    14351495                                       
    1436                                         g_signal_emit_by_name (m_gst_playbin, "get-audio-pad", i, &pad);
     1496                                        g_signal_emit_by_name (pipeline, "get-audio-pad", i, &pad);
    14371497#if GST_VERSION_MAJOR < 1
    14381498                                        GstCaps* caps = gst_pad_get_negotiated_caps(pad);
     
    14461506                                        const gchar *g_type = gst_structure_get_name(str);
    14471507
    1448                                         g_signal_emit_by_name(m_gst_playbin, "get-audio-tags", i, &tags);
     1508                                        g_signal_emit_by_name(pipeline, "get-audio-tags", i, &tags);
    14491509
    14501510#if GST_VERSION_MAJOR < 1
     
    15021562//                                      GstPad* pad = 0;
    15031563                               
    1504                                         g_signal_emit_by_name(m_gst_playbin, "get-text-tags", i, &tags);
     1564                                        g_signal_emit_by_name(pipeline, "get-text-tags", i, &tags);
    15051565                                       
    15061566#if GST_VERSION_MAJOR < 1
     
    15251585                                        }
    15261586/*
    1527                                         g_signal_emit_by_name(m_gst_playbin, "get-text-pad", i, &pad);
     1587                                        g_signal_emit_by_name(pipeline, "get-text-pad", i, &pad);
    15281588                                        if(pad)
    15291589                                                g_signal_connect(G_OBJECT(pad), "notify::caps", G_CALLBACK (gstTextpadHasCAPS), this);
     
    15391599                                        gchar *g_codec = NULL, *g_lang = NULL;
    15401600                                       
    1541                                         g_signal_emit_by_name(m_gst_playbin, "get-video-tags", i, &tags);
     1601                                        g_signal_emit_by_name(pipeline, "get-video-tags", i, &tags);
    15421602                                       
    15431603#if GST_VERSION_MAJOR < 1
     
    16131673
    16141674#ifdef EPLAYER4
    1615         if(m_gst_playbin != NULL)
     1675        if(pipeline != NULL)
    16161676        {
    16171677                switch(type)
    16181678                {
    16191679                        case 1:
    1620                                 g_object_get(G_OBJECT(m_gst_playbin), "current-audio", CurTrackId, NULL);
     1680                                g_object_get(G_OBJECT(pipeline), "current-audio", CurTrackId, NULL);
    16211681                                break;
    16221682                }
     
    16461706       
    16471707/*
    1648         if(m_gst_playbin)
    1649         {
    1650                 gst_element_query_position(m_gst_playbin, &fmt, (gint64*)&pts);
     1708        if(pipeline)
     1709        {
     1710                gst_element_query_position(pipeline, &fmt, (gint64*)&pts);
    16511711                sec = pts / 1000000000;
    16521712                pts = sec * 90000;
     
    16551715*/
    16561716
    1657         if(m_gst_playbin)
     1717        if(pipeline)
    16581718        {
    16591719                gint64 pos;
     
    16611721                pts = 0;
    16621722
    1663                 g_object_get(G_OBJECT (m_gst_playbin), "audio-sink", &sink, NULL);
    1664 
    1665                 if(!sink) g_object_get (G_OBJECT (m_gst_playbin), "video-sink", &sink, NULL);
     1723                g_object_get(G_OBJECT (pipeline), "audio-sink", &sink, NULL);
     1724
     1725                if(!sink) g_object_get (G_OBJECT (pipeline), "video-sink", &sink, NULL);
    16661726                if(!sink) return 0;
    16671727
     
    16741734                gst_object_unref(sink);
    16751735
    1676                 if(!use_get_decoder_time && !gst_element_query_position(m_gst_playbin, &fmt, &pos))
     1736                if(!use_get_decoder_time && !gst_element_query_position(pipeline, &fmt, &pos))
    16771737                        return 0;
    16781738
     
    17061766        gint64 len;
    17071767
    1708         if(m_gst_playbin)
    1709         {
    1710                 gst_element_query_duration(m_gst_playbin, &fmt, &len);
     1768        if(pipeline)
     1769        {
     1770                gst_element_query_duration(pipeline, &fmt, &len);
    17111771                length = len / 1000000000;
    17121772                if(length < 0) length = 0;
     
    17521812
    17531813#ifdef EPLAYER4
    1754         if(m_gst_playbin != NULL)
    1755                 g_object_set(G_OBJECT(m_gst_playbin), "current-audio", num, NULL);     
     1814        if(pipeline != NULL)
     1815                g_object_set(G_OBJECT(pipeline), "current-audio", num, NULL);   
    17561816#endif
    17571817}
Note: See TracChangeset for help on using the changeset viewer.