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

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

Issue 2501623003: Implement MediaStreamTrack contentHint skeleton. (Closed)
Patch Set: const chars 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 contentHintStringNone[] = "";
esprehn 2016/12/09 02:30:09 k prefix constants
pbos 2016/12/09 17:34:46 Done.
48 static const char contentHintStringAudioSpeech[] = "speech";
49 static const char contentHintStringAudioMusic[] = "music";
50 static const char contentHintStringVideoFluid[] = "fluid";
51 static const char contentHintStringVideoDetailed[] = "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::ContentHint hint = m_component->contentHint();
120 switch (hint) {
121 case WebMediaStreamTrack::ContentHint::None:
122 return contentHintStringNone;
123 case WebMediaStreamTrack::ContentHint::AudioSpeech:
124 return contentHintStringAudioSpeech;
125 case WebMediaStreamTrack::ContentHint::AudioMusic:
126 return contentHintStringAudioMusic;
127 case WebMediaStreamTrack::ContentHint::VideoFluid:
128 return contentHintStringVideoFluid;
129 case WebMediaStreamTrack::ContentHint::VideoDetailed:
130 return contentHintStringVideoDetailed;
131 }
132
133 NOTREACHED();
134 return String();
135 }
136
137 void MediaStreamTrack::setContentHint(const String& hint) {
138 WebMediaStreamTrack::ContentHint translatedHint =
139 WebMediaStreamTrack::ContentHint::None;
140 switch (m_component->source()->type()) {
141 case MediaStreamSource::TypeAudio:
142 if (hint == contentHintStringNone) {
143 translatedHint = WebMediaStreamTrack::ContentHint::None;
144 } else if (hint == contentHintStringAudioSpeech) {
145 translatedHint = WebMediaStreamTrack::ContentHint::AudioSpeech;
146 } else if (hint == contentHintStringAudioMusic) {
147 translatedHint = WebMediaStreamTrack::ContentHint::AudioMusic;
148 } else {
149 // TODO(pbos): Log warning?
esprehn 2016/12/09 02:30:09 What does the spec say you should do with an inval
pbos 2016/12/09 17:34:46 Ignore, similar to enums. I put a comment in.
150 return;
151 }
152 break;
153 case MediaStreamSource::TypeVideo:
154 if (hint == contentHintStringNone) {
155 translatedHint = WebMediaStreamTrack::ContentHint::None;
156 } else if (hint == contentHintStringVideoFluid) {
157 translatedHint = WebMediaStreamTrack::ContentHint::VideoFluid;
158 } else if (hint == contentHintStringVideoDetailed) {
159 translatedHint = WebMediaStreamTrack::ContentHint::VideoDetailed;
160 } else {
161 // TODO(pbos): Log warning?
esprehn 2016/12/09 02:30:09 ditto
pbos 2016/12/09 17:34:46 Done.
162 return;
163 }
164 }
165
166 m_component->setContentHint(translatedHint);
167 }
168
110 bool MediaStreamTrack::remote() const { 169 bool MediaStreamTrack::remote() const {
111 return m_component->source()->remote(); 170 return m_component->source()->remote();
112 } 171 }
113 172
114 String MediaStreamTrack::readyState() const { 173 String MediaStreamTrack::readyState() const {
115 if (ended()) 174 if (ended())
116 return "ended"; 175 return "ended";
117 176
118 switch (m_readyState) { 177 switch (m_readyState) {
119 case MediaStreamSource::ReadyStateLive: 178 case MediaStreamSource::ReadyStateLive:
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
254 } 313 }
255 314
256 DEFINE_TRACE(MediaStreamTrack) { 315 DEFINE_TRACE(MediaStreamTrack) {
257 visitor->trace(m_registeredMediaStreams); 316 visitor->trace(m_registeredMediaStreams);
258 visitor->trace(m_component); 317 visitor->trace(m_component);
259 EventTargetWithInlineData::trace(visitor); 318 EventTargetWithInlineData::trace(visitor);
260 ActiveDOMObject::trace(visitor); 319 ActiveDOMObject::trace(visitor);
261 } 320 }
262 321
263 } // namespace blink 322 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698