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

Side by Side Diff: content/renderer/media/media_stream_audio_track.h

Issue 2777583002: Move getUserMedia finish to "when audio track configured". (Closed)
Patch Set: Thread-safety on unittest Created 3 years, 8 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 unified diff | Download patch
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef CONTENT_RENDERER_MEDIA_MEDIA_STREAM_AUDIO_TRACK_H_ 5 #ifndef CONTENT_RENDERER_MEDIA_MEDIA_STREAM_AUDIO_TRACK_H_
6 #define CONTENT_RENDERER_MEDIA_MEDIA_STREAM_AUDIO_TRACK_H_ 6 #define CONTENT_RENDERER_MEDIA_MEDIA_STREAM_AUDIO_TRACK_H_
7 7
8 #include <memory> 8 #include <memory>
9 9
10 #include "base/atomicops.h" 10 #include "base/atomicops.h"
11 #include "base/bind.h"
11 #include "base/callback.h" 12 #include "base/callback.h"
12 #include "base/macros.h" 13 #include "base/macros.h"
13 #include "base/memory/weak_ptr.h" 14 #include "base/memory/weak_ptr.h"
14 #include "base/synchronization/lock.h" 15 #include "base/synchronization/lock.h"
15 #include "base/threading/thread_checker.h" 16 #include "base/threading/thread_checker.h"
16 #include "content/renderer/media/media_stream_audio_deliverer.h" 17 #include "content/renderer/media/media_stream_audio_deliverer.h"
17 #include "content/renderer/media/media_stream_track.h" 18 #include "content/renderer/media/media_stream_track.h"
18 19
19 namespace content { 20 namespace content {
20 21
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
65 66
66 // MediaStreamTrack override. 67 // MediaStreamTrack override.
67 void SetEnabled(bool enabled) override; 68 void SetEnabled(bool enabled) override;
68 void SetContentHint( 69 void SetContentHint(
69 blink::WebMediaStreamTrack::ContentHintType content_hint) override; 70 blink::WebMediaStreamTrack::ContentHintType content_hint) override;
70 71
71 // Returns a unique class identifier. Some subclasses override and use this 72 // Returns a unique class identifier. Some subclasses override and use this
72 // method to provide safe down-casting to their type. 73 // method to provide safe down-casting to their type.
73 virtual void* GetClassIdentifier() const; 74 virtual void* GetClassIdentifier() const;
74 75
76 void SetFormatConfiguredCallback(base::OnceCallback<void()> callback) {
77 base::AutoLock guard(format_set_callback_guard_);
78 format_set_callback_ = std::move(callback);
79 }
80
75 private: 81 private:
76 friend class MediaStreamAudioSource; 82 friend class MediaStreamAudioSource;
77 friend class MediaStreamAudioDeliverer<MediaStreamAudioTrack>; 83 friend class MediaStreamAudioDeliverer<MediaStreamAudioTrack>;
78 84
79 // Called by MediaStreamAudioSource to notify this track that the flow of 85 // Called by MediaStreamAudioSource to notify this track that the flow of
80 // audio data has started from the source. |stop_callback| is run by Stop() 86 // audio data has started from the source. |stop_callback| is run by Stop()
81 // when the source must halt the flow of audio data to this track. 87 // when the source must halt the flow of audio data to this track.
82 void Start(const base::Closure& stop_callback); 88 void Start(const base::Closure& stop_callback);
83 89
84 // Called by the MediaStreamAudioDeliverer to notify this track of an audio 90 // Called by the MediaStreamAudioDeliverer to notify this track of an audio
(...skipping 19 matching lines...) Expand all
104 110
105 // Manages sinks connected to this track and the audio format and data flow. 111 // Manages sinks connected to this track and the audio format and data flow.
106 MediaStreamAudioDeliverer<MediaStreamAudioSink> deliverer_; 112 MediaStreamAudioDeliverer<MediaStreamAudioSink> deliverer_;
107 113
108 // While false (0), silent audio is delivered to the sinks. 114 // While false (0), silent audio is delivered to the sinks.
109 base::subtle::Atomic32 is_enabled_; 115 base::subtle::Atomic32 is_enabled_;
110 116
111 // Buffer used to deliver silent audio data while this track is disabled. 117 // Buffer used to deliver silent audio data while this track is disabled.
112 std::unique_ptr<media::AudioBus> silent_bus_; 118 std::unique_ptr<media::AudioBus> silent_bus_;
113 119
120 // True if the track knows its configuration (OnSetFormat has been called).
121 bool format_is_set_ = false;
122 base::Lock format_set_callback_guard_;
123 base::OnceCallback<void()> format_set_callback_;
124
114 // Provides weak pointers that are valid until Stop() is called. 125 // Provides weak pointers that are valid until Stop() is called.
115 base::WeakPtrFactory<MediaStreamAudioTrack> weak_factory_; 126 base::WeakPtrFactory<MediaStreamAudioTrack> weak_factory_;
116 127
117 DISALLOW_COPY_AND_ASSIGN(MediaStreamAudioTrack); 128 DISALLOW_COPY_AND_ASSIGN(MediaStreamAudioTrack);
118 }; 129 };
119 130
120 } // namespace content 131 } // namespace content
121 132
122 #endif // CONTENT_RENDERER_MEDIA_MEDIA_STREAM_AUDIO_TRACK_H_ 133 #endif // CONTENT_RENDERER_MEDIA_MEDIA_STREAM_AUDIO_TRACK_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698