Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(621)

Unified Diff: Source/web/WebMediaPlayerClientImpl.cpp

Issue 170233009: Initial implementation of AudioTrack, AudioTrackList, VideoTrack, and VideoTrackList. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@blink-master
Patch Set: Created 6 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: Source/web/WebMediaPlayerClientImpl.cpp
diff --git a/Source/web/WebMediaPlayerClientImpl.cpp b/Source/web/WebMediaPlayerClientImpl.cpp
index 5ff8923acfccddb56ff0bbc115fb26698c5fcb69..bd47b84b03817fd34bc2cd5b4b512a21271a170e 100644
--- a/Source/web/WebMediaPlayerClientImpl.cpp
+++ b/Source/web/WebMediaPlayerClientImpl.cpp
@@ -13,6 +13,8 @@
#include "core/frame/Frame.h"
#include "core/html/HTMLMediaElement.h"
#include "core/html/TimeRanges.h"
+#include "core/html/track/AudioTrack.h"
+#include "core/html/track/VideoTrack.h"
#include "core/rendering/RenderLayerCompositor.h"
#include "core/rendering/RenderView.h"
#include "modules/mediastream/MediaStreamRegistry.h"
@@ -60,7 +62,7 @@ static PassOwnPtr<WebMediaPlayer> createWebMediaPlayer(WebMediaPlayerClient* cli
return adoptPtr(webFrame->client()->createMediaPlayer(webFrame, url, client));
}
-WebMediaPlayer* WebMediaPlayerClientImpl::mediaPlayer() const
+WebMediaPlayer* WebMediaPlayerClientImpl::webMediaPlayer() const
{
return m_webMediaPlayer.get();
}
@@ -177,14 +179,94 @@ void WebMediaPlayerClientImpl::setWebLayer(blink::WebLayer* layer)
m_client->mediaPlayerSetWebLayer(layer);
}
+static AtomicString VideoKindToString(WebMediaPlayerClient::VideoTrackKind kind)
+{
+ switch (kind) {
+ case WebMediaPlayerClient::VideoTrackKindNone:
+ return AtomicString();
+ break;
+ case WebMediaPlayerClient::VideoTrackKindAlternative:
+ return VideoTrack::alternativeKeyword();
+ break;
+ case WebMediaPlayerClient::VideoTrackKindCaptions:
+ return VideoTrack::captionsKeyword();
+ break;
+ case WebMediaPlayerClient::VideoTrackKindMain:
+ return VideoTrack::mainKeyword();
+ break;
+ case WebMediaPlayerClient::VideoTrackKindSign:
+ return VideoTrack::signKeyword();
+ break;
+ case WebMediaPlayerClient::VideoTrackKindSubtitles:
+ return VideoTrack::subtitlesKeyword();
+ break;
+ case WebMediaPlayerClient::VideoTrackKindCommentary:
+ return VideoTrack::commentaryKeyword();
+ break;
+ }
+
+ ASSERT_NOT_REACHED();
+ return AtomicString();
+}
+
+void WebMediaPlayerClientImpl::addVideoTrack(const WebString& id, VideoTrackKind kind, const WebString& label, const WebString& language, bool selected)
+{
+ m_client->mediaPlayerDidAddVideoTrack(id, VideoKindToString(kind), label, language, selected);
+}
+
+void WebMediaPlayerClientImpl::removeVideoTrack(const WebString& id)
+{
+ m_client->mediaPlayerDidRemoveVideoTrack(id);
+}
+
+static AtomicString AudioKindToString(WebMediaPlayerClient::AudioTrackKind kind)
+{
+ switch (kind) {
+ case WebMediaPlayerClient::AudioTrackKindNone:
+ return AtomicString();
+ break;
+ case WebMediaPlayerClient::AudioTrackKindAlternative:
+ return AudioTrack::alternativeKeyword();
+ break;
+ case WebMediaPlayerClient::AudioTrackKindDescriptions:
+ return AudioTrack::descriptionsKeyword();
+ break;
+ case WebMediaPlayerClient::AudioTrackKindMain:
+ return AudioTrack::mainKeyword();
+ break;
+ case WebMediaPlayerClient::AudioTrackKindMainDescriptions:
+ return AudioTrack::mainDescriptionsKeyword();
+ break;
+ case WebMediaPlayerClient::AudioTrackKindTranslation:
+ return AudioTrack::translationKeyword();
+ break;
+ case WebMediaPlayerClient::AudioTrackKindCommentary:
+ return AudioTrack::commentaryKeyword();
+ break;
+ }
+
+ ASSERT_NOT_REACHED();
+ return AtomicString();
+}
+
+void WebMediaPlayerClientImpl::addAudioTrack(const WebString& id, AudioTrackKind kind, const WebString& label, const WebString& language, bool enabled)
+{
+ m_client->mediaPlayerDidAddAudioTrack(id, AudioKindToString(kind), label, language, enabled);
+}
+
+void WebMediaPlayerClientImpl::removeAudioTrack(const WebString& id)
+{
+ m_client->mediaPlayerDidRemoveAudioTrack(id);
+}
+
void WebMediaPlayerClientImpl::addTextTrack(WebInbandTextTrack* textTrack)
{
- m_client->mediaPlayerDidAddTrack(textTrack);
+ m_client->mediaPlayerDidAddTextTrack(textTrack);
}
void WebMediaPlayerClientImpl::removeTextTrack(WebInbandTextTrack* textTrack)
{
- m_client->mediaPlayerDidRemoveTrack(textTrack);
+ m_client->mediaPlayerDidRemoveTextTrack(textTrack);
}
void WebMediaPlayerClientImpl::mediaSourceOpened(WebMediaSource* webMediaSource)

Powered by Google App Engine
This is Rietveld 408576698