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

Side by Side Diff: third_party/WebKit/Source/modules/mediastream/MediaStreamTrack.cpp

Issue 2501623003: Implement MediaStreamTrack contentHint skeleton. (Closed)
Patch Set: ContentHint -> ContentHintType Created 4 years 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 unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2011 Google Inc. All rights reserved. 2 * Copyright (C) 2011 Google Inc. All rights reserved.
3 * Copyright (C) 2011 Ericsson AB. All rights reserved. 3 * Copyright (C) 2011 Ericsson AB. All rights reserved.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions 6 * modification, are permitted provided that the following conditions
7 * are met: 7 * are met:
8 * 1. Redistributions of source code must retain the above copyright 8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright 10 * 2. Redistributions in binary form must reproduce the above copyright
(...skipping 25 matching lines...) Expand all
36 #include "modules/mediastream/MediaTrackSettings.h" 36 #include "modules/mediastream/MediaTrackSettings.h"
37 #include "modules/mediastream/UserMediaController.h" 37 #include "modules/mediastream/UserMediaController.h"
38 #include "platform/mediastream/MediaStreamCenter.h" 38 #include "platform/mediastream/MediaStreamCenter.h"
39 #include "platform/mediastream/MediaStreamComponent.h" 39 #include "platform/mediastream/MediaStreamComponent.h"
40 #include "public/platform/WebMediaStreamTrack.h" 40 #include "public/platform/WebMediaStreamTrack.h"
41 #include "wtf/Assertions.h" 41 #include "wtf/Assertions.h"
42 #include <memory> 42 #include <memory>
43 43
44 namespace blink { 44 namespace blink {
45 45
46 namespace {
47 static const char kContentHintStringNone[] = "";
48 static const char kContentHintStringAudioSpeech[] = "speech";
49 static const char kContentHintStringAudioMusic[] = "music";
50 static const char kContentHintStringVideoFluid[] = "fluid";
51 static const char kContentHintStringVideoDetailed[] = "detailed";
52 } // namespace
53
46 MediaStreamTrack* MediaStreamTrack::create(ExecutionContext* context, 54 MediaStreamTrack* MediaStreamTrack::create(ExecutionContext* context,
47 MediaStreamComponent* component) { 55 MediaStreamComponent* component) {
48 MediaStreamTrack* track = new MediaStreamTrack(context, component); 56 MediaStreamTrack* track = new MediaStreamTrack(context, component);
49 track->suspendIfNeeded(); 57 track->suspendIfNeeded();
50 return track; 58 return track;
51 } 59 }
52 60
53 MediaStreamTrack::MediaStreamTrack(ExecutionContext* context, 61 MediaStreamTrack::MediaStreamTrack(ExecutionContext* context,
54 MediaStreamComponent* component) 62 MediaStreamComponent* component)
55 : ActiveScriptWrappable(this), 63 : ActiveScriptWrappable(this),
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
100 108
101 if (!ended()) 109 if (!ended())
102 MediaStreamCenter::instance().didSetMediaStreamTrackEnabled( 110 MediaStreamCenter::instance().didSetMediaStreamTrackEnabled(
103 m_component.get()); 111 m_component.get());
104 } 112 }
105 113
106 bool MediaStreamTrack::muted() const { 114 bool MediaStreamTrack::muted() const {
107 return m_component->muted(); 115 return m_component->muted();
108 } 116 }
109 117
118 String MediaStreamTrack::contentHint() const {
119 WebMediaStreamTrack::ContentHintType hint = m_component->contentHint();
120 switch (hint) {
121 case WebMediaStreamTrack::ContentHintType::None:
122 return kContentHintStringNone;
123 case WebMediaStreamTrack::ContentHintType::AudioSpeech:
124 return kContentHintStringAudioSpeech;
125 case WebMediaStreamTrack::ContentHintType::AudioMusic:
126 return kContentHintStringAudioMusic;
127 case WebMediaStreamTrack::ContentHintType::VideoFluid:
128 return kContentHintStringVideoFluid;
129 case WebMediaStreamTrack::ContentHintType::VideoDetailed:
130 return kContentHintStringVideoDetailed;
131 }
132
133 NOTREACHED();
134 return String();
135 }
136
137 void MediaStreamTrack::setContentHint(const String& hint) {
138 WebMediaStreamTrack::ContentHintType translatedHint =
139 WebMediaStreamTrack::ContentHintType::None;
140 switch (m_component->source()->type()) {
141 case MediaStreamSource::TypeAudio:
142 if (hint == kContentHintStringNone) {
143 translatedHint = WebMediaStreamTrack::ContentHintType::None;
144 } else if (hint == kContentHintStringAudioSpeech) {
145 translatedHint = WebMediaStreamTrack::ContentHintType::AudioSpeech;
146 } else if (hint == kContentHintStringAudioMusic) {
147 translatedHint = WebMediaStreamTrack::ContentHintType::AudioMusic;
148 } else {
149 // TODO(pbos): Log warning?
150 // Invalid values for audio are to be ignored (similar to invalid enum
151 // values).
152 return;
153 }
154 break;
155 case MediaStreamSource::TypeVideo:
156 if (hint == kContentHintStringNone) {
157 translatedHint = WebMediaStreamTrack::ContentHintType::None;
158 } else if (hint == kContentHintStringVideoFluid) {
159 translatedHint = WebMediaStreamTrack::ContentHintType::VideoFluid;
160 } else if (hint == kContentHintStringVideoDetailed) {
161 translatedHint = WebMediaStreamTrack::ContentHintType::VideoDetailed;
162 } else {
163 // TODO(pbos): Log warning?
164 // Invalid values for video are to be ignored (similar to invalid enum
165 // values).
166 return;
167 }
168 }
169
170 m_component->setContentHint(translatedHint);
171 }
172
110 bool MediaStreamTrack::remote() const { 173 bool MediaStreamTrack::remote() const {
111 return m_component->source()->remote(); 174 return m_component->source()->remote();
112 } 175 }
113 176
114 String MediaStreamTrack::readyState() const { 177 String MediaStreamTrack::readyState() const {
115 if (ended()) 178 if (ended())
116 return "ended"; 179 return "ended";
117 180
118 switch (m_readyState) { 181 switch (m_readyState) {
119 case MediaStreamSource::ReadyStateLive: 182 case MediaStreamSource::ReadyStateLive:
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
254 } 317 }
255 318
256 DEFINE_TRACE(MediaStreamTrack) { 319 DEFINE_TRACE(MediaStreamTrack) {
257 visitor->trace(m_registeredMediaStreams); 320 visitor->trace(m_registeredMediaStreams);
258 visitor->trace(m_component); 321 visitor->trace(m_component);
259 EventTargetWithInlineData::trace(visitor); 322 EventTargetWithInlineData::trace(visitor);
260 SuspendableObject::trace(visitor); 323 SuspendableObject::trace(visitor);
261 } 324 }
262 325
263 } // namespace blink 326 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698