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

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

Issue 1834323002: MediaStream audio: Refactor 3 separate "glue" implementations into one. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: REBASE + Workaround to ensure MediaStreamAudioProcessor is destroyed on the main thread. Created 4 years, 7 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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_SOURCE_H_ 5 #ifndef CONTENT_RENDERER_MEDIA_MEDIA_STREAM_SOURCE_H_
6 #define CONTENT_RENDERER_MEDIA_MEDIA_STREAM_SOURCE_H_ 6 #define CONTENT_RENDERER_MEDIA_MEDIA_STREAM_SOURCE_H_
7 7
8 #include "base/callback.h" 8 #include "base/callback.h"
9 #include "base/compiler_specific.h" 9 #include "base/compiler_specific.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
11 #include "base/macros.h" 11 #include "base/macros.h"
12 #include "base/threading/thread_checker.h"
12 #include "content/common/content_export.h" 13 #include "content/common/content_export.h"
13 #include "content/common/media/media_stream_options.h" 14 #include "content/common/media/media_stream_options.h"
14 #include "third_party/WebKit/public/platform/WebMediaStreamSource.h" 15 #include "third_party/WebKit/public/platform/WebMediaStreamSource.h"
15 16
16 namespace blink { 17 namespace blink {
17 class WebMediaStreamTrack; 18 class WebMediaStreamTrack;
18 } // namespace blink 19 } // namespace blink
19 20
20 namespace content { 21 namespace content {
21 22
(...skipping 14 matching lines...) Expand all
36 37
37 MediaStreamSource(); 38 MediaStreamSource();
38 ~MediaStreamSource() override; 39 ~MediaStreamSource() override;
39 40
40 // Returns device information about a source that has been created by a 41 // Returns device information about a source that has been created by a
41 // JavaScript call to GetUserMedia, e.g., a camera or microphone. 42 // JavaScript call to GetUserMedia, e.g., a camera or microphone.
42 const StreamDeviceInfo& device_info() const { 43 const StreamDeviceInfo& device_info() const {
43 return device_info_; 44 return device_info_;
44 } 45 }
45 46
46 // Stops the source (by calling DoStopSource()). This sets the 47 // Stops the source (by calling DoStopSource()). This runs the
47 // WebMediaStreamSource::readyState to ended, triggers the |stop_callback_| 48 // |stop_callback_| (if set), and then sets the
48 // if set. All pointers to this object are invalid after calling this. 49 // WebMediaStreamSource::readyState to ended.
49 void StopSource(); 50 void StopSource();
50 51
51 void ResetSourceStoppedCallback() { 52 // Sets device information about a source that has been created by a
52 DCHECK(!stop_callback_.is_null()); 53 // JavaScript call to GetUserMedia. F.E a camera or microphone.
53 stop_callback_.Reset(); 54 void SetDeviceInfo(const StreamDeviceInfo& device_info);
54 } 55
56 // Sets a callback that will be triggered when StopSource is called.
57 void SetStopCallback(const SourceStoppedCallback& stop_callback);
58
59 // Clears the previously-set SourceStoppedCallback so that it will not be run
60 // in the future.
61 void ResetSourceStoppedCallback();
55 62
56 protected: 63 protected:
57 // Called when StopSource is called. It allows derived classes to implement 64 // Called when StopSource is called. It allows derived classes to implement
58 // its own Stop method. 65 // its own Stop method.
59 virtual void DoStopSource() = 0; 66 virtual void DoStopSource() = 0;
60 67
61 // Sets device information about a source that has been created by a 68 private:
62 // JavaScript call to GetUserMedia. F.E a camera or microphone. 69 // Called by both StopSource() and the destructor to ensure the
63 void SetDeviceInfo(const StreamDeviceInfo& device_info) { 70 // |stop_callback_| has been run and the blink::WebMediaStreamSource's ready
64 device_info_ = device_info; 71 // state has been set to "ended."
65 } 72 void RunStopCallbackAndEndStream();
66 73
67 // Sets a callback that will be triggered when StopSource is called.
68 void SetStopCallback(const SourceStoppedCallback& stop_callback) {
69 DCHECK(stop_callback_.is_null());
70 stop_callback_ = stop_callback;
71 }
72
73 private:
74 StreamDeviceInfo device_info_; 74 StreamDeviceInfo device_info_;
75 SourceStoppedCallback stop_callback_; 75 SourceStoppedCallback stop_callback_;
76 76
77 // In debug builds, check that all methods are being called on the main
78 // thread.
79 base::ThreadChecker thread_checker_;
80
77 DISALLOW_COPY_AND_ASSIGN(MediaStreamSource); 81 DISALLOW_COPY_AND_ASSIGN(MediaStreamSource);
78 }; 82 };
79 83
80 } // namespace content 84 } // namespace content
81 85
82 #endif // CONTENT_RENDERER_MEDIA_MEDIA_STREAM_SOURCE_H_ 86 #endif // CONTENT_RENDERER_MEDIA_MEDIA_STREAM_SOURCE_H_
OLDNEW
« no previous file with comments | « content/renderer/media/media_stream_renderer_factory_impl.cc ('k') | content/renderer/media/media_stream_source.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698