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

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

Issue 1918173002: Add support for device-change notifications to MediaStreamDispatcher and MediaStreamDispatcherHost (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: hta comments 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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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_DISPATCHER_H_ 5 #ifndef CONTENT_RENDERER_MEDIA_MEDIA_STREAM_DISPATCHER_H_
6 #define CONTENT_RENDERER_MEDIA_MEDIA_STREAM_DISPATCHER_H_ 6 #define CONTENT_RENDERER_MEDIA_MEDIA_STREAM_DISPATCHER_H_
7 7
8 #include <list> 8 #include <list>
9 #include <map> 9 #include <map>
10 #include <memory> 10 #include <memory>
11 #include <string> 11 #include <string>
12 #include <vector>
12 13
13 #include "base/gtest_prod_util.h" 14 #include "base/gtest_prod_util.h"
14 #include "base/macros.h" 15 #include "base/macros.h"
15 #include "base/memory/weak_ptr.h" 16 #include "base/memory/weak_ptr.h"
16 #include "base/threading/thread_checker.h" 17 #include "base/threading/thread_checker.h"
17 #include "content/common/content_export.h" 18 #include "content/common/content_export.h"
18 #include "content/common/media/media_stream_options.h" 19 #include "content/common/media/media_stream_options.h"
19 #include "content/public/renderer/render_frame_observer.h" 20 #include "content/public/renderer/render_frame_observer.h"
20 #include "content/renderer/media/media_stream_dispatcher_eventhandler.h" 21 #include "content/renderer/media/media_stream_dispatcher_eventhandler.h"
21 22
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
71 const GURL& security_origin); 72 const GURL& security_origin);
72 73
73 // Cancel the request to open a device. 74 // Cancel the request to open a device.
74 virtual void CancelOpenDevice( 75 virtual void CancelOpenDevice(
75 int request_id, 76 int request_id,
76 const base::WeakPtr<MediaStreamDispatcherEventHandler>& event_handler); 77 const base::WeakPtr<MediaStreamDispatcherEventHandler>& event_handler);
77 78
78 // Close a started device. |label| is provided in OnDeviceOpened. 79 // Close a started device. |label| is provided in OnDeviceOpened.
79 void CloseDevice(const std::string& label); 80 void CloseDevice(const std::string& label);
80 81
82 // Register and unregister event handlers for device-change notifications.
83 // It is an error to try to subscribe a handler that is already subscribed or
84 // to cancel the subscription of a handler that is not subscribed. Also,
85 // each subscribed handler must make sure to invoke
86 // CancelDeviceChangeNotifications() before the handler is destroyed.
87 void SubscribeToDeviceChangeNotifications(
88 const base::WeakPtr<MediaStreamDispatcherEventHandler>& event_handler,
89 const GURL& security_origin);
90 void CancelDeviceChangeNotifications(
91 const base::WeakPtr<MediaStreamDispatcherEventHandler>& event_handler);
92
81 // Check if the label is a valid stream. 93 // Check if the label is a valid stream.
82 virtual bool IsStream(const std::string& label); 94 virtual bool IsStream(const std::string& label);
83 // Get the video session_id given a label. The label identifies a stream. 95 // Get the video session_id given a label. The label identifies a stream.
84 // index is the index in the video_device_array of the stream. 96 // index is the index in the video_device_array of the stream.
85 virtual int video_session_id(const std::string& label, int index); 97 virtual int video_session_id(const std::string& label, int index);
86 // Returns an audio session_id given a label and an index. 98 // Returns an audio session_id given a label and an index.
87 virtual int audio_session_id(const std::string& label, int index); 99 virtual int audio_session_id(const std::string& label, int index);
88 100
89 protected: 101 protected:
90 int GetNextIpcIdForTest() { return next_ipc_id_; } 102 int GetNextIpcIdForTest() { return next_ipc_id_; }
(...skipping 26 matching lines...) Expand all
117 void OnDeviceStopped(const std::string& label, 129 void OnDeviceStopped(const std::string& label,
118 const StreamDeviceInfo& device_info); 130 const StreamDeviceInfo& device_info);
119 void OnDevicesEnumerated( 131 void OnDevicesEnumerated(
120 int request_id, 132 int request_id,
121 const StreamDeviceInfoArray& device_array); 133 const StreamDeviceInfoArray& device_array);
122 void OnDeviceOpened( 134 void OnDeviceOpened(
123 int request_id, 135 int request_id,
124 const std::string& label, 136 const std::string& label,
125 const StreamDeviceInfo& device_info); 137 const StreamDeviceInfo& device_info);
126 void OnDeviceOpenFailed(int request_id); 138 void OnDeviceOpenFailed(int request_id);
139 void OnDevicesChanged();
127 140
128 // Used for DCHECKs so methods calls won't execute in the wrong thread. 141 // Used for DCHECKs so methods calls won't execute in the wrong thread.
129 base::ThreadChecker thread_checker_; 142 base::ThreadChecker thread_checker_;
130 143
131 int next_ipc_id_; 144 int next_ipc_id_;
132 typedef std::map<std::string, Stream> LabelStreamMap; 145 typedef std::map<std::string, Stream> LabelStreamMap;
133 LabelStreamMap label_stream_map_; 146 LabelStreamMap label_stream_map_;
134 147
135 // List of calls made to the browser process that have not yet completed or 148 // List of calls made to the browser process that have not yet completed or
136 // been canceled. 149 // been canceled.
137 typedef std::list<Request> RequestList; 150 typedef std::list<Request> RequestList;
138 RequestList requests_; 151 RequestList requests_;
139 152
153 std::vector<base::WeakPtr<MediaStreamDispatcherEventHandler>>
154 device_change_subscribers_;
155
140 DISALLOW_COPY_AND_ASSIGN(MediaStreamDispatcher); 156 DISALLOW_COPY_AND_ASSIGN(MediaStreamDispatcher);
141 }; 157 };
142 158
143 } // namespace content 159 } // namespace content
144 160
145 #endif // CONTENT_RENDERER_MEDIA_MEDIA_STREAM_DISPATCHER_H_ 161 #endif // CONTENT_RENDERER_MEDIA_MEDIA_STREAM_DISPATCHER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698