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

Side by Side Diff: third_party/WebKit/Source/platform/mediastream/MediaStreamComponent.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 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::ContentHint::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::ContentHint 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 ThreadState::current()->registerPreFinalizer(this); 72 ThreadState::current()->registerPreFinalizer(this);
62 } 73 }
63 74
64 MediaStreamComponent* MediaStreamComponent::clone() const { 75 MediaStreamComponent* MediaStreamComponent::clone() const {
65 MediaStreamComponent* clonedComponent = new MediaStreamComponent( 76 MediaStreamComponent* clonedComponent = new MediaStreamComponent(
66 createCanonicalUUIDString(), source(), m_enabled, m_muted); 77 createCanonicalUUIDString(), source(), m_enabled, m_muted, m_contentHint);
67 // TODO(pbos): Clone |m_trackData| as well. 78 // TODO(pbos): Clone |m_trackData| as well.
68 // TODO(pbos): Move properties from MediaStreamTrack here so that they are 79 // TODO(pbos): Move properties from MediaStreamTrack here so that they are
69 // also cloned. Part of crbug:669212 since stopped is currently not carried 80 // also cloned. Part of crbug:669212 since stopped is currently not carried
70 // over, nor is ended(). 81 // over, nor is ended().
71 return clonedComponent; 82 return clonedComponent;
72 } 83 }
73 84
74 void MediaStreamComponent::dispose() { 85 void MediaStreamComponent::dispose() {
75 m_trackData.reset(); 86 m_trackData.reset();
76 } 87 }
77 88
78 void MediaStreamComponent::AudioSourceProviderImpl::wrap( 89 void MediaStreamComponent::AudioSourceProviderImpl::wrap(
79 WebAudioSourceProvider* provider) { 90 WebAudioSourceProvider* provider) {
80 MutexLocker locker(m_provideInputLock); 91 MutexLocker locker(m_provideInputLock);
81 m_webAudioSourceProvider = provider; 92 m_webAudioSourceProvider = provider;
82 } 93 }
83 94
84 void MediaStreamComponent::getSettings( 95 void MediaStreamComponent::getSettings(
85 WebMediaStreamTrack::Settings& settings) { 96 WebMediaStreamTrack::Settings& settings) {
86 DCHECK(m_trackData); 97 DCHECK(m_trackData);
87 m_trackData->getSettings(settings); 98 m_trackData->getSettings(settings);
88 } 99 }
89 100
101 void MediaStreamComponent::setContentHint(
102 WebMediaStreamTrack::ContentHint hint) {
103 switch (hint) {
104 case WebMediaStreamTrack::ContentHint::None:
105 break;
106 case WebMediaStreamTrack::ContentHint::AudioSpeech:
107 case WebMediaStreamTrack::ContentHint::AudioMusic:
108 DCHECK_EQ(MediaStreamSource::TypeAudio, source()->type());
109 break;
110 case WebMediaStreamTrack::ContentHint::VideoFluid:
111 case WebMediaStreamTrack::ContentHint::VideoDetailed:
112 DCHECK_EQ(MediaStreamSource::TypeVideo, source()->type());
113 break;
114 }
115 if (hint == m_contentHint)
116 return;
117 m_contentHint = hint;
118
119 MediaStreamCenter::instance().didSetContentHint(this);
120 }
121
90 void MediaStreamComponent::AudioSourceProviderImpl::provideInput( 122 void MediaStreamComponent::AudioSourceProviderImpl::provideInput(
91 AudioBus* bus, 123 AudioBus* bus,
92 size_t framesToProcess) { 124 size_t framesToProcess) {
93 DCHECK(bus); 125 DCHECK(bus);
94 if (!bus) 126 if (!bus)
95 return; 127 return;
96 128
97 MutexTryLocker tryLocker(m_provideInputLock); 129 MutexTryLocker tryLocker(m_provideInputLock);
98 if (!tryLocker.locked() || !m_webAudioSourceProvider) { 130 if (!tryLocker.locked() || !m_webAudioSourceProvider) {
99 bus->zero(); 131 bus->zero();
100 return; 132 return;
101 } 133 }
102 134
103 // Wrap the AudioBus channel data using WebVector. 135 // Wrap the AudioBus channel data using WebVector.
104 size_t n = bus->numberOfChannels(); 136 size_t n = bus->numberOfChannels();
105 WebVector<float*> webAudioData(n); 137 WebVector<float*> webAudioData(n);
106 for (size_t i = 0; i < n; ++i) 138 for (size_t i = 0; i < n; ++i)
107 webAudioData[i] = bus->channel(i)->mutableData(); 139 webAudioData[i] = bus->channel(i)->mutableData();
108 140
109 m_webAudioSourceProvider->provideInput(webAudioData, framesToProcess); 141 m_webAudioSourceProvider->provideInput(webAudioData, framesToProcess);
110 } 142 }
111 143
112 DEFINE_TRACE(MediaStreamComponent) { 144 DEFINE_TRACE(MediaStreamComponent) {
113 visitor->trace(m_source); 145 visitor->trace(m_source);
114 } 146 }
115 147
116 } // namespace blink 148 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698