Changeset 53617 in webkit
- Timestamp:
- Jan 21, 2010 1:43:18 AM (14 years ago)
- Location:
- trunk/WebCore
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/WebCore/ChangeLog
r53611 r53617 1 2010-01-13 Philippe Normand <pnormand@igalia.com> 2 3 Reviewed by Oliver Hunt. 4 5 [GTK] handle media redirections 6 https://bugs.webkit.org/show_bug.cgi?id=33539 7 8 Media redirections support. 9 10 * platform/graphics/gtk/MediaPlayerPrivateGStreamer.cpp: 11 (WebCore::mediaPlayerPrivateMessageCallback): 12 (WebCore::MediaPlayerPrivate::MediaPlayerPrivate): 13 (WebCore::MediaPlayerPrivate::~MediaPlayerPrivate): 14 (WebCore::MediaPlayerPrivate::mediaLocationChanged): 15 (WebCore::MediaPlayerPrivate::loadNextLocation): 16 * platform/graphics/gtk/MediaPlayerPrivateGStreamer.h: 17 (WebCore::MediaPlayerPrivate::pipelineReset): 18 1 19 2010-01-21 No'am Rosenthal <noam.rosenthal@nokia.com> 2 20 -
trunk/WebCore/platform/graphics/gtk/MediaPlayerPrivateGStreamer.cpp
r53329 r53617 37 37 #include "NotImplemented.h" 38 38 #include "ScrollView.h" 39 #include "SecurityOrigin.h" 39 40 #include "TimeRanges.h" 40 41 #include "VideoSinkGStreamer.h" … … 60 61 MediaPlayerPrivate* mp = reinterpret_cast<MediaPlayerPrivate*>(data); 61 62 gint percent = 0; 63 bool issueError = true; 64 bool attemptNextLocation = false; 65 66 if (message->structure) { 67 const gchar* messageTypeName = gst_structure_get_name(message->structure); 68 69 // Redirect messages are sent from elements, like qtdemux, to 70 // notify of the new location(s) of the media. 71 if (!g_strcmp0(messageTypeName, "redirect")) { 72 mp->mediaLocationChanged(message); 73 return true; 74 } 75 } 62 76 63 77 switch (GST_MESSAGE_TYPE(message)) { 64 78 case GST_MESSAGE_ERROR: 79 if (mp && mp->pipelineReset()) 80 break; 65 81 gst_message_parse_error(message, &err.outPtr(), &debug.outPtr()); 66 82 LOG_VERBOSE(Media, "Error: %d, %s", err->code, err->message); … … 73 89 || err->code == GST_RESOURCE_ERROR_NOT_FOUND) 74 90 error = MediaPlayer::FormatError; 75 else if (err->domain == GST_STREAM_ERROR) 91 else if (err->domain == GST_STREAM_ERROR) { 76 92 error = MediaPlayer::DecodeError; 77 else if (err->domain == GST_RESOURCE_ERROR) 93 attemptNextLocation = true; 94 } else if (err->domain == GST_RESOURCE_ERROR) 78 95 error = MediaPlayer::NetworkError; 79 96 80 if (mp) 81 mp->loadingFailed(error); 97 if (mp) { 98 if (attemptNextLocation) 99 issueError = !mp->loadNextLocation(); 100 if (issueError) 101 mp->loadingFailed(error); 102 } 82 103 break; 83 104 case GST_MESSAGE_EOS: … … 209 230 , m_size(IntSize()) 210 231 , m_buffer(0) 232 , m_mediaLocations(0) 233 , m_mediaLocationCurrentIndex(0) 234 , m_resetPipeline(false) 211 235 , m_paused(true) 212 236 , m_seeking(false) … … 228 252 gst_buffer_unref(m_buffer); 229 253 m_buffer = 0; 254 255 if (m_mediaLocations) { 256 gst_structure_free(m_mediaLocations); 257 m_mediaLocations = 0; 258 } 230 259 231 260 if (m_playBin) { … … 629 658 gst_element_state_get_name(pending)); 630 659 660 m_resetPipeline = state <= GST_STATE_READY; 661 631 662 if (state == GST_STATE_READY) 632 663 m_readyState = MediaPlayer::HaveNothing; … … 701 732 m_player->readyStateChanged(); 702 733 } 734 } 735 736 void MediaPlayerPrivate::mediaLocationChanged(GstMessage* message) 737 { 738 if (m_mediaLocations) 739 gst_structure_free(m_mediaLocations); 740 741 if (message->structure) { 742 // This structure can contain: 743 // - both a new-location string and embedded locations structure 744 // - or only a new-location string. 745 m_mediaLocations = gst_structure_copy(message->structure); 746 const GValue* locations = gst_structure_get_value(m_mediaLocations, "locations"); 747 748 if (locations) 749 m_mediaLocationCurrentIndex = gst_value_list_get_size(locations) -1; 750 751 loadNextLocation(); 752 } 753 } 754 755 bool MediaPlayerPrivate::loadNextLocation() 756 { 757 if (!m_mediaLocations) 758 return false; 759 760 const GValue* locations = gst_structure_get_value(m_mediaLocations, "locations"); 761 const gchar* newLocation = 0; 762 763 if (!locations) { 764 // Fallback on new-location string. 765 newLocation = gst_structure_get_string(m_mediaLocations, "new-location"); 766 if (!newLocation) 767 return false; 768 } 769 770 if (!newLocation) { 771 if (m_mediaLocationCurrentIndex < 0) { 772 m_mediaLocations = 0; 773 return false; 774 } 775 776 const GValue* location = gst_value_list_get_value(locations, 777 m_mediaLocationCurrentIndex); 778 const GstStructure* structure = gst_value_get_structure(location); 779 780 if (!structure) { 781 m_mediaLocationCurrentIndex--; 782 return false; 783 } 784 785 newLocation = gst_structure_get_string(structure, "new-location"); 786 } 787 788 if (newLocation) { 789 // Found a candidate. new-location is not always an absolute url 790 // though. We need to take the base of the current url and 791 // append the value of new-location to it. 792 793 gchar* currentLocation = 0; 794 g_object_get(m_playBin, "uri", ¤tLocation, NULL); 795 796 KURL currentUrl(KURL(), currentLocation); 797 g_free(currentLocation); 798 799 KURL newUrl; 800 801 if (gst_uri_is_valid(newLocation)) 802 newUrl = KURL(KURL(), newLocation); 803 else 804 newUrl = KURL(KURL(), currentUrl.baseAsString() + newLocation); 805 806 RefPtr<SecurityOrigin> securityOrigin = SecurityOrigin::create(currentUrl); 807 if (securityOrigin->canRequest(newUrl)) { 808 LOG_VERBOSE(Media, "New media url: %s", newUrl.string().utf8().data()); 809 810 // Reset player states. 811 m_networkState = MediaPlayer::Loading; 812 m_player->networkStateChanged(); 813 m_readyState = MediaPlayer::HaveNothing; 814 m_player->readyStateChanged(); 815 816 // Reset pipeline state. 817 m_resetPipeline = true; 818 gst_element_set_state(m_playBin, GST_STATE_READY); 819 820 GstState state; 821 gst_element_get_state(m_playBin, &state, 0, 0); 822 if (state <= GST_STATE_READY) { 823 // Set the new uri and start playing. 824 g_object_set(m_playBin, "uri", newUrl.string().utf8().data(), NULL); 825 gst_element_set_state(m_playBin, GST_STATE_PLAYING); 826 return true; 827 } 828 } 829 } 830 m_mediaLocationCurrentIndex--; 831 return false; 832 703 833 } 704 834 -
trunk/WebCore/platform/graphics/gtk/MediaPlayerPrivateGStreamer.h
r53255 r53617 62 62 void load(const String &url); 63 63 void cancelLoad(); 64 bool loadNextLocation(); 64 65 65 66 void play(); … … 92 93 void setSize(const IntSize&); 93 94 95 void mediaLocationChanged(GstMessage*); 94 96 void loadStateChanged(); 95 97 void sizeChanged(); … … 105 107 106 108 bool supportsFullscreen() const; 109 110 bool pipelineReset() const { return m_resetPipeline; } 107 111 108 112 private: … … 139 143 IntSize m_size; 140 144 GstBuffer* m_buffer; 141 145 GstStructure* m_mediaLocations; 146 gint m_mediaLocationCurrentIndex; 147 bool m_resetPipeline; 142 148 bool m_paused; 143 149 bool m_seeking;
Note: See TracChangeset
for help on using the changeset viewer.