Changeset 252950 in webkit
- Timestamp:
- Nov 29, 2019 12:27:08 PM (4 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r252947 r252950 1 2019-11-29 Charlie Turner <cturner@igalia.com> 2 3 [GStreamer] MediaPlayerPrivateGStreamer style cleanups 4 https://bugs.webkit.org/show_bug.cgi?id=204617 5 6 Reviewed by Xabier Rodriguez-Calvar. 7 8 Follow-up commit to bug 204352 addressing style issues in the 9 existing player code. The main issues addressed are naming 10 violations, adding final to types not overridden and organizing 11 better the scope of names in the classes. 12 13 Covered by existing tests. 14 15 * platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp: 16 (WebCore::initializeDebugCategory): 17 (WebCore::MediaPlayerPrivateGStreamer::loadFull): 18 (WebCore::MediaPlayerPrivateGStreamer::prepareToPlay): 19 (WebCore::MediaPlayerPrivateGStreamer::play): 20 (WebCore::MediaPlayerPrivateGStreamer::pause): 21 (WebCore::MediaPlayerPrivateGStreamer::paused const): 22 (WebCore::MediaPlayerPrivateGStreamer::doSeek): 23 (WebCore::MediaPlayerPrivateGStreamer::seek): 24 (WebCore::MediaPlayerPrivateGStreamer::updatePlaybackRate): 25 (WebCore::MediaPlayerPrivateGStreamer::currentMediaTime const): 26 (WebCore::MediaPlayerPrivateGStreamer::setRate): 27 (WebCore::MediaPlayerPrivateGStreamer::setPreservesPitch): 28 (WebCore::MediaPlayerPrivateGStreamer::setPreload): 29 (WebCore::MediaPlayerPrivateGStreamer::buffered const): 30 (WebCore::MediaPlayerPrivateGStreamer::maxMediaTimeSeekable const): 31 (WebCore::MediaPlayerPrivateGStreamer::maxTimeLoaded const): 32 (WebCore::MediaPlayerPrivateGStreamer::didLoadingProgress const): 33 (WebCore::MediaPlayerPrivateGStreamer::totalBytes const): 34 (WebCore::MediaPlayerPrivateGStreamer::changePipelineState): 35 (WebCore::MediaPlayerPrivateGStreamer::notifyPlayerOfVideo): 36 (WebCore::MediaPlayerPrivateGStreamer::notifyPlayerOfAudio): 37 (WebCore::MediaPlayerPrivateGStreamer::notifyPlayerOfText): 38 (WebCore::MediaPlayerPrivateGStreamer::platformDuration const): 39 (WebCore::MediaPlayerPrivateGStreamer::isMuted const): 40 (WebCore::MediaPlayerPrivateGStreamer::commitLoad): 41 (WebCore::MediaPlayerPrivateGStreamer::fillTimerFired): 42 (WebCore::MediaPlayerPrivateGStreamer::loadingFailed): 43 (WebCore::MediaPlayerPrivateGStreamer::playbackPosition const): 44 (WebCore::MediaPlayerPrivateGStreamer::enableTrack): 45 (WebCore::MediaPlayerPrivateGStreamer::updateTracks): 46 (WebCore::MediaPlayerPrivateGStreamer::handleSyncMessage): 47 (WebCore::MediaPlayerPrivateGStreamer::naturalSize const): 48 (WebCore::MediaPlayerPrivateGStreamer::setMuted): 49 (WebCore::MediaPlayerPrivateGStreamer::handleMessage): 50 (WebCore::MediaPlayerPrivateGStreamer::updateBufferingStatus): 51 (WebCore::MediaPlayerPrivateGStreamer::processMpegTsSection): 52 (WebCore::MediaPlayerPrivateGStreamer::processTableOfContentsEntry): 53 (WebCore::MediaPlayerPrivateGStreamer::asyncStateChangeDone): 54 (WebCore::MediaPlayerPrivateGStreamer::updateStates): 55 (WebCore::MediaPlayerPrivateGStreamer::loadNextLocation): 56 (WebCore::MediaPlayerPrivateGStreamer::didEnd): 57 (WebCore::MediaPlayerPrivateGStreamer::updateDownloadBufferingFlag): 58 (WebCore::MediaPlayerPrivateGStreamer::createGSTPlayBin): 59 (WebCore::MediaPlayerPrivateGStreamer::canSaveMediaData const): 60 (WebCore::MediaPlayerPrivateGStreamer::acceleratedRenderingStateChanged): 61 (WebCore::MediaPlayerPrivateGStreamer::pushTextureToCompositor): 62 (WebCore::MediaPlayerPrivateGStreamer::triggerRepaint): 63 (WebCore::MediaPlayerPrivateGStreamer::cancelRepaint): 64 (WebCore::MediaPlayerPrivateGStreamer::paint): 65 (WebCore::MediaPlayerPrivateGStreamer::copyVideoTextureToPlatformTexture): 66 (WebCore::MediaPlayerPrivateGStreamer::nativeImageForCurrentTime): 67 (WebCore::MediaPlayerPrivateGStreamer::movieLoadType const): 68 (WebCore::MediaPlayerPrivateGStreamer::createVideoSink): 69 (WebCore::MediaPlayerPrivateGStreamer::decodedFrameCount const): 70 (WebCore::MediaPlayerPrivateGStreamer::droppedFrameCount const): 71 (WebCore::MediaPlayerPrivateGStreamer::attemptToDecryptWithLocalInstance): 72 (WebCore::MediaPlayerPrivateGStreamer::setWaitingForKey): 73 (WebCore::MediaPlayerPrivateGStreamer::initializeDebugCategory): Deleted. 74 (WebCore::MediaPlayerPrivateGStreamer::sizeChanged): Deleted. 75 (WebCore::MediaPlayerPrivateGStreamer::muted const): Deleted. 76 * platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.h: 77 (WebCore::MediaPlayerPrivateGStreamer::pipeline const): 78 (WebCore::MediaPlayerPrivateGStreamer::mediaPlayer const): Deleted. 79 (WebCore::MediaPlayerPrivateGStreamer::isLiveStream const): Deleted. 80 * platform/graphics/gstreamer/mse/MediaPlayerPrivateGStreamerMSE.cpp: 81 (WebCore::MediaPlayerPrivateGStreamerMSE::pause): 82 (WebCore::MediaPlayerPrivateGStreamerMSE::durationMediaTime const): 83 (WebCore::MediaPlayerPrivateGStreamerMSE::seek): 84 (WebCore::MediaPlayerPrivateGStreamerMSE::doSeek): 85 (WebCore::MediaPlayerPrivateGStreamerMSE::maybeFinishSeek): 86 (WebCore::MediaPlayerPrivateGStreamerMSE::seeking const): 87 (WebCore::MediaPlayerPrivateGStreamerMSE::waitForSeekCompleted): 88 (WebCore::MediaPlayerPrivateGStreamerMSE::updateStates): 89 (WebCore::MediaPlayerPrivateGStreamerMSE::asyncStateChangeDone): 90 (WebCore::MediaPlayerPrivateGStreamerMSE::maxMediaTimeSeekable const): 91 * platform/graphics/gstreamer/mse/MediaPlayerPrivateGStreamerMSE.h: 92 * platform/graphics/gstreamer/mse/MediaSourceClientGStreamerMSE.cpp: 93 (WebCore::MediaSourceClientGStreamerMSE::flush): 94 1 95 2019-11-29 Zalan Bujtas <zalan@apple.com> 2 96 -
trunk/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp
r252938 r252950 337 337 #endif 338 338 339 void MediaPlayerPrivateGStreamer::initializeDebugCategory() 340 { 341 GST_DEBUG_CATEGORY_INIT(webkit_media_player_debug, "webkitmediaplayer", 0, "WebKit media player"); 339 static void initializeDebugCategory() 340 { 341 static std::once_flag onceFlag; 342 std::call_once(onceFlag, [] { 343 GST_DEBUG_CATEGORY_INIT(webkit_media_player_debug, "webkitmediaplayer", 0, "WebKit media player"); 344 }); 342 345 } 343 346 … … 498 501 if (m_preload == MediaPlayer::None) { 499 502 GST_INFO_OBJECT(pipeline(), "Delaying load."); 500 m_ delayingLoad = true;503 m_isDelayingLoad = true; 501 504 } 502 505 … … 507 510 m_readyState = MediaPlayer::HaveNothing; 508 511 m_player->readyStateChanged(); 509 m_ volumeAndMuteInitialized = false;512 m_areVolumeAndMuteInitialized = false; 510 513 m_hasTaintedOrigin = WTF::nullopt; 511 514 512 if (!m_ delayingLoad)515 if (!m_isDelayingLoad) 513 516 commitLoad(); 514 517 } … … 542 545 #endif 543 546 544 void MediaPlayerPrivateGStreamer::commitLoad()545 {546 ASSERT(!m_delayingLoad);547 GST_DEBUG_OBJECT(pipeline(), "Committing load.");548 549 // GStreamer needs to have the pipeline set to a paused state to550 // start providing anything useful.551 changePipelineState(GST_STATE_PAUSED);552 553 updateDownloadBufferingFlag();554 updateStates();555 }556 557 547 void MediaPlayerPrivateGStreamer::cancelLoad() 558 548 { … … 568 558 GST_DEBUG_OBJECT(pipeline(), "Prepare to play"); 569 559 m_preload = MediaPlayer::Auto; 570 if (m_ delayingLoad) {571 m_ delayingLoad = false;560 if (m_isDelayingLoad) { 561 m_isDelayingLoad = false; 572 562 commitLoad(); 573 563 } … … 577 567 { 578 568 if (!m_playbackRate) { 579 m_ playbackRatePause= true;569 m_isPlaybackRatePaused = true; 580 570 return; 581 571 } … … 583 573 if (changePipelineState(GST_STATE_PLAYING)) { 584 574 m_isEndReached = false; 585 m_ delayingLoad = false;575 m_isDelayingLoad = false; 586 576 m_preload = MediaPlayer::Auto; 587 577 updateDownloadBufferingFlag(); … … 593 583 void MediaPlayerPrivateGStreamer::pause() 594 584 { 595 m_ playbackRatePause= false;585 m_isPlaybackRatePaused = false; 596 586 GstState currentState, pendingState; 597 587 gst_element_get_state(m_pipeline.get(), ¤tState, &pendingState, 0); … … 615 605 } 616 606 617 if (m_ playbackRatePause) {607 if (m_isPlaybackRatePaused) { 618 608 GST_DEBUG_OBJECT(pipeline(), "Playback rate is 0, simulating PAUSED state"); 619 609 return false; … … 634 624 if (rate < 0) { 635 625 startTime = MediaTime::zeroTime(); 636 // If we are at beginning of media, start from the end to 637 // avoid immediate EOS. 638 if (position < MediaTime::zeroTime()) 639 endTime = durationMediaTime(); 640 else 641 endTime = position; 626 // If we are at beginning of media, start from the end to avoid immediate EOS. 627 endTime = position < MediaTime::zeroTime() ? durationMediaTime() : position; 642 628 } 643 629 … … 651 637 void MediaPlayerPrivateGStreamer::seek(const MediaTime& mediaTime) 652 638 { 653 if (!m_pipeline) 654 return; 655 656 if (m_errorOccured) 639 if (!m_pipeline || m_didErrorOccur) 657 640 return; 658 641 … … 667 650 MediaTime time = std::min(mediaTime, durationMediaTime()); 668 651 669 if ( isLiveStream()) {652 if (m_isLiveStream) { 670 653 GST_DEBUG_OBJECT(pipeline(), "[Seek] Live stream seek unhandled"); 671 654 return; … … 674 657 GST_INFO_OBJECT(pipeline(), "[Seek] seeking to %s", toString(time).utf8().data()); 675 658 676 if (m_ seeking) {659 if (m_isSeeking) { 677 660 m_timeOfOverlappingSeek = time; 678 if (m_ seekIsPending) {661 if (m_isSeekPending) { 679 662 m_seekTime = time; 680 663 return; … … 689 672 } 690 673 if (getStateResult == GST_STATE_CHANGE_ASYNC || state < GST_STATE_PAUSED || m_isEndReached) { 691 m_ seekIsPending = true;674 m_isSeekPending = true; 692 675 if (m_isEndReached) { 693 676 GST_DEBUG_OBJECT(pipeline(), "[Seek] reset pipeline"); 694 m_ resetPipeline = true;677 m_shouldResetPipeline = true; 695 678 if (!changePipelineState(GST_STATE_PAUSED)) 696 679 loadingFailed(MediaPlayer::Empty); … … 704 687 } 705 688 706 m_ seeking = true;689 m_isSeeking = true; 707 690 m_seekTime = time; 708 691 m_isEndReached = false; … … 711 694 void MediaPlayerPrivateGStreamer::updatePlaybackRate() 712 695 { 713 if (!m_ changingRate)696 if (!m_isChangingRate) 714 697 return; 715 698 … … 717 700 718 701 // Mute the sound if the playback rate is negative or too extreme and audio pitch is not adjusted. 719 bool mute = m_playbackRate <= 0 || (!m_ preservesPitch && (m_playbackRate < 0.8 || m_playbackRate > 2));702 bool mute = m_playbackRate <= 0 || (!m_shouldPreservePitch && (m_playbackRate < 0.8 || m_playbackRate > 2)); 720 703 721 704 GST_INFO_OBJECT(pipeline(), mute ? "Need to mute audio" : "Do not need to mute audio"); … … 729 712 } 730 713 731 if (m_playbackRatePause) { 732 GstState state; 733 GstState pending; 714 if (m_isPlaybackRatePaused) { 715 GstState state, pending; 734 716 735 717 gst_element_get_state(m_pipeline.get(), &state, &pending, 0); 736 718 if (state != GST_STATE_PLAYING && pending != GST_STATE_PLAYING) 737 719 changePipelineState(GST_STATE_PLAYING); 738 m_ playbackRatePause= false;739 } 740 741 m_ changingRate = false;720 m_isPlaybackRatePaused = false; 721 } 722 723 m_isChangingRate = false; 742 724 m_player->rateChanged(); 743 }744 745 MediaTime MediaPlayerPrivateGStreamer::platformDuration() const746 {747 if (!m_pipeline)748 return MediaTime::invalidTime();749 750 GST_TRACE_OBJECT(pipeline(), "errorOccured: %s, pipeline state: %s", boolForPrinting(m_errorOccured), gst_element_state_get_name(GST_STATE(m_pipeline.get())));751 if (m_errorOccured)752 return MediaTime::invalidTime();753 754 // The duration query would fail on a not-prerolled pipeline.755 if (GST_STATE(m_pipeline.get()) < GST_STATE_PAUSED)756 return MediaTime::invalidTime();757 758 int64_t duration = 0;759 if (!gst_element_query_duration(m_pipeline.get(), GST_FORMAT_TIME, &duration) || !GST_CLOCK_TIME_IS_VALID(duration)) {760 GST_DEBUG_OBJECT(pipeline(), "Time duration query failed for %s", m_url.string().utf8().data());761 return MediaTime::positiveInfiniteTime();762 }763 764 GST_LOG_OBJECT(pipeline(), "Duration: %" GST_TIME_FORMAT, GST_TIME_ARGS(duration));765 return MediaTime(duration, GST_SECOND);766 725 } 767 726 … … 783 742 MediaTime MediaPlayerPrivateGStreamer::currentMediaTime() const 784 743 { 785 if (!m_pipeline || m_ errorOccured)744 if (!m_pipeline || m_didErrorOccur) 786 745 return MediaTime::invalidTime(); 787 746 788 GST_TRACE_OBJECT(pipeline(), "seeking: %s, seekTime: %s", boolForPrinting(m_ seeking), m_seekTime.toString().utf8().data());789 if (m_ seeking)747 GST_TRACE_OBJECT(pipeline(), "seeking: %s, seekTime: %s", boolForPrinting(m_isSeeking), m_seekTime.toString().utf8().data()); 748 if (m_isSeeking) 790 749 return m_seekTime; 791 750 … … 795 754 void MediaPlayerPrivateGStreamer::setRate(float rate) 796 755 { 797 // Higher rate causes crash. 798 rate = clampTo(rate, -20.0, 20.0); 756 float rateClamped = clampTo(rate, -20.0, 20.0); 757 if (rateClamped != rate) 758 GST_WARNING("Clamping original rate (%f) to [-20, 20] (%f), higher rates cause crashes", rate, rateClamped); 799 759 800 760 // Avoid useless playback rate update. 801 if (m_playbackRate == rate ) {802 // and make sure that upper layers were notified if rate was set803 804 if (!m_ changingRate && m_player->rate() != m_playbackRate)761 if (m_playbackRate == rateClamped) { 762 // And make sure that upper layers were notified if rate was set. 763 764 if (!m_isChangingRate && m_player->rate() != m_playbackRate) 805 765 m_player->rateChanged(); 806 766 return; 807 767 } 808 768 809 if ( isLiveStream()) {810 // notify upper layers that we cannot handle passed rate.811 m_ changingRate = false;769 if (m_isLiveStream) { 770 // Notify upper layers that we cannot handle passed rate. 771 m_isChangingRate = false; 812 772 m_player->rateChanged(); 813 773 return; 814 774 } 815 775 816 GstState state; 817 GstState pending; 818 819 m_playbackRate = rate; 820 m_changingRate = true; 776 GstState state, pending; 777 778 m_playbackRate = rateClamped; 779 m_isChangingRate = true; 821 780 822 781 gst_element_get_state(m_pipeline.get(), &state, &pending, 0); 823 782 824 if (!rate ) {825 m_ changingRate = false;826 m_ playbackRatePause= true;783 if (!rateClamped) { 784 m_isChangingRate = false; 785 m_isPlaybackRatePaused = true; 827 786 if (state != GST_STATE_PAUSED && pending != GST_STATE_PAUSED) 828 787 changePipelineState(GST_STATE_PAUSED); … … 844 803 void MediaPlayerPrivateGStreamer::setPreservesPitch(bool preservesPitch) 845 804 { 846 m_ preservesPitch = preservesPitch;805 m_shouldPreservePitch = preservesPitch; 847 806 } 848 807 … … 850 809 { 851 810 GST_DEBUG_OBJECT(pipeline(), "Setting preload to %s", convertEnumerationToString(preload).utf8().data()); 852 if (preload == MediaPlayer::Auto && isLiveStream())811 if (preload == MediaPlayer::Auto && m_isLiveStream) 853 812 return; 854 813 … … 856 815 updateDownloadBufferingFlag(); 857 816 858 if (m_ delayingLoad && m_preload != MediaPlayer::None) {859 m_ delayingLoad = false;817 if (m_isDelayingLoad && m_preload != MediaPlayer::None) { 818 m_isDelayingLoad = false; 860 819 commitLoad(); 861 820 } … … 865 824 { 866 825 auto timeRanges = makeUnique<PlatformTimeRanges>(); 867 if (m_ errorOccured || isLiveStream())826 if (m_didErrorOccur || m_isLiveStream) 868 827 return timeRanges; 869 828 … … 877 836 return timeRanges; 878 837 879 guintnumBufferingRanges = gst_query_get_n_buffering_ranges(query.get());880 for ( guintindex = 0; index < numBufferingRanges; index++) {838 unsigned numBufferingRanges = gst_query_get_n_buffering_ranges(query.get()); 839 for (unsigned index = 0; index < numBufferingRanges; index++) { 881 840 gint64 rangeStart = 0, rangeStop = 0; 882 841 if (gst_query_parse_nth_buffering_range(query.get(), index, &rangeStart, &rangeStop)) { … … 887 846 } 888 847 889 // Fallback to the more general maxTimeLoaded() if no range has 890 // been found. 848 // Fallback to the more general maxTimeLoaded() if no range has been found. 891 849 if (!timeRanges->length()) { 892 850 MediaTime loaded = maxTimeLoaded(); … … 900 858 MediaTime MediaPlayerPrivateGStreamer::maxMediaTimeSeekable() const 901 859 { 902 GST_TRACE_OBJECT(pipeline(), "errorOccured: %s, isLiveStream: %s", boolForPrinting(m_ errorOccured), boolForPrinting(isLiveStream()));903 if (m_ errorOccured)860 GST_TRACE_OBJECT(pipeline(), "errorOccured: %s, isLiveStream: %s", boolForPrinting(m_didErrorOccur), boolForPrinting(m_isLiveStream)); 861 if (m_didErrorOccur) 904 862 return MediaTime::zeroTime(); 905 863 906 if ( isLiveStream())864 if (m_isLiveStream) 907 865 return MediaTime::zeroTime(); 908 866 909 867 MediaTime duration = durationMediaTime(); 910 868 GST_DEBUG_OBJECT(pipeline(), "maxMediaTimeSeekable, duration: %s", toString(duration).utf8().data()); 911 // infinite duration means live stream869 // Infinite duration means live stream. 912 870 if (duration.isPositiveInfinite()) 913 871 return MediaTime::zeroTime(); … … 918 876 MediaTime MediaPlayerPrivateGStreamer::maxTimeLoaded() const 919 877 { 920 if (m_ errorOccured)878 if (m_didErrorOccur) 921 879 return MediaTime::zeroTime(); 922 880 … … 930 888 bool MediaPlayerPrivateGStreamer::didLoadingProgress() const 931 889 { 932 if (m_ errorOccured|| m_loadingStalled)890 if (m_didErrorOccur || m_loadingStalled) 933 891 return false; 934 892 … … 953 911 unsigned long long MediaPlayerPrivateGStreamer::totalBytes() const 954 912 { 955 if (m_ errorOccured)913 if (m_didErrorOccur || !m_source || m_isLiveStream) 956 914 return 0; 957 915 958 916 if (m_totalBytes) 959 917 return m_totalBytes; 960 961 if (!m_source)962 return 0;963 964 if (isLiveStream())965 return 0;966 918 967 919 GstFormat fmt = GST_FORMAT_BYTES; … … 970 922 GST_INFO_OBJECT(pipeline(), "totalBytes %" G_GINT64_FORMAT, length); 971 923 m_totalBytes = static_cast<unsigned long long>(length); 972 m_is Streaming= !length;924 m_isLiveStream = !length; 973 925 return m_totalBytes; 974 926 } 975 927 976 // Fall back to querying the source pads manually. 977 // See also https://bugzilla.gnome.org/show_bug.cgi?id=638749 928 // Fall back to querying the source pads manually. See also https://bugzilla.gnome.org/show_bug.cgi?id=638749 978 929 GstIterator* iter = gst_element_iterate_src_pads(m_source.get()); 979 930 bool done = false; … … 1005 956 GST_INFO_OBJECT(pipeline(), "totalBytes %" G_GINT64_FORMAT, length); 1006 957 m_totalBytes = static_cast<unsigned long long>(length); 1007 m_is Streaming= !length;958 m_isLiveStream = !length; 1008 959 return m_totalBytes; 1009 960 } … … 1130 1081 ASSERT(m_pipeline); 1131 1082 1132 GstState currentState; 1133 GstState pending; 1083 GstState currentState, pending; 1134 1084 1135 1085 gst_element_get_state(m_pipeline.get(), ¤tState, &pending, 0); … … 1148 1098 return false; 1149 1099 1150 // Create a timer when entering the READY state so that we can free resources 1151 // if we stay for too long on READY. 1152 // Also lets remove the timer if we request a state change for any state other than READY. 1153 // See also https://bugs.webkit.org/show_bug.cgi?id=117354 1100 // Create a timer when entering the READY state so that we can free resources if we stay for too long on READY. 1101 // Also lets remove the timer if we request a state change for any state other than READY. See also https://bugs.webkit.org/show_bug.cgi?id=117354 1154 1102 if (newState == GST_STATE_READY && !m_readyTimerHandler.isActive()) { 1155 // Max interval in seconds to stay in the READY state on manual 1156 // state change requests. 1103 // Max interval in seconds to stay in the READY state on manual state change requests. 1157 1104 static const Seconds readyStateTimerDelay { 1_min }; 1158 1105 m_readyTimerHandler.startOneShot(readyStateTimerDelay); … … 1205 1152 ASSERT(m_isLegacyPlaybin || isMediaSource()); 1206 1153 1207 gintnumTracks = 0;1154 unsigned numTracks = 0; 1208 1155 bool useMediaSource = isMediaSource(); 1209 1156 GstElement* element = useMediaSource ? m_source.get() : m_pipeline.get(); … … 1228 1175 #if ENABLE(VIDEO_TRACK) 1229 1176 Vector<String> validVideoStreams; 1230 for ( ginti = 0; i < numTracks; ++i) {1177 for (unsigned i = 0; i < numTracks; ++i) { 1231 1178 GRefPtr<GstPad> pad; 1232 1179 g_signal_emit_by_name(m_pipeline.get(), "get-video-pad", i, &pad.outPtr(), nullptr); … … 1235 1182 String streamId = "V" + String::number(i); 1236 1183 validVideoStreams.append(streamId); 1237 if (i < static_cast<gint>(m_videoTracks.size())) {1184 if (i < m_videoTracks.size()) { 1238 1185 RefPtr<VideoTrackPrivateGStreamer> existingTrack = m_videoTracks.get(streamId); 1239 1186 if (existingTrack) { … … 1283 1230 ASSERT(m_isLegacyPlaybin || isMediaSource()); 1284 1231 1285 gintnumTracks = 0;1232 unsigned numTracks = 0; 1286 1233 bool useMediaSource = isMediaSource(); 1287 1234 GstElement* element = useMediaSource ? m_source.get() : m_pipeline.get(); … … 1302 1249 #if ENABLE(VIDEO_TRACK) 1303 1250 Vector<String> validAudioStreams; 1304 for ( ginti = 0; i < numTracks; ++i) {1251 for (unsigned i = 0; i < numTracks; ++i) { 1305 1252 GRefPtr<GstPad> pad; 1306 1253 g_signal_emit_by_name(m_pipeline.get(), "get-audio-pad", i, &pad.outPtr(), nullptr); … … 1309 1256 String streamId = "A" + String::number(i); 1310 1257 validAudioStreams.append(streamId); 1311 if (i < static_cast<gint>(m_audioTracks.size())) {1258 if (i < m_audioTracks.size()) { 1312 1259 RefPtr<AudioTrackPrivateGStreamer> existingTrack = m_audioTracks.get(streamId); 1313 1260 if (existingTrack) { … … 1345 1292 ASSERT(m_isLegacyPlaybin || isMediaSource()); 1346 1293 1347 gintnumTracks = 0;1294 unsigned numTracks = 0; 1348 1295 bool useMediaSource = isMediaSource(); 1349 1296 GstElement* element = useMediaSource ? m_source.get() : m_pipeline.get(); … … 1358 1305 1359 1306 Vector<String> validTextStreams; 1360 for ( ginti = 0; i < numTracks; ++i) {1307 for (unsigned i = 0; i < numTracks; ++i) { 1361 1308 GRefPtr<GstPad> pad; 1362 1309 g_signal_emit_by_name(m_pipeline.get(), "get-text-pad", i, &pad.outPtr(), nullptr); … … 1370 1317 1371 1318 validTextStreams.append(streamId); 1372 if (i < static_cast<gint>(m_textTracks.size())) {1319 if (i < m_textTracks.size()) { 1373 1320 RefPtr<InbandTextTrackPrivateGStreamer> existingTrack = m_textTracks.get(streamId); 1374 1321 if (existingTrack) { … … 1423 1370 #endif 1424 1371 1372 MediaTime MediaPlayerPrivateGStreamer::platformDuration() const 1373 { 1374 if (!m_pipeline) 1375 return MediaTime::invalidTime(); 1376 1377 GST_TRACE_OBJECT(pipeline(), "errorOccured: %s, pipeline state: %s", boolForPrinting(m_didErrorOccur), gst_element_state_get_name(GST_STATE(m_pipeline.get()))); 1378 if (m_didErrorOccur) 1379 return MediaTime::invalidTime(); 1380 1381 // The duration query would fail on a not-prerolled pipeline. 1382 if (GST_STATE(m_pipeline.get()) < GST_STATE_PAUSED) 1383 return MediaTime::invalidTime(); 1384 1385 int64_t duration = 0; 1386 if (!gst_element_query_duration(m_pipeline.get(), GST_FORMAT_TIME, &duration) || !GST_CLOCK_TIME_IS_VALID(duration)) { 1387 GST_DEBUG_OBJECT(pipeline(), "Time duration query failed for %s", m_url.string().utf8().data()); 1388 return MediaTime::positiveInfiniteTime(); 1389 } 1390 1391 GST_LOG_OBJECT(pipeline(), "Duration: %" GST_TIME_FORMAT, GST_TIME_ARGS(duration)); 1392 return MediaTime(duration, GST_SECOND); 1393 } 1394 1395 bool MediaPlayerPrivateGStreamer::isMuted() const 1396 { 1397 if (!m_volumeElement) 1398 return false; 1399 1400 gboolean isMuted; 1401 g_object_get(m_volumeElement.get(), "mute", &isMuted, nullptr); 1402 GST_INFO_OBJECT(pipeline(), "Player is muted: %s", boolForPrinting(!!isMuted)); 1403 return isMuted; 1404 } 1405 1406 void MediaPlayerPrivateGStreamer::commitLoad() 1407 { 1408 ASSERT(!m_isDelayingLoad); 1409 GST_DEBUG_OBJECT(pipeline(), "Committing load."); 1410 1411 // GStreamer needs to have the pipeline set to a paused state to 1412 // start providing anything useful. 1413 changePipelineState(GST_STATE_PAUSED); 1414 1415 updateDownloadBufferingFlag(); 1416 updateStates(); 1417 } 1418 1425 1419 void MediaPlayerPrivateGStreamer::fillTimerFired() 1426 1420 { 1427 if (m_ errorOccured) {1421 if (m_didErrorOccur) { 1428 1422 GST_DEBUG_OBJECT(pipeline(), "[Buffering] An error occurred, disabling the fill timer"); 1429 1423 m_fillTimer.stop(); … … 1467 1461 GST_WARNING("Loading failed, error: %s", convertEnumerationToString(networkError).utf8().data()); 1468 1462 1469 m_ errorOccured= true;1463 m_didErrorOccur = true; 1470 1464 if (forceNotifications || m_networkState != networkError) { 1471 1465 m_networkState = networkError; … … 1510 1504 MediaTime MediaPlayerPrivateGStreamer::playbackPosition() const 1511 1505 { 1512 GST_TRACE_OBJECT(pipeline(), "isEndReached: %s, seeking: %s, seekTime: %s", boolForPrinting(m_isEndReached), boolForPrinting(m_ seeking), m_seekTime.toString().utf8().data());1513 if (m_isEndReached && m_ seeking)1506 GST_TRACE_OBJECT(pipeline(), "isEndReached: %s, seeking: %s, seekTime: %s", boolForPrinting(m_isEndReached), boolForPrinting(m_isSeeking), m_seekTime.toString().utf8().data()); 1507 if (m_isEndReached && m_isSeeking) 1514 1508 return m_seekTime; 1515 1509 … … 1531 1525 gst_query_unref(query); 1532 1526 1533 GST_TRACE_OBJECT(pipeline(), "Position %" GST_TIME_FORMAT ", canFallBackToLastFinishedSeekPosition: %s", GST_TIME_ARGS(position), boolForPrinting(m_canFallBackToLastFinishedSeekPosition)); 1527 GstClockTime gstreamerPosition = static_cast<GstClockTime>(position); 1528 GST_TRACE_OBJECT(pipeline(), "Position %" GST_TIME_FORMAT ", canFallBackToLastFinishedSeekPosition: %s", GST_TIME_ARGS(gstreamerPosition), boolForPrinting(m_canFallBackToLastFinishedSeekPosition)); 1534 1529 1535 1530 MediaTime playbackPosition = MediaTime::zeroTime(); 1536 GstClockTime gstreamerPosition = static_cast<GstClockTime>(position); 1531 1537 1532 if (GST_CLOCK_TIME_IS_VALID(gstreamerPosition)) 1538 1533 playbackPosition = MediaTime(gstreamerPosition, GST_SECOND); … … 1610 1605 break; 1611 1606 case TrackPrivateBaseGStreamer::TrackType::Unknown: 1607 FALLTHROUGH; 1612 1608 default: 1613 1609 ASSERT_NOT_REACHED(); … … 1661 1657 } 1662 1658 1663 if ( (oldHasVideo != m_hasVideo) || (oldHasAudio != m_hasAudio))1659 if (oldHasVideo != m_hasVideo || oldHasAudio != m_hasAudio) 1664 1660 m_player->characteristicChanged(); 1665 1661 … … 1721 1717 1722 1718 const gchar* contextType; 1723 gst_message_parse_context_type(message, &contextType); 1719 if (!gst_message_parse_context_type(message, &contextType)) 1720 return false; 1721 1724 1722 GST_DEBUG_OBJECT(pipeline(), "Handling %s need-context message for %s", contextType, GST_MESSAGE_SRC_NAME(message)); 1725 1723 … … 1772 1770 gst_element_set_context(GST_ELEMENT(GST_MESSAGE_SRC(message)), context.get()); 1773 1771 } else 1774 GST_WARNING("CDM instance not initializ aed");1772 GST_WARNING("CDM instance not initialized"); 1775 1773 1776 1774 return true; … … 1782 1780 } 1783 1781 1784 // Returns the size of the video 1782 // Returns the size of the video. 1785 1783 FloatSize MediaPlayerPrivateGStreamer::naturalSize() const 1786 1784 { … … 1820 1818 return FloatSize(); 1821 1819 1822 // TODO: handle possible clean aperture data. See 1823 // https://bugzilla.gnome.org/show_bug.cgi?id=596571 1824 // TODO: handle possible transformation matrix. See 1825 // https://bugzilla.gnome.org/show_bug.cgi?id=596326 1820 // TODO: handle possible clean aperture data. See https://bugzilla.gnome.org/show_bug.cgi?id=596571 1821 // TODO: handle possible transformation matrix. See https://bugzilla.gnome.org/show_bug.cgi?id=596326 1826 1822 1827 1823 // Get the video PAR and original size, if this fails the … … 1835 1831 #if USE(TEXTURE_MAPPER_GL) 1836 1832 // When using accelerated compositing, if the video is tagged as rotated 90 or 270 degrees, swap width and height. 1837 if (m_ renderingCanBeAccelerated) {1833 if (m_canRenderingBeAccelerated) { 1838 1834 if (m_videoSourceOrientation.usesWidthAsHeight()) 1839 1835 originalSize = originalSize.transposedSize(); … … 1854 1850 1855 1851 // Apply DAR to original video size. This is the same behavior as in xvimagesink's setcaps function. 1856 guint64width = 0, height = 0;1852 uint64_t width = 0, height = 0; 1857 1853 if (!(originalSize.height() % displayHeight)) { 1858 1854 GST_DEBUG_OBJECT(pipeline(), "Keeping video original height"); 1859 1855 width = gst_util_uint64_scale_int(originalSize.height(), displayWidth, displayHeight); 1860 height = static_cast<guint64>(originalSize.height());1856 height = originalSize.height(); 1861 1857 } else if (!(originalSize.width() % displayWidth)) { 1862 1858 GST_DEBUG_OBJECT(pipeline(), "Keeping video original width"); 1863 1859 height = gst_util_uint64_scale_int(originalSize.width(), displayHeight, displayWidth); 1864 width = static_cast<guint64>(originalSize.width());1860 width = originalSize.width(); 1865 1861 } else { 1866 1862 GST_DEBUG_OBJECT(pipeline(), "Approximating while keeping original video height"); 1867 1863 width = gst_util_uint64_scale_int(originalSize.height(), displayWidth, displayHeight); 1868 height = static_cast<guint64>(originalSize.height());1864 height = originalSize.height(); 1869 1865 } 1870 1866 … … 1924 1920 } 1925 1921 1926 void MediaPlayerPrivateGStreamer::sizeChanged() 1927 { 1928 notImplemented(); 1929 } 1930 1931 void MediaPlayerPrivateGStreamer::setMuted(bool mute) 1932 { 1933 if (!m_volumeElement) 1934 return; 1935 1936 bool currentValue = muted(); 1937 if (currentValue == mute) 1938 return; 1939 1940 GST_INFO_OBJECT(pipeline(), "Set muted to %s", toString(mute).utf8().data()); 1941 g_object_set(m_volumeElement.get(), "mute", mute, nullptr); 1942 } 1943 1944 bool MediaPlayerPrivateGStreamer::muted() const 1945 { 1946 if (!m_volumeElement) 1947 return false; 1948 1949 gboolean muted; 1950 g_object_get(m_volumeElement.get(), "mute", &muted, nullptr); 1951 GST_INFO_OBJECT(pipeline(), "Player is muted: %s", toString(static_cast<bool>(muted)).utf8().data()); 1952 return muted; 1922 void MediaPlayerPrivateGStreamer::setMuted(bool shouldMute) 1923 { 1924 if (!m_volumeElement || shouldMute == isMuted()) 1925 return; 1926 1927 GST_INFO_OBJECT(pipeline(), "Muted? %s", boolForPrinting(shouldMute)); 1928 g_object_set(m_volumeElement.get(), "mute", shouldMute, nullptr); 1953 1929 } 1954 1930 … … 2000 1976 switch (GST_MESSAGE_TYPE(message)) { 2001 1977 case GST_MESSAGE_ERROR: 2002 if (m_ resetPipeline || !m_missingPluginCallbacks.isEmpty() || m_errorOccured)1978 if (m_shouldResetPipeline || !m_missingPluginCallbacks.isEmpty() || m_didErrorOccur) 2003 1979 break; 2004 1980 gst_message_parse_error(message, &err.outPtr(), &debug.outPtr()); … … 2015 1991 error = MediaPlayer::FormatError; 2016 1992 else if (g_error_matches(err.get(), GST_STREAM_ERROR, GST_STREAM_ERROR_TYPE_NOT_FOUND)) { 2017 // Let the mediaPlayerClient handle the stream error, in 2018 // this case the HTMLMediaElement will emit a stalled 2019 // event. 1993 // Let the mediaPlayerClient handle the stream error, in this case the HTMLMediaElement will emit a stalled event. 2020 1994 GST_ERROR("Decode error, let the Media element emit a stalled event."); 2021 1995 m_loadingStalled = true; … … 2030 2004 issueError = !loadNextLocation(); 2031 2005 if (issueError) { 2032 m_ errorOccured= true;2006 m_didErrorOccur = true; 2033 2007 if (m_networkState != error) { 2034 2008 m_networkState = error; … … 2041 2015 break; 2042 2016 case GST_MESSAGE_ASYNC_DONE: 2043 if (!messageSourceIsPlaybin || m_ delayingLoad)2017 if (!messageSourceIsPlaybin || m_isDelayingLoad) 2044 2018 break; 2045 2019 asyncStateChangeDone(); 2046 2020 break; 2047 2021 case GST_MESSAGE_STATE_CHANGED: { 2048 if (!messageSourceIsPlaybin || m_ delayingLoad)2022 if (!messageSourceIsPlaybin || m_isDelayingLoad) 2049 2023 break; 2050 2024 updateStates(); … … 2177 2151 } 2178 2152 if (!isRangeRequest) { 2179 m_is Streaming= !contentLength;2180 GST_INFO_OBJECT(pipeline(), "%s stream detected", m_is Streaming? "Live" : "Non-live");2153 m_isLiveStream = !contentLength; 2154 GST_INFO_OBJECT(pipeline(), "%s stream detected", m_isLiveStream ? "Live" : "Non-live"); 2181 2155 updateDownloadBufferingFlag(); 2182 2156 } … … 2286 2260 GST_DEBUG_OBJECT(pipeline(), "[Buffering] mode: %s, status: %f%%", enumToString(GST_TYPE_BUFFERING_MODE, mode).data(), percentage); 2287 2261 2288 m_d ownloadFinished= percentage == 100;2289 m_ buffering = !m_downloadFinished;2262 m_didDownloadFinish = percentage == 100; 2263 m_isBuffering = !m_didDownloadFinish; 2290 2264 2291 2265 switch (mode) { … … 2294 2268 2295 2269 m_bufferingPercentage = percentage; 2296 if (m_d ownloadFinished)2270 if (m_didDownloadFinish) 2297 2271 updateStates(); 2298 2272 … … 2304 2278 // Media is now fully loaded. It will play even if network connection is 2305 2279 // cut. Buffering is done, remove the fill source from the main loop. 2306 if (m_d ownloadFinished)2280 if (m_didDownloadFinish) 2307 2281 m_fillTimer.stop(); 2308 2282 … … 2324 2298 const GstMpegtsPMT* pmt = gst_mpegts_section_get_pmt(section); 2325 2299 m_metadataTracks.clear(); 2326 for ( guinti = 0; i < pmt->streams->len; ++i) {2300 for (unsigned i = 0; i < pmt->streams->len; ++i) { 2327 2301 const GstMpegtsPMTStream* stream = static_cast<const GstMpegtsPMTStream*>(g_ptr_array_index(pmt->streams, i)); 2328 2302 if (stream->stream_type == 0x05 || stream->stream_type >= 0x80) { … … 2343 2317 String inbandMetadataTrackDispatchType; 2344 2318 appendUnsignedAsHexFixedSize(stream->stream_type, inbandMetadataTrackDispatchType, 2); 2345 for ( guintj = 0; j < stream->descriptors->len; ++j) {2319 for (unsigned j = 0; j < stream->descriptors->len; ++j) { 2346 2320 const GstMpegtsDescriptor* descriptor = static_cast<const GstMpegtsDescriptor*>(g_ptr_array_index(stream->descriptors, j)); 2347 for ( guintk = 0; k < descriptor->length; ++k)2321 for (unsigned k = 0; k < descriptor->length; ++k) 2348 2322 appendByteAsHex(descriptor->data[k], inbandMetadataTrackDispatchType); 2349 2323 } … … 2395 2369 gint64 start = -1, stop = -1; 2396 2370 gst_toc_entry_get_start_stop_times(entry, &start, &stop); 2371 2372 uint32_t truncatedGstSecond = static_cast<uint32_t>(GST_SECOND); 2397 2373 if (start != -1) 2398 cue->setStartTime(MediaTime(sta rt, GST_SECOND));2374 cue->setStartTime(MediaTime(static_cast<int64_t>(start), truncatedGstSecond)); 2399 2375 if (stop != -1) 2400 cue->setEndTime(MediaTime(st op, GST_SECOND));2376 cue->setEndTime(MediaTime(static_cast<int64_t>(stop), truncatedGstSecond)); 2401 2377 2402 2378 GstTagList* tags = gst_toc_entry_get_tags(entry); … … 2496 2472 void MediaPlayerPrivateGStreamer::asyncStateChangeDone() 2497 2473 { 2498 if (!m_pipeline || m_ errorOccured)2499 return; 2500 2501 if (m_ seeking) {2502 if (m_ seekIsPending)2474 if (!m_pipeline || m_didErrorOccur) 2475 return; 2476 2477 if (m_isSeeking) { 2478 if (m_isSeekPending) 2503 2479 updateStates(); 2504 2480 else { 2505 2481 GST_DEBUG_OBJECT(pipeline(), "[Seek] seeked to %s", toString(m_seekTime).utf8().data()); 2506 m_ seeking = false;2482 m_isSeeking = false; 2507 2483 m_cachedPosition = MediaTime::invalidTime(); 2508 2484 if (m_timeOfOverlappingSeek != m_seekTime && m_timeOfOverlappingSeek.isValid()) { … … 2524 2500 void MediaPlayerPrivateGStreamer::updateStates() 2525 2501 { 2526 if (!m_pipeline) 2527 return; 2528 2529 if (m_errorOccured) 2502 if (!m_pipeline || m_didErrorOccur) 2530 2503 return; 2531 2504 2532 2505 MediaPlayer::NetworkState oldNetworkState = m_networkState; 2533 2506 MediaPlayer::ReadyState oldReadyState = m_readyState; 2534 GstState pending; 2535 GstState state; 2507 GstState pending, state; 2536 2508 bool stateReallyChanged = false; 2537 2509 … … 2553 2525 break; 2554 2526 2555 m_ resetPipeline = m_currentState <= GST_STATE_READY;2556 2557 bool didBuffering = m_ buffering;2527 m_shouldResetPipeline = m_currentState <= GST_STATE_READY; 2528 2529 bool didBuffering = m_isBuffering; 2558 2530 2559 2531 // Update ready and network states. … … 2569 2541 case GST_STATE_PAUSED: 2570 2542 case GST_STATE_PLAYING: 2571 if (m_ buffering) {2543 if (m_isBuffering) { 2572 2544 if (m_bufferingPercentage == 100) { 2573 2545 GST_DEBUG_OBJECT(pipeline(), "[Buffering] Complete."); 2574 m_ buffering = false;2546 m_isBuffering = false; 2575 2547 m_readyState = MediaPlayer::HaveEnoughData; 2576 m_networkState = m_d ownloadFinished? MediaPlayer::Idle : MediaPlayer::Loading;2548 m_networkState = m_didDownloadFinish ? MediaPlayer::Idle : MediaPlayer::Loading; 2577 2549 } else { 2578 2550 m_readyState = MediaPlayer::HaveCurrentData; 2579 2551 m_networkState = MediaPlayer::Loading; 2580 2552 } 2581 } else if (m_d ownloadFinished) {2553 } else if (m_didDownloadFinish) { 2582 2554 m_readyState = MediaPlayer::HaveEnoughData; 2583 2555 m_networkState = MediaPlayer::Loaded; … … 2595 2567 // Sync states where needed. 2596 2568 if (m_currentState == GST_STATE_PAUSED) { 2597 if (!m_ volumeAndMuteInitialized) {2569 if (!m_areVolumeAndMuteInitialized) { 2598 2570 notifyPlayerOfVolumeChange(); 2599 2571 notifyPlayerOfMute(); 2600 m_ volumeAndMuteInitialized = true;2572 m_areVolumeAndMuteInitialized = true; 2601 2573 } 2602 2574 2603 if (didBuffering && !m_ buffering && !m_paused && m_playbackRate) {2575 if (didBuffering && !m_isBuffering && !m_isPaused && m_playbackRate) { 2604 2576 GST_DEBUG_OBJECT(pipeline(), "[Buffering] Restarting playback."); 2605 2577 changePipelineState(GST_STATE_PLAYING); 2606 2578 } 2607 2579 } else if (m_currentState == GST_STATE_PLAYING) { 2608 m_ paused = false;2609 2610 if ((m_ buffering && !isLiveStream()) || !m_playbackRate) {2580 m_isPaused = false; 2581 2582 if ((m_isBuffering && m_isLiveStream) || !m_playbackRate) { 2611 2583 GST_DEBUG_OBJECT(pipeline(), "[Buffering] Pausing stream for buffering."); 2612 2584 changePipelineState(GST_STATE_PAUSED); 2613 2585 } 2614 2586 } else 2615 m_ paused = true;2587 m_isPaused = true; 2616 2588 2617 2589 GST_DEBUG_OBJECT(pipeline(), "Old state: %s, new state: %s (requested: %s)", gst_element_state_get_name(m_oldState), gst_element_state_get_name(m_currentState), gst_element_state_get_name(m_requestedState)); … … 2638 2610 case GST_STATE_CHANGE_FAILURE: 2639 2611 GST_DEBUG_OBJECT(pipeline(), "Failure: State: %s, pending: %s", gst_element_state_get_name(m_currentState), gst_element_state_get_name(pending)); 2640 // Change failed 2612 // Change failed. 2641 2613 return; 2642 2614 case GST_STATE_CHANGE_NO_PREROLL: … … 2644 2616 2645 2617 // Live pipelines go in PAUSED without prerolling. 2646 m_is Streaming= true;2618 m_isLiveStream = true; 2647 2619 updateDownloadBufferingFlag(); 2648 2620 … … 2651 2623 else if (m_currentState == GST_STATE_PAUSED) { 2652 2624 m_readyState = MediaPlayer::HaveEnoughData; 2653 m_ paused = true;2625 m_isPaused = true; 2654 2626 } else if (m_currentState == GST_STATE_PLAYING) 2655 m_ paused = false;2656 2657 if (!m_ paused && m_playbackRate)2627 m_isPaused = false; 2628 2629 if (!m_isPaused && m_playbackRate) 2658 2630 changePipelineState(GST_STATE_PLAYING); 2659 2631 … … 2681 2653 if (getStateResult == GST_STATE_CHANGE_SUCCESS && m_currentState >= GST_STATE_PAUSED) { 2682 2654 updatePlaybackRate(); 2683 if (m_ seekIsPending) {2655 if (m_isSeekPending) { 2684 2656 GST_DEBUG_OBJECT(pipeline(), "[Seek] committing pending seek to %s", toString(m_seekTime).utf8().data()); 2685 m_ seekIsPending = false;2686 m_ seeking = doSeek(m_seekTime, m_player->rate(), static_cast<GstSeekFlags>(GST_SEEK_FLAG_FLUSH | GST_SEEK_FLAG_ACCURATE));2687 if (!m_ seeking) {2657 m_isSeekPending = false; 2658 m_isSeeking = doSeek(m_seekTime, m_player->rate(), static_cast<GstSeekFlags>(GST_SEEK_FLAG_FLUSH | GST_SEEK_FLAG_ACCURATE)); 2659 if (!m_isSeeking) { 2688 2660 m_cachedPosition = MediaTime::invalidTime(); 2689 2661 GST_DEBUG_OBJECT(pipeline(), "[Seek] seeking to %s failed", toString(m_seekTime).utf8().data()); … … 2719 2691 2720 2692 const GValue* locations = gst_structure_get_value(m_mediaLocations, "locations"); 2721 const gchar* newLocation = nullptr;2693 const char* newLocation = nullptr; 2722 2694 2723 2695 if (!locations) { … … 2776 2748 2777 2749 // Reset pipeline state. 2778 m_ resetPipeline = true;2750 m_shouldResetPipeline = true; 2779 2751 2780 2752 GstState state; … … 2802 2774 m_cachedPosition = MediaTime::invalidTime(); 2803 2775 MediaTime now = currentMediaTime(); 2804 if (now > MediaTime::zeroTime() && !m_ seeking) {2776 if (now > MediaTime::zeroTime() && !m_isSeeking) { 2805 2777 m_cachedDuration = now; 2806 2778 m_player->durationChanged(); … … 2810 2782 2811 2783 if (!m_player->client().mediaPlayerIsLooping()) { 2812 m_ paused = true;2784 m_isPaused = true; 2813 2785 changePipelineState(GST_STATE_READY); 2814 m_d ownloadFinished= false;2786 m_didDownloadFinish = false; 2815 2787 } 2816 2788 timeChanged(); … … 2865 2837 2866 2838 // We don't want to stop downloading if we already started it. 2867 if (flags & flagDownload && m_readyState > MediaPlayer::HaveNothing && !m_ resetPipeline) {2839 if (flags & flagDownload && m_readyState > MediaPlayer::HaveNothing && !m_shouldResetPipeline) { 2868 2840 GST_DEBUG_OBJECT(pipeline(), "Download already started, not starting again"); 2869 2841 return; 2870 2842 } 2871 2843 2872 bool shouldDownload = ! isLiveStream()&& m_preload == MediaPlayer::Auto;2844 bool shouldDownload = !m_isLiveStream && m_preload == MediaPlayer::Auto; 2873 2845 if (shouldDownload) { 2874 2846 GST_INFO_OBJECT(pipeline(), "Enabling on-disk buffering"); … … 2884 2856 void MediaPlayerPrivateGStreamer::createGSTPlayBin(const URL& url, const String& pipelineName) 2885 2857 { 2886 const gchar* playbinName = "playbin";2858 const char* playbinName = "playbin"; 2887 2859 2888 2860 // MSE doesn't support playbin3. Mediastream requires playbin3. Regular … … 2907 2879 m_isLegacyPlaybin = !g_strcmp0(playbinName, "playbin"); 2908 2880 2909 // gst_element_factory_make() returns a floating reference so2910 // we should not adopt.2911 2881 static Atomic<uint32_t> pipelineId; 2912 2882 setPipeline(gst_element_factory_make(playbinName, … … 2974 2944 configurePlaySink(); 2975 2945 2976 if (m_ preservesPitch) {2946 if (m_shouldPreservePitch) { 2977 2947 GstElement* scale = gst_element_factory_make("scaletempo", nullptr); 2978 2948 … … 2983 2953 } 2984 2954 2985 if (!m_ renderingCanBeAccelerated) {2955 if (!m_canRenderingBeAccelerated) { 2986 2956 // If not using accelerated compositing, let GStreamer handle 2987 2957 // the image-orientation tag. … … 3008 2978 bool MediaPlayerPrivateGStreamer::canSaveMediaData() const 3009 2979 { 3010 if ( isLiveStream())2980 if (m_isLiveStream) 3011 2981 return false; 3012 2982 … … 3028 2998 void MediaPlayerPrivateGStreamer::acceleratedRenderingStateChanged() 3029 2999 { 3030 m_ renderingCanBeAccelerated = m_player && m_player->client().mediaPlayerAcceleratedCompositingEnabled();3000 m_canRenderingBeAccelerated = m_player && m_player->client().mediaPlayerAcceleratedCompositingEnabled(); 3031 3001 } 3032 3002 … … 3076 3046 return; 3077 3047 3078 std::unique_ptr<GstVideoFrameHolder> frameHolder = makeUnique<GstVideoFrameHolder>(m_sample.get(), m_videoDecoderPlatform, m_textureMapperFlags, !m_ usingFallbackVideoSink);3048 std::unique_ptr<GstVideoFrameHolder> frameHolder = makeUnique<GstVideoFrameHolder>(m_sample.get(), m_videoDecoderPlatform, m_textureMapperFlags, !m_isUsingFallbackVideoSink); 3079 3049 3080 3050 std::unique_ptr<TextureMapperPlatformLayerBuffer> layerBuffer; … … 3118 3088 void MediaPlayerPrivateGStreamer::triggerRepaint(GstSample* sample) 3119 3089 { 3120 bool triggerResize;3090 bool shouldTriggerResize; 3121 3091 { 3122 3092 auto sampleLocker = holdLock(m_sampleMutex); 3123 triggerResize = !m_sample;3093 shouldTriggerResize = !m_sample; 3124 3094 m_sample = sample; 3125 3095 } 3126 3096 3127 if ( triggerResize) {3097 if (shouldTriggerResize) { 3128 3098 GST_DEBUG_OBJECT(pipeline(), "First sample reached the sink, triggering video dimensions update"); 3129 3099 m_notifier->notify(MainThreadNotification::SizeChanged, [this] { … … 3132 3102 } 3133 3103 3134 if (!m_ renderingCanBeAccelerated) {3104 if (!m_canRenderingBeAccelerated) { 3135 3105 LockHolder locker(m_drawMutex); 3136 if (m_ destroying)3106 if (m_isBeingDestroyed) 3137 3107 return; 3138 3108 m_drawTimer.startOneShot(0_s); … … 3142 3112 3143 3113 #if USE(TEXTURE_MAPPER_GL) 3144 if (m_ usingFallbackVideoSink) {3114 if (m_isUsingFallbackVideoSink) { 3145 3115 LockHolder lock(m_drawMutex); 3146 3116 auto proxyOperation = … … 3178 3148 // This function is also used when destroying the player (destroying parameter is true), to release the gstreamer thread from 3179 3149 // m_drawCondition and to ensure that new triggerRepaint calls won't wait on m_drawCondition. 3180 if (!m_ renderingCanBeAccelerated) {3150 if (!m_canRenderingBeAccelerated) { 3181 3151 LockHolder locker(m_drawMutex); 3182 3152 m_drawTimer.stop(); 3183 m_ destroying= destroying;3153 m_isBeingDestroyed = destroying; 3184 3154 m_drawCondition.notifyOne(); 3185 3155 } … … 3263 3233 m_colorConvertOutputCaps = adoptGRef(gst_caps_copy(caps)); 3264 3234 #if G_BYTE_ORDER == G_LITTLE_ENDIAN 3265 const gchar* formatString = GST_VIDEO_INFO_HAS_ALPHA(&videoInfo) ? "RGBA" : "BGRx";3235 const char* formatString = GST_VIDEO_INFO_HAS_ALPHA(&videoInfo) ? "RGBA" : "BGRx"; 3266 3236 #else 3267 const gchar* formatString = GST_VIDEO_INFO_HAS_ALPHA(&videoInfo) ? "RGBA" : "RGBx";3237 const char* formatString = GST_VIDEO_INFO_HAS_ALPHA(&videoInfo) ? "RGBA" : "RGBx"; 3268 3238 #endif 3269 3239 gst_caps_set_simple(m_colorConvertOutputCaps.get(), "format", G_TYPE_STRING, formatString, nullptr); … … 3286 3256 return; 3287 3257 3288 context.drawImage(gstImage->image(), rect, gstImage->rect(), { CompositeCopy, m_ renderingCanBeAccelerated ? m_videoSourceOrientation : ImageOrientation() });3258 context.drawImage(gstImage->image(), rect, gstImage->rect(), { CompositeCopy, m_canRenderingBeAccelerated ? m_videoSourceOrientation : ImageOrientation() }); 3289 3259 } 3290 3260 … … 3294 3264 UNUSED_PARAM(context); 3295 3265 3296 if (m_ usingFallbackVideoSink)3266 if (m_isUsingFallbackVideoSink) 3297 3267 return false; 3298 3268 … … 3326 3296 { 3327 3297 #if USE(CAIRO) && ENABLE(ACCELERATED_2D_CANVAS) 3328 if (m_ usingFallbackVideoSink)3298 if (m_isUsingFallbackVideoSink) 3329 3299 return nullptr; 3330 3300 … … 3407 3377 return MediaPlayer::Unknown; 3408 3378 3409 if ( isLiveStream())3379 if (m_isLiveStream) 3410 3380 return MediaPlayer::LiveStream; 3411 3381 … … 3485 3455 3486 3456 #if USE(GSTREAMER_GL) 3487 if (m_ renderingCanBeAccelerated)3457 if (m_canRenderingBeAccelerated) 3488 3458 m_videoSink = createVideoSinkGL(); 3489 3459 #endif 3490 3460 3491 3461 if (!m_videoSink) { 3492 m_ usingFallbackVideoSink = true;3462 m_isUsingFallbackVideoSink = true; 3493 3463 m_videoSink = webkitVideoSinkNew(); 3494 3464 g_signal_connect_swapped(m_videoSink.get(), "repaint-requested", G_CALLBACK(repaintCallback), this); … … 3544 3514 unsigned MediaPlayerPrivateGStreamer::decodedFrameCount() const 3545 3515 { 3546 guint64decodedFrames = 0;3516 uint64_t decodedFrames = 0; 3547 3517 if (m_fpsSink) 3548 3518 g_object_get(m_fpsSink.get(), "frames-rendered", &decodedFrames, nullptr); … … 3552 3522 unsigned MediaPlayerPrivateGStreamer::droppedFrameCount() const 3553 3523 { 3554 guint64framesDropped = 0;3524 uint64_t framesDropped = 0; 3555 3525 if (m_fpsSink) 3556 3526 g_object_get(m_fpsSink.get(), "frames-dropped", &framesDropped, nullptr); … … 3650 3620 void MediaPlayerPrivateGStreamer::attemptToDecryptWithLocalInstance() 3651 3621 { 3652 bool eventHandled = gst_element_send_event(pipeline(), gst_event_new_custom(GST_EVENT_CUSTOM_DOWNSTREAM_OOB, gst_structure_new_empty("attempt-to-decrypt")));3653 GST_DEBUG("attempting to decrypt, event handled %s", boolForPrinting( eventHandled));3622 bool wasEventHandled = gst_element_send_event(pipeline(), gst_event_new_custom(GST_EVENT_CUSTOM_DOWNSTREAM_OOB, gst_structure_new_empty("attempt-to-decrypt"))); 3623 GST_DEBUG("attempting to decrypt, event handled %s", boolForPrinting(wasEventHandled)); 3654 3624 } 3655 3625 … … 3670 3640 } 3671 3641 3672 void MediaPlayerPrivateGStreamer::setWaitingForKey(bool waitingForKey)3642 void MediaPlayerPrivateGStreamer::setWaitingForKey(bool isWaitingForKey) 3673 3643 { 3674 3644 // We bail out if values did not change or if we are requested to not wait anymore but there are still waiting decryptors. 3675 GST_TRACE(" waitingForKey %s, m_waitingForKey %s", boolForPrinting(waitingForKey), boolForPrinting(m_waitingForKey));3676 if ( waitingForKey == m_waitingForKey || (!waitingForKey && this->waitingForKey()))3677 return; 3678 3679 m_ waitingForKey = waitingForKey;3680 GST_DEBUG("waiting for key changed %s", boolForPrinting(m_ waitingForKey));3645 GST_TRACE("isWaitingForKey %s, m_isWaitingForKey %s", boolForPrinting(isWaitingForKey), boolForPrinting(m_isWaitingForKey)); 3646 if (isWaitingForKey == m_isWaitingForKey || (!isWaitingForKey && this->waitingForKey())) 3647 return; 3648 3649 m_isWaitingForKey = isWaitingForKey; 3650 GST_DEBUG("waiting for key changed %s", boolForPrinting(m_isWaitingForKey)); 3681 3651 m_player->waitingForKeyChanged(); 3682 3652 } -
trunk/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.h
r252938 r252950 121 121 WTF_MAKE_FAST_ALLOCATED; 122 122 public: 123 static void initializeDebugCategory();124 125 123 MediaPlayerPrivateGStreamer(MediaPlayer*); 126 124 virtual ~MediaPlayerPrivateGStreamer(); 127 125 128 static bool isAvailable();129 126 static void registerMediaEngine(MediaEngineRegistrar); 130 131 bool hasVideo() const override { return m_hasVideo; } 132 bool has Audio() const override { return m_hasAudio; }133 127 static MediaPlayer::SupportsType extendedSupportsType(const MediaEngineSupportParameters&, MediaPlayer::SupportsType); 128 129 bool hasVideo() const final { return m_hasVideo; } 130 bool hasAudio() const final { return m_hasAudio; } 134 131 void load(const String &url) override; 135 132 #if ENABLE(MEDIA_SOURCE) … … 139 136 void load(MediaStreamPrivate&) override; 140 137 #endif 141 void commitLoad(); 142 void cancelLoad() override; 143 144 void prepareToPlay() override; 145 void play() override; 138 void cancelLoad() final; 139 void prepareToPlay() final; 140 void play() final; 146 141 void pause() override; 147 bool paused() const override;148 bool seeking() const override { return m_ seeking; }142 bool paused() const final; 143 bool seeking() const override { return m_isSeeking; } 149 144 void seek(const MediaTime&) override; 150 151 MediaTime platformDuration() const;152 153 145 void setRate(float) override; 154 double rate() const override; 155 void setPreservesPitch(bool) override; 156 void setPreload(MediaPlayer::Preload) override; 157 146 double rate() const final; 147 void setPreservesPitch(bool) final; 148 void setPreload(MediaPlayer::Preload) final; 158 149 FloatSize naturalSize() const final; 159 160 void setVolume(float) override; 161 float volume() const override; 162 163 void setMuted(bool) override; 164 bool muted() const; 165 166 MediaPlayer::NetworkState networkState() const override; 167 MediaPlayer::ReadyState readyState() const override; 168 169 void setVisible(bool) override { } 170 void setSize(const IntSize&) override; 171 void sizeChanged(); 172 150 void setVolume(float) final; 151 float volume() const final; 152 void setMuted(bool) final; 153 MediaPlayer::NetworkState networkState() const final; 154 MediaPlayer::ReadyState readyState() const final; 155 void setVisible(bool) final { } 156 void setSize(const IntSize&) final; 173 157 // Prefer MediaTime based methods over float based. 174 175 float duration() const override { return durationMediaTime().toFloat(); } 176 double durationDouble() const override { return durationMediaTime().toDouble(); } 177 MediaTime durationMediaTime() const override; 178 float currentTime() const override { return currentMediaTime().toFloat(); } 179 double currentTimeDouble() const override { return currentMediaTime().toDouble(); } 158 float duration() const final { return durationMediaTime().toFloat(); } 159 double durationDouble() const final { return durationMediaTime().toDouble(); } 160 MediaTime durationMediaTime() const; 161 float currentTime() const final { return currentMediaTime().toFloat(); } 162 double currentTimeDouble() const final { return currentMediaTime().toDouble(); } 180 163 MediaTime currentMediaTime() const override; 181 164 std::unique_ptr<PlatformTimeRanges> buffered() const override; 182 void seek(float time) override { seek(MediaTime::createWithFloat(time)); } 183 void seekDouble(double time) override { seek(MediaTime::createWithDouble(time)); } 184 185 float maxTimeSeekable() const override { return maxMediaTimeSeekable().toFloat(); } 165 void seek(float time) final { seek(MediaTime::createWithFloat(time)); } 166 void seekDouble(double time) final { seek(MediaTime::createWithDouble(time)); } 167 float maxTimeSeekable() const final { return maxMediaTimeSeekable().toFloat(); } 186 168 MediaTime maxMediaTimeSeekable() const override; 187 double minTimeSeekable() const override { return minMediaTimeSeekable().toFloat(); } 188 MediaTime minMediaTimeSeekable() const override { return MediaTime::zeroTime(); } 189 190 bool didLoadingProgress() const override; 191 unsigned long long totalBytes() const override; 192 193 bool hasSingleSecurityOrigin() const override; 194 Optional<bool> wouldTaintOrigin(const SecurityOrigin&) const override; 195 196 void simulateAudioInterruption() override; 197 169 double minTimeSeekable() const final { return minMediaTimeSeekable().toFloat(); } 170 MediaTime minMediaTimeSeekable() const final { return MediaTime::zeroTime(); } 171 bool didLoadingProgress() const final; 172 unsigned long long totalBytes() const final; 173 bool hasSingleSecurityOrigin() const final; 174 Optional<bool> wouldTaintOrigin(const SecurityOrigin&) const final; 175 void simulateAudioInterruption() final; 198 176 #if ENABLE(WEB_AUDIO) 199 AudioSourceProvider* audioSourceProvider() override; 200 #endif 201 202 void paint(GraphicsContext&, const FloatRect&) override; 203 204 bool supportsFullscreen() const override; 205 206 MediaPlayer::MovieLoadType movieLoadType() const override; 207 208 MediaPlayer* mediaPlayer() const { return m_player; } 209 210 unsigned decodedFrameCount() const override; 211 unsigned droppedFrameCount() const override; 212 unsigned audioDecodedByteCount() const override; 213 unsigned videoDecodedByteCount() const override; 214 215 void acceleratedRenderingStateChanged() override; 177 AudioSourceProvider* audioSourceProvider() final; 178 #endif 179 void paint(GraphicsContext&, const FloatRect&) final; 180 bool supportsFullscreen() const final; 181 MediaPlayer::MovieLoadType movieLoadType() const final; 182 183 unsigned decodedFrameCount() const final; 184 unsigned droppedFrameCount() const final; 185 unsigned audioDecodedByteCount() const final; 186 unsigned videoDecodedByteCount() const final; 187 188 void acceleratedRenderingStateChanged() final; 216 189 217 190 #if USE(TEXTURE_MAPPER_GL) … … 226 199 227 200 #if ENABLE(ENCRYPTED_MEDIA) 228 void cdmInstanceAttached(CDMInstance&) override; 229 void cdmInstanceDetached(CDMInstance&) override; 201 void cdmInstanceAttached(CDMInstance&) final; 202 void cdmInstanceDetached(CDMInstance&) final; 203 void attemptToDecryptWithInstance(CDMInstance&) final; 204 bool waitingForKey() const final; 205 230 206 void handleProtectionEvent(GstEvent*); 231 virtual void attemptToDecryptWithLocalInstance(); 232 void attemptToDecryptWithInstance(CDMInstance&) final; 233 void initializationDataEncountered(InitData&&); 234 void setWaitingForKey(bool); 235 bool waitingForKey() const override; 236 #endif 237 238 static bool supportsKeySystem(const String& keySystem, const String& mimeType); 239 static MediaPlayer::SupportsType extendedSupportsType(const MediaEngineSupportParameters&, MediaPlayer::SupportsType); 207 #endif 240 208 241 209 #if USE(GSTREAMER_GL) … … 244 212 #endif 245 213 246 void setVideoSourceOrientation(ImageOrientation);247 GstElement* pipeline() const { return m_pipeline.get(); }248 214 void enableTrack(TrackPrivateBaseGStreamer::TrackType, unsigned index); 249 215 250 216 // Append pipeline interface 217 // FIXME: Use the client interface pattern, AppendPipeline does not need the full interface to this class just for these two functions. 251 218 bool handleSyncMessage(GstMessage*); 252 219 void handleMessage(GstMessage*); … … 271 238 }; 272 239 273 virtual bool isLiveStream() const { return m_isStreaming; } 274 MediaTime maxTimeLoaded() const; 240 static bool isAvailable(); 241 #if ENABLE(ENCRYPTED_MEDIA) 242 static bool supportsKeySystem(const String& keySystem, const String& mimeType); 243 #endif 275 244 276 245 virtual void durationChanged(); … … 279 248 virtual bool changePipelineState(GstState); 280 249 281 282 250 #if USE(GSTREAMER_HOLEPUNCH) 283 251 GstElement* createHolePunchVideoSink(); … … 293 261 void pushTextureToCompositor(); 294 262 #if USE(NICOSIA) 295 void swapBuffersIfNeeded() override;263 void swapBuffersIfNeeded() final; 296 264 #else 297 RefPtr<TextureMapperPlatformLayerProxy> proxy() const override;298 void swapBuffersIfNeeded() override;265 RefPtr<TextureMapperPlatformLayerProxy> proxy() const final; 266 void swapBuffersIfNeeded() final; 299 267 #endif 300 268 #endif … … 317 285 static void volumeChangedCallback(MediaPlayerPrivateGStreamer*); 318 286 static void muteChangedCallback(MediaPlayerPrivateGStreamer*); 319 320 // FIXME: Where is this used?321 void handlePluginInstallerResult(GstInstallPluginsReturn);322 287 323 288 void readyTimerFired(); … … 359 324 mutable MediaTime m_cachedDuration; 360 325 bool m_canFallBackToLastFinishedSeekPosition { false }; 361 bool m_ changingRate { false };362 bool m_d ownloadFinished{ false };363 bool m_ errorOccured{ false };326 bool m_isChangingRate { false }; 327 bool m_didDownloadFinish { false }; 328 bool m_didErrorOccur { false }; 364 329 mutable bool m_isEndReached { false }; 365 mutable bool m_is Streaming{ false };366 bool m_ paused { true };330 mutable bool m_isLiveStream { false }; 331 bool m_isPaused { true }; 367 332 float m_playbackRate { 1 }; 368 333 GstState m_currentState; 369 334 GstState m_oldState; 370 335 GstState m_requestedState { GST_STATE_VOID_PENDING }; 371 bool m_ resetPipeline { false };372 bool m_ seeking { false };373 bool m_ seekIsPending { false };336 bool m_shouldResetPipeline { false }; 337 bool m_isSeeking { false }; 338 bool m_isSeekPending { false }; 374 339 MediaTime m_seekTime; 375 340 GRefPtr<GstElement> m_source { nullptr }; 376 bool m_ volumeAndMuteInitialized { false };341 bool m_areVolumeAndMuteInitialized { false }; 377 342 378 343 #if USE(TEXTURE_MAPPER_GL) … … 392 357 393 358 mutable FloatSize m_videoSize; 394 bool m_ usingFallbackVideoSink { false };395 bool m_ renderingCanBeAccelerated { false };396 397 bool m_ destroying{ false };359 bool m_isUsingFallbackVideoSink { false }; 360 bool m_canRenderingBeAccelerated { false }; 361 362 bool m_isBeingDestroyed { false }; 398 363 399 364 #if USE(GSTREAMER_GL) … … 413 378 HashSet<uint32_t> m_handledProtectionEvents; 414 379 415 bool m_ waitingForKey { false };380 bool m_isWaitingForKey { false }; 416 381 #endif 417 382 … … 419 384 420 385 private: 386 MediaTime maxTimeLoaded() const; 387 GstElement* pipeline() const { return m_pipeline.get(); } 388 void setVideoSourceOrientation(ImageOrientation); 389 MediaTime platformDuration() const; 390 bool isMuted() const; 391 void commitLoad(); 421 392 void fillTimerFired(); 422 423 393 void didEnd(); 424 425 394 426 395 GstElement* createVideoSink(); … … 476 445 void clearTracks(); 477 446 447 #if ENABLE(ENCRYPTED_MEDIA) 448 void attemptToDecryptWithLocalInstance(); 449 void initializationDataEncountered(InitData&&); 450 void setWaitingForKey(bool); 451 #endif 452 478 453 #if ENABLE(VIDEO_TRACK) 479 454 GRefPtr<GstElement> m_textAppSink; … … 482 457 GstStructure* m_mediaLocations { nullptr }; 483 458 int m_mediaLocationCurrentIndex { 0 }; 484 bool m_ playbackRatePause{ false };459 bool m_isPlaybackRatePaused { false }; 485 460 MediaTime m_timeOfOverlappingSeek; 486 461 float m_lastPlaybackRate { 1 }; … … 489 464 bool m_loadingStalled { false }; 490 465 MediaPlayer::Preload m_preload; 491 bool m_ delayingLoad { false };466 bool m_isDelayingLoad { false }; 492 467 mutable MediaTime m_maxTimeLoadedAtLastDidLoadingProgress; 493 468 bool m_hasVideo { false }; … … 504 479 #endif 505 480 #endif 506 bool m_ buffering { false };481 bool m_isBuffering { false }; 507 482 int m_bufferingPercentage { 0 }; 508 483 mutable unsigned long long m_totalBytes { 0 }; 509 484 URL m_url; 510 bool m_ preservesPitch { false };485 bool m_shouldPreservePitch { false }; 511 486 mutable Optional<Seconds> m_lastQueryTime; 512 487 bool m_isLegacyPlaybin; -
trunk/Source/WebCore/platform/graphics/gstreamer/mse/MediaPlayerPrivateGStreamerMSE.cpp
r252938 r252950 133 133 void MediaPlayerPrivateGStreamerMSE::pause() 134 134 { 135 m_paused = true; 135 // FIXME: Should not need direct access to this member. This override is probably not needed. 136 m_isPaused = true; 136 137 MediaPlayerPrivateGStreamer::pause(); 137 138 } … … 139 140 MediaTime MediaPlayerPrivateGStreamerMSE::durationMediaTime() const 140 141 { 141 if (UNLIKELY(!m_pipeline || m_ errorOccured))142 if (UNLIKELY(!m_pipeline || m_didErrorOccur)) 142 143 return MediaTime(); 143 144 … … 147 148 void MediaPlayerPrivateGStreamerMSE::seek(const MediaTime& time) 148 149 { 149 if (UNLIKELY(!m_pipeline || m_ errorOccured))150 if (UNLIKELY(!m_pipeline || m_didErrorOccur)) 150 151 return; 151 152 … … 155 156 MediaTime current = currentMediaTime(); 156 157 if (time == current) { 157 if (!m_ seeking)158 if (!m_isSeeking) 158 159 timeChanged(); 159 160 return; 160 161 } 161 162 162 if ( isLiveStream())163 return; 164 165 if (m_ seeking && m_seekIsPending) {163 if (m_isLiveStream) 164 return; 165 166 if (m_isSeeking && m_isSeekPending) { 166 167 m_seekTime = time; 167 168 return; … … 180 181 181 182 m_isEndReached = false; 182 GST_DEBUG("m_ seeking=%s, m_seekTime=%s", boolForPrinting(m_seeking), toString(m_seekTime).utf8().data());183 GST_DEBUG("m_isSeeking=%s, m_seekTime=%s", boolForPrinting(m_isSeeking), toString(m_seekTime).utf8().data()); 183 184 } 184 185 … … 233 234 234 235 // Always move to seeking state to report correct 'currentTime' while pending for actual seek to complete. 235 m_ seeking = true;236 m_isSeeking = true; 236 237 237 238 // Check if playback pipeline is ready for seek. … … 241 242 GST_DEBUG("[Seek] cannot seek, current state change is %s", gst_element_state_change_return_get_name(getStateResult)); 242 243 webKitMediaSrcSetReadyForSamples(WEBKIT_MEDIA_SRC(m_source.get()), true); 243 m_ seeking = false;244 m_isSeeking = false; 244 245 return false; 245 246 } … … 263 264 GST_DEBUG("[Seek] Delaying the seek: %s", reason.data()); 264 265 265 m_ seekIsPending = true;266 m_isSeekPending = true; 266 267 267 268 if (m_isEndReached) { 268 269 GST_DEBUG("[Seek] reset pipeline"); 269 m_ resetPipeline = true;270 m_ seeking = false;270 m_shouldResetPipeline = true; 271 m_isSeeking = false; 271 272 if (!changePipelineState(GST_STATE_PAUSED)) 272 273 loadingFailed(MediaPlayer::Empty); 273 274 else 274 m_ seeking = true;275 m_isSeeking = true; 275 276 } 276 277 277 return m_ seeking;278 return m_isSeeking; 278 279 } 279 280 … … 301 302 GST_DEBUG("[Seek] Cannot seek, failed to pause playback pipeline."); 302 303 webKitMediaSrcSetReadyForSamples(WEBKIT_MEDIA_SRC(m_source.get()), true); 303 m_ seeking = false;304 m_isSeeking = false; 304 305 return false; 305 306 } … … 315 316 ASSERT(m_mseSeekCompleted); 316 317 // Note: seekCompleted will recursively call us. 317 return m_ seeking;318 return m_isSeeking; 318 319 } 319 320 … … 338 339 if (!gst_element_seek(m_pipeline.get(), rate, GST_FORMAT_TIME, seekType, GST_SEEK_TYPE_SET, toGstClockTime(startTime), GST_SEEK_TYPE_SET, toGstClockTime(endTime))) { 339 340 webKitMediaSrcSetReadyForSamples(WEBKIT_MEDIA_SRC(m_source.get()), true); 340 m_ seeking = false;341 m_isSeeking = false; 341 342 m_gstSeekCompleted = true; 342 343 GST_DEBUG("doSeek(): gst_element_seek() failed, returning false"); … … 351 352 void MediaPlayerPrivateGStreamerMSE::maybeFinishSeek() 352 353 { 353 if (!m_ seeking || !m_mseSeekCompleted || !m_gstSeekCompleted)354 if (!m_isSeeking || !m_mseSeekCompleted || !m_gstSeekCompleted) 354 355 return; 355 356 … … 363 364 } 364 365 365 if (m_ seekIsPending) {366 if (m_isSeekPending) { 366 367 GST_DEBUG("[Seek] Committing pending seek to %s", toString(m_seekTime).utf8().data()); 367 m_ seekIsPending = false;368 m_isSeekPending = false; 368 369 if (!doSeek()) { 369 370 GST_WARNING("[Seek] Seeking to %s failed", toString(m_seekTime).utf8().data()); … … 376 377 377 378 webKitMediaSrcSetReadyForSamples(WEBKIT_MEDIA_SRC(m_source.get()), true); 378 m_ seeking = false;379 m_isSeeking = false; 379 380 m_cachedPosition = MediaTime::invalidTime(); 380 381 // The pipeline can still have a pending state. In this case a position query will fail. … … 391 392 bool MediaPlayerPrivateGStreamerMSE::seeking() const 392 393 { 393 return m_ seeking;394 return m_isSeeking; 394 395 } 395 396 … … 429 430 void MediaPlayerPrivateGStreamerMSE::waitForSeekCompleted() 430 431 { 431 if (!m_ seeking)432 if (!m_isSeeking) 432 433 return; 433 434 … … 480 481 void MediaPlayerPrivateGStreamerMSE::updateStates() 481 482 { 482 if (UNLIKELY(!m_pipeline || m_ errorOccured))483 if (UNLIKELY(!m_pipeline || m_didErrorOccur)) 483 484 return; 484 485 … … 499 500 break; 500 501 501 m_ resetPipeline = (state <= GST_STATE_READY);502 if (m_ resetPipeline)502 m_shouldResetPipeline = (state <= GST_STATE_READY); 503 if (m_shouldResetPipeline) 503 504 m_mediaTimeDuration = MediaTime::zeroTime(); 504 505 … … 539 540 // Sync states where needed. 540 541 if (state == GST_STATE_PAUSED) { 541 if (!m_ volumeAndMuteInitialized) {542 if (!m_areVolumeAndMuteInitialized) { 542 543 notifyPlayerOfVolumeChange(); 543 544 notifyPlayerOfMute(); 544 m_ volumeAndMuteInitialized = true;545 m_areVolumeAndMuteInitialized = true; 545 546 } 546 547 547 if (!seeking() && !m_ paused && m_playbackRate) {548 if (!seeking() && !m_isPaused && m_playbackRate) { 548 549 GST_DEBUG("[Buffering] Restarting playback."); 549 550 changePipelineState(GST_STATE_PLAYING); 550 551 } 551 552 } else if (state == GST_STATE_PLAYING) { 552 m_ paused = false;553 m_isPaused = false; 553 554 554 555 if (!m_playbackRate) { … … 557 558 } 558 559 } else 559 m_ paused = true;560 m_isPaused = true; 560 561 561 562 if (m_requestedState == GST_STATE_PAUSED && state == GST_STATE_PAUSED) { … … 578 579 579 580 // Live pipelines go in PAUSED without prerolling. 580 m_is Streaming= true;581 m_isLiveStream = true; 581 582 582 583 if (state == GST_STATE_READY) { … … 586 587 m_readyState = MediaPlayer::HaveEnoughData; 587 588 GST_DEBUG("m_readyState=%s", dumpReadyState(m_readyState)); 588 m_ paused = true;589 m_isPaused = true; 589 590 } else if (state == GST_STATE_PLAYING) 590 m_ paused = false;591 592 if (!m_ paused && m_playbackRate)591 m_isPaused = false; 592 593 if (!m_isPaused && m_playbackRate) 593 594 changePipelineState(GST_STATE_PLAYING); 594 595 … … 621 622 void MediaPlayerPrivateGStreamerMSE::asyncStateChangeDone() 622 623 { 623 if (UNLIKELY(!m_pipeline || m_ errorOccured))624 return; 625 626 if (m_ seeking)624 if (UNLIKELY(!m_pipeline || m_didErrorOccur)) 625 return; 626 627 if (m_isSeeking) 627 628 maybeFinishSeek(); 628 629 else … … 775 776 MediaTime MediaPlayerPrivateGStreamerMSE::maxMediaTimeSeekable() const 776 777 { 777 if (UNLIKELY(m_ errorOccured))778 if (UNLIKELY(m_didErrorOccur)) 778 779 return MediaTime::zeroTime(); 779 780 -
trunk/Source/WebCore/platform/graphics/gstreamer/mse/MediaPlayerPrivateGStreamerMSE.h
r252938 r252950 55 55 void updateDownloadBufferingFlag() override { }; 56 56 57 bool isLiveStream() const override { return false; }58 57 MediaTime currentMediaTime() const override; 59 58 -
trunk/Source/WebCore/platform/graphics/gstreamer/mse/MediaSourceClientGStreamerMSE.cpp
r252938 r252950 164 164 165 165 // This is only for on-the-fly reenqueues after appends. When seeking, the seek will do its own flush. 166 if (!m_playerPrivate.m_seeking) 166 // FIXME: Should not be touching private parts. 167 if (!m_playerPrivate.m_isSeeking) 167 168 m_playerPrivate.m_playbackPipeline->flush(trackId); 168 169 }
Note: See TracChangeset
for help on using the changeset viewer.