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

Side by Side Diff: third_party/WebKit/Source/platform/mediastream/MediaStreamComponent.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 Ericsson AB. All rights reserved. 2 * Copyright (C) 2011 Ericsson AB. All rights reserved.
3 * Copyright (C) 2013 Google Inc. All rights reserved. 3 * Copyright (C) 2013 Google Inc. 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 are 6 * modification, are permitted provided that the following conditions are
7 * met: 7 * met:
8 * 8 *
9 * * Redistributions of source code must retain the above copyright 9 * * Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer. 10 * notice, this list of conditions and the following disclaimer.
(...skipping 15 matching lines...) Expand all
26 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
27 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
28 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */ 30 */
31 31
32 #include "platform/mediastream/MediaStreamComponent.h" 32 #include "platform/mediastream/MediaStreamComponent.h"
33 33
34 #include "platform/UUID.h" 34 #include "platform/UUID.h"
35 #include "platform/audio/AudioBus.h" 35 #include "platform/audio/AudioBus.h"
36 #include "platform/mediastream/MediaStreamCenter.h"
36 #include "platform/mediastream/MediaStreamSource.h" 37 #include "platform/mediastream/MediaStreamSource.h"
37 #include "public/platform/WebAudioSourceProvider.h" 38 #include "public/platform/WebAudioSourceProvider.h"
38 #include "public/platform/WebMediaStreamTrack.h" 39 #include "public/platform/WebMediaStreamTrack.h"
39 40
40 namespace blink { 41 namespace blink {
41 42
42 MediaStreamComponent* MediaStreamComponent::create(MediaStreamSource* source) { 43 MediaStreamComponent* MediaStreamComponent::create(MediaStreamSource* source) {
43 return new MediaStreamComponent(createCanonicalUUIDString(), source); 44 return new MediaStreamComponent(createCanonicalUUIDString(), source);
44 } 45 }
45 46
46 MediaStreamComponent* MediaStreamComponent::create(const String& id, 47 MediaStreamComponent* MediaStreamComponent::create(const String& id,
47 MediaStreamSource* source) { 48 MediaStreamSource* source) {
48 return new MediaStreamComponent(id, source); 49 return new MediaStreamComponent(id, source);
49 } 50 }
50 51
51 MediaStreamComponent::MediaStreamComponent(const String& id, 52 MediaStreamComponent::MediaStreamComponent(const String& id,
52 MediaStreamSource* source) 53 MediaStreamSource* source)
53 : MediaStreamComponent(id, source, true, false) {} 54 : MediaStreamComponent(id,
55 source,
56 true,
57 false,
58 WebMediaStreamTrack::ContentHintType::None) {}
54 59
55 MediaStreamComponent::MediaStreamComponent(const String& id, 60 MediaStreamComponent::MediaStreamComponent(
56 MediaStreamSource* source, 61 const String& id,
57 bool enabled, 62 MediaStreamSource* source,
58 bool muted) 63 bool enabled,
59 : m_source(source), m_id(id), m_enabled(enabled), m_muted(muted) { 64 bool muted,
65 WebMediaStreamTrack::ContentHintType contentHint)
66 : m_source(source),
67 m_id(id),
68 m_enabled(enabled),
69 m_muted(muted),
70 m_contentHint(contentHint) {
60 DCHECK(m_id.length()); 71 DCHECK(m_id.length());
61 } 72 }
62 73
63 MediaStreamComponent* MediaStreamComponent::clone() const { 74 MediaStreamComponent* MediaStreamComponent::clone() const {
64 MediaStreamComponent* clonedComponent = new MediaStreamComponent( 75 MediaStreamComponent* clonedComponent = new MediaStreamComponent(
65 createCanonicalUUIDString(), source(), m_enabled, m_muted); 76 createCanonicalUUIDString(), source(), m_enabled, m_muted, m_contentHint);
66 // TODO(pbos): Clone |m_trackData| as well. 77 // TODO(pbos): Clone |m_trackData| as well.
67 // TODO(pbos): Move properties from MediaStreamTrack here so that they are 78 // TODO(pbos): Move properties from MediaStreamTrack here so that they are
68 // also cloned. Part of crbug:669212 since stopped is currently not carried 79 // also cloned. Part of crbug:669212 since stopped is currently not carried
69 // over, nor is ended(). 80 // over, nor is ended().
70 return clonedComponent; 81 return clonedComponent;
71 } 82 }
72 83
73 void MediaStreamComponent::dispose() { 84 void MediaStreamComponent::dispose() {
74 m_trackData.reset(); 85 m_trackData.reset();
75 } 86 }
76 87
77 void MediaStreamComponent::AudioSourceProviderImpl::wrap( 88 void MediaStreamComponent::AudioSourceProviderImpl::wrap(
78 WebAudioSourceProvider* provider) { 89 WebAudioSourceProvider* provider) {
79 MutexLocker locker(m_provideInputLock); 90 MutexLocker locker(m_provideInputLock);
80 m_webAudioSourceProvider = provider; 91 m_webAudioSourceProvider = provider;
81 } 92 }
82 93
83 void MediaStreamComponent::getSettings( 94 void MediaStreamComponent::getSettings(
84 WebMediaStreamTrack::Settings& settings) { 95 WebMediaStreamTrack::Settings& settings) {
85 DCHECK(m_trackData); 96 DCHECK(m_trackData);
86 m_trackData->getSettings(settings); 97 m_trackData->getSettings(settings);
87 } 98 }
88 99
100 void MediaStreamComponent::setContentHint(
101 WebMediaStreamTrack::ContentHintType hint) {
102 switch (hint) {
103 case WebMediaStreamTrack::ContentHintType::None:
104 break;
105 case WebMediaStreamTrack::ContentHintType::AudioSpeech:
106 case WebMediaStreamTrack::ContentHintType::AudioMusic:
107 DCHECK_EQ(MediaStreamSource::TypeAudio, source()->type());
108 break;
109 case WebMediaStreamTrack::ContentHintType::VideoFluid:
110 case WebMediaStreamTrack::ContentHintType::VideoDetailed:
111 DCHECK_EQ(MediaStreamSource::TypeVideo, source()->type());
112 break;
113 }
114 if (hint == m_contentHint)
115 return;
116 m_contentHint = hint;
117
118 MediaStreamCenter::instance().didSetContentHint(this);
119 }
120
89 void MediaStreamComponent::AudioSourceProviderImpl::provideInput( 121 void MediaStreamComponent::AudioSourceProviderImpl::provideInput(
90 AudioBus* bus, 122 AudioBus* bus,
91 size_t framesToProcess) { 123 size_t framesToProcess) {
92 DCHECK(bus); 124 DCHECK(bus);
93 if (!bus) 125 if (!bus)
94 return; 126 return;
95 127
96 MutexTryLocker tryLocker(m_provideInputLock); 128 MutexTryLocker tryLocker(m_provideInputLock);
97 if (!tryLocker.locked() || !m_webAudioSourceProvider) { 129 if (!tryLocker.locked() || !m_webAudioSourceProvider) {
98 bus->zero(); 130 bus->zero();
99 return; 131 return;
100 } 132 }
101 133
102 // Wrap the AudioBus channel data using WebVector. 134 // Wrap the AudioBus channel data using WebVector.
103 size_t n = bus->numberOfChannels(); 135 size_t n = bus->numberOfChannels();
104 WebVector<float*> webAudioData(n); 136 WebVector<float*> webAudioData(n);
105 for (size_t i = 0; i < n; ++i) 137 for (size_t i = 0; i < n; ++i)
106 webAudioData[i] = bus->channel(i)->mutableData(); 138 webAudioData[i] = bus->channel(i)->mutableData();
107 139
108 m_webAudioSourceProvider->provideInput(webAudioData, framesToProcess); 140 m_webAudioSourceProvider->provideInput(webAudioData, framesToProcess);
109 } 141 }
110 142
111 DEFINE_TRACE(MediaStreamComponent) { 143 DEFINE_TRACE(MediaStreamComponent) {
112 visitor->trace(m_source); 144 visitor->trace(m_source);
113 } 145 }
114 146
115 } // namespace blink 147 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698