Changeset 30600
- Timestamp:
- 10/18/14 16:03:50 (9 years ago)
- Location:
- titan
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
titan/plugins/tithek/tithek.h
r30273 r30600 1354 1354 else if(!ostrncmp("http://", tmpstr1, 7)) 1355 1355 { 1356 #ifdef EPLAYER31356 //#ifdef EPLAYER3 1357 1357 if(checkbox("UFS910") == 1 && !file_exist("/var/swapdir/swapfile")) 1358 1358 addmenulist(&mlist, "Streaming Playback Caching (5MB)", _("Streaming Playback Caching (5MB)"), NULL, 0, 0); … … 1361 1361 addmenulist(&mlist, "Streaming Playback Caching (10MB)", _("Streaming Playback Caching (10MB)"), NULL, 0, 0); 1362 1362 } 1363 #endif1363 //#endif 1364 1364 if(file_exist(getconfig("rec_streampath", NULL)) && (file_exist("/mnt/swapextensions/etc/.codecpack") || file_exist("/var/swap/etc/.codecpack") || file_exist("/var/etc/.codecpack"))) 1365 1365 { -
titan/titan/player.h
r30594 r30600 29 29 30 30 #ifdef EPLAYER4 31 GstElement * m_gst_playbin= NULL;31 GstElement *pipeline = NULL; 32 32 unsigned long long m_gst_startpts = 0; 33 33 #endif … … 590 590 } 591 591 592 typedef struct _CustomData { 593 gboolean is_live; 594 GstElement *pipeline; 595 GMainLoop *loop; 596 } CustomData; 597 598 CustomData data; 599 592 600 //extern player 593 594 601 int playerstart(char* file) 595 602 { … … 695 702 696 703 #ifdef EPLAYER4 697 status.prefillbuffer = 1;698 699 704 int flags = 0x47; //(GST_PLAY_FLAG_VIDEO | GST_PLAY_FLAG_AUDIO | GST_PLAY_FLAG_NATIVE_VIDEO | GST_PLAY_FLAG_TEXT); 700 705 701 if( m_gst_playbin!= NULL)706 if(pipeline != NULL) 702 707 { 703 708 debug(150, "eplayer allready running"); … … 713 718 { 714 719 err("no mem"); 715 free( m_gst_playbin); m_gst_playbin= NULL;720 free(pipeline); pipeline = NULL; 716 721 return 1; 717 722 } … … 721 726 else 722 727 status.playercan = 0x7E7F; 723 724 m_gst_playbin= gst_element_factory_make("playbin2", "playbin");728 729 pipeline = gst_element_factory_make("playbin2", "playbin"); 725 730 726 731 // 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); 729 740 // enable buffersizeend 730 741 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); 733 744 free(tmpfile); tmpfile = NULL; 734 745 746 /////////////////// 735 747 // srt subs start 736 748 const char *filename = file; … … 746 758 // m_subs_to_pull_handler_id = g_signal_connect (subsink, "new-buffer", G_CALLBACK (gstCBsubtitleAvail), this); 747 759 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)); 753 765 #if GST_VERSION_MAJOR < 1 754 766 // gst_bus_set_sync_handler(bus, gstBusSyncHandler, this); … … 769 781 printf("found srt1: %s\n",srt_filename); 770 782 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; 779 813 780 814 int count = 0; … … 786 820 m_gst_startpts = playergetpts(); 787 821 } 822 788 823 return 0; 789 824 #endif … … 792 827 return 1; 793 828 } 829 794 830 795 831 #ifdef EPLAYER4 … … 797 833 { 798 834 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); 800 836 return 0; 801 837 } … … 810 846 811 847 #ifdef EPLAYER4 812 int gstbuscall(GstBus *bus, GstMessage *msg )848 int gstbuscall(GstBus *bus, GstMessage *msg, CustomData *data) 813 849 { 814 850 815 851 int ret = 1; 816 if(! m_gst_playbin) return 0;852 if(!pipeline) return 0; 817 853 if(!msg) return ret; 818 854 … … 830 866 break; 831 867 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)) 833 869 break; 834 870 … … 848 884 case GST_STATE_CHANGE_READY_TO_PAUSED: 849 885 /* 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"); 851 887 if(appsink) 852 888 { … … 928 964 //m_event((iPlayableService*)this, evBuffering); 929 965 */ 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 /* 930 988 GstBufferingMode mode; 931 989 gst_message_parse_buffering(msg, &(status.bufferpercent)); 932 990 gst_message_parse_buffering_stats(msg, &mode, &(status.avgInRate), &(status.avgOutRate), &(status.bufferingLeft)); 933 991 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); 939 997 940 998 if(status.prefillbuffer == 1) … … 945 1003 { 946 1004 GstState state; 947 gst_element_get_state( m_gst_playbin, &state, NULL, 0LL);1005 gst_element_get_state(pipeline, &state, NULL, 0LL); 948 1006 if (state != GST_STATE_PLAYING) 949 1007 { 950 1008 // eDebug("start playing"); 951 gst_element_set_state ( m_gst_playbin, GST_STATE_PLAYING);1009 gst_element_set_state (pipeline, GST_STATE_PLAYING); 952 1010 } 953 1011 // m_ignore_buffering_messages = 5; … … 957 1015 { 958 1016 // eDebug("start pause"); 959 gst_element_set_state ( m_gst_playbin, GST_STATE_PAUSED);1017 gst_element_set_state (pipeline, GST_STATE_PAUSED); 960 1018 // m_ignore_buffering_messages = 0; 961 1019 } 962 1020 } 963 1021 */ 964 1022 /* 965 1023 GstBufferingMode mode; 966 1024 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); 968 1026 969 1027 … … 977 1035 { 978 1036 GstState state; 979 gst_element_get_state( m_gst_playbin, &state, NULL, 0LL);1037 gst_element_get_state(pipeline, &state, NULL, 0LL); 980 1038 if (state != GST_STATE_PLAYING) 981 1039 { 982 1040 // eDebug("start playing"); 983 gst_element_set_state ( m_gst_playbin, GST_STATE_PLAYING);1041 gst_element_set_state (pipeline, GST_STATE_PLAYING); 984 1042 } 985 1043 m_ignore_buffering_messages = 5; … … 988 1046 { 989 1047 // eDebug("start pause"); 990 gst_element_set_state ( m_gst_playbin, GST_STATE_PAUSED);1048 gst_element_set_state (pipeline, GST_STATE_PAUSED); 991 1049 m_ignore_buffering_messages = 0; 992 1050 } … … 1090 1148 int ret = 1; 1091 1149 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)); 1095 1153 GstMessage *message = NULL; 1154 //use global variale, with static var crash 1155 // CustomData *data = NULL; 1096 1156 while((message = gst_bus_pop(bus))) 1097 1157 { 1098 ret = gstbuscall(bus, message );1158 ret = gstbuscall(bus, message, &data); 1099 1159 gst_message_unref(message); 1100 1160 } … … 1116 1176 1117 1177 #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); 1120 1180 #endif 1121 1181 } … … 1145 1205 1146 1206 #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; 1152 1212 } 1153 1213 #endif … … 1165 1225 1166 1226 #ifdef EPLAYER4 1167 if( m_gst_playbin)1227 if(pipeline) 1168 1228 playerstop(); 1169 1229 #endif … … 1178 1238 1179 1239 #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); 1182 1242 #endif 1183 1243 } … … 1191 1251 1192 1252 #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); 1195 1255 #endif 1196 1256 } … … 1280 1340 //GstFormat fmt = GST_FORMAT_TIME; 1281 1341 1282 if( m_gst_playbin)1342 if(pipeline) 1283 1343 { 1284 1344 len = playergetlength(); … … 1294 1354 playerstop(); 1295 1355 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); 1297 1357 } 1298 1358 #endif … … 1416 1476 //TrackList = tmpTrackList; 1417 1477 1418 if( m_gst_playbin!= NULL)1478 if(pipeline != NULL) 1419 1479 { 1420 1480 gint i, n_video = 0, n_audio = 0, n_text = 0; 1421 1481 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); 1425 1485 1426 1486 switch(type) … … 1434 1494 GstPad* pad = 0; 1435 1495 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); 1437 1497 #if GST_VERSION_MAJOR < 1 1438 1498 GstCaps* caps = gst_pad_get_negotiated_caps(pad); … … 1446 1506 const gchar *g_type = gst_structure_get_name(str); 1447 1507 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); 1449 1509 1450 1510 #if GST_VERSION_MAJOR < 1 … … 1502 1562 // GstPad* pad = 0; 1503 1563 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); 1505 1565 1506 1566 #if GST_VERSION_MAJOR < 1 … … 1525 1585 } 1526 1586 /* 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); 1528 1588 if(pad) 1529 1589 g_signal_connect(G_OBJECT(pad), "notify::caps", G_CALLBACK (gstTextpadHasCAPS), this); … … 1539 1599 gchar *g_codec = NULL, *g_lang = NULL; 1540 1600 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); 1542 1602 1543 1603 #if GST_VERSION_MAJOR < 1 … … 1613 1673 1614 1674 #ifdef EPLAYER4 1615 if( m_gst_playbin!= NULL)1675 if(pipeline != NULL) 1616 1676 { 1617 1677 switch(type) 1618 1678 { 1619 1679 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); 1621 1681 break; 1622 1682 } … … 1646 1706 1647 1707 /* 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); 1651 1711 sec = pts / 1000000000; 1652 1712 pts = sec * 90000; … … 1655 1715 */ 1656 1716 1657 if( m_gst_playbin)1717 if(pipeline) 1658 1718 { 1659 1719 gint64 pos; … … 1661 1721 pts = 0; 1662 1722 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); 1666 1726 if(!sink) return 0; 1667 1727 … … 1674 1734 gst_object_unref(sink); 1675 1735 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)) 1677 1737 return 0; 1678 1738 … … 1706 1766 gint64 len; 1707 1767 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); 1711 1771 length = len / 1000000000; 1712 1772 if(length < 0) length = 0; … … 1752 1812 1753 1813 #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); 1756 1816 #endif 1757 1817 }
Note: See TracChangeset
for help on using the changeset viewer.