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

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

Issue 18420011: Support cancellation of request for opening device. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: add IsThisRequest method and some comments Created 7 years, 5 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | content/renderer/media/media_stream_dispatcher.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 <string> 10 #include <string>
(...skipping 30 matching lines...) Expand all
41 // Request a new media stream to be created. 41 // Request a new media stream to be created.
42 // This can be used either by WebKit or a plugin. 42 // This can be used either by WebKit or a plugin.
43 // Note: The event_handler must be valid for as long as the stream exists. 43 // Note: The event_handler must be valid for as long as the stream exists.
44 virtual void GenerateStream( 44 virtual void GenerateStream(
45 int request_id, 45 int request_id,
46 const base::WeakPtr<MediaStreamDispatcherEventHandler>& event_handler, 46 const base::WeakPtr<MediaStreamDispatcherEventHandler>& event_handler,
47 const StreamOptions& components, 47 const StreamOptions& components,
48 const GURL& security_origin); 48 const GURL& security_origin);
49 49
50 // Cancel the request for a new media stream to be created. 50 // Cancel the request for a new media stream to be created.
51 virtual void CancelGenerateStream(int request_id); 51 virtual void CancelGenerateStream(
52 int request_id,
53 const base::WeakPtr<MediaStreamDispatcherEventHandler>& event_handler);
52 54
53 // Stop a started stream. Label is the label provided in OnStreamGenerated. 55 // Stop a started stream. Label is the label provided in OnStreamGenerated.
54 virtual void StopStream(const std::string& label); 56 virtual void StopStream(const std::string& label);
55 57
56 // Request to enumerate devices. 58 // Request to enumerate devices.
57 void EnumerateDevices( 59 void EnumerateDevices(
58 int request_id, 60 int request_id,
59 const base::WeakPtr<MediaStreamDispatcherEventHandler>& event_handler, 61 const base::WeakPtr<MediaStreamDispatcherEventHandler>& event_handler,
60 MediaStreamType type, 62 MediaStreamType type,
61 const GURL& security_origin); 63 const GURL& security_origin);
62 64
63 // Request to stop enumerating devices. 65 // Request to stop enumerating devices.
64 void StopEnumerateDevices( 66 void StopEnumerateDevices(
65 int request_id, 67 int request_id,
66 const base::WeakPtr<MediaStreamDispatcherEventHandler>& event_handler); 68 const base::WeakPtr<MediaStreamDispatcherEventHandler>& event_handler);
67 69
68 // Request to open a device. 70 // Request to open a device.
69 void OpenDevice( 71 void OpenDevice(
70 int request_id, 72 int request_id,
71 const base::WeakPtr<MediaStreamDispatcherEventHandler>& event_handler, 73 const base::WeakPtr<MediaStreamDispatcherEventHandler>& event_handler,
72 const std::string& device_id, 74 const std::string& device_id,
73 MediaStreamType type, 75 MediaStreamType type,
74 const GURL& security_origin); 76 const GURL& security_origin);
75 77
78 // Cancel the request to open a device.
79 virtual void CancelOpenDevice(
80 int request_id,
81 const base::WeakPtr<MediaStreamDispatcherEventHandler>& event_handler);
82
76 // Close a started device. |label| is provided in OnDeviceOpened. 83 // Close a started device. |label| is provided in OnDeviceOpened.
77 void CloseDevice(const std::string& label); 84 void CloseDevice(const std::string& label);
78 85
79 // Check if the label is a valid stream. 86 // Check if the label is a valid stream.
80 virtual bool IsStream(const std::string& label); 87 virtual bool IsStream(const std::string& label);
81 // Get the video session_id given a label. The label identifies a stream. 88 // Get the video session_id given a label. The label identifies a stream.
82 // index is the index in the video_device_array of the stream. 89 // index is the index in the video_device_array of the stream.
83 virtual int video_session_id(const std::string& label, int index); 90 virtual int video_session_id(const std::string& label, int index);
84 // Returns an audio session_id given a label and an index. 91 // Returns an audio session_id given a label and an index.
85 virtual int audio_session_id(const std::string& label, int index); 92 virtual int audio_session_id(const std::string& label, int index);
86 93
87 private: 94 private:
88 FRIEND_TEST_ALL_PREFIXES(MediaStreamDispatcherTest, BasicStream); 95 FRIEND_TEST_ALL_PREFIXES(MediaStreamDispatcherTest, BasicStream);
89 FRIEND_TEST_ALL_PREFIXES(MediaStreamDispatcherTest, BasicStreamForDevice); 96 FRIEND_TEST_ALL_PREFIXES(MediaStreamDispatcherTest, BasicStreamForDevice);
90 FRIEND_TEST_ALL_PREFIXES(MediaStreamDispatcherTest, BasicVideoDevice); 97 FRIEND_TEST_ALL_PREFIXES(MediaStreamDispatcherTest, BasicVideoDevice);
91 FRIEND_TEST_ALL_PREFIXES(MediaStreamDispatcherTest, TestFailure); 98 FRIEND_TEST_ALL_PREFIXES(MediaStreamDispatcherTest, TestFailure);
92 FRIEND_TEST_ALL_PREFIXES(MediaStreamDispatcherTest, CancelGenerateStream); 99 FRIEND_TEST_ALL_PREFIXES(MediaStreamDispatcherTest, CancelGenerateStream);
93 100
94 struct Request; 101 struct Request;
95 102
96 // Private class for keeping track of opened devices and who have 103 // Private class for keeping track of opened devices and who have
97 // opened it. 104 // opened it.
98 struct Stream; 105 struct Stream;
99 106
107 // An enumeration request is identified by pair (request_id, handler).
108 // It allows multiple clients to make requests and each client could have
109 // its own request_id sequence.
100 struct EnumerationRequest { 110 struct EnumerationRequest {
101 EnumerationRequest( 111 EnumerationRequest(
102 const base::WeakPtr<MediaStreamDispatcherEventHandler>& handler, 112 const base::WeakPtr<MediaStreamDispatcherEventHandler>& handler,
103 int request_id); 113 int request_id);
104 ~EnumerationRequest(); 114 ~EnumerationRequest();
115 bool IsThisRequest(
116 int request_id,
117 const base::WeakPtr<MediaStreamDispatcherEventHandler>& handler);
105 118
106 base::WeakPtr<MediaStreamDispatcherEventHandler> handler; 119 base::WeakPtr<MediaStreamDispatcherEventHandler> handler;
107 int request_id; 120 int request_id;
108 }; 121 };
109 122
110 // List of requests made to EnumerateDevices. 123 // List of requests made to EnumerateDevices.
111 typedef std::list<EnumerationRequest> EnumerationRequestList; 124 typedef std::list<EnumerationRequest> EnumerationRequestList;
112 125
113 struct EnumerationState { 126 struct EnumerationState {
114 EnumerationState(); 127 EnumerationState();
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
162 // List of calls made to GenerateStream that have not yet completed. 175 // List of calls made to GenerateStream that have not yet completed.
163 typedef std::list<Request> RequestList; 176 typedef std::list<Request> RequestList;
164 RequestList requests_; 177 RequestList requests_;
165 178
166 DISALLOW_COPY_AND_ASSIGN(MediaStreamDispatcher); 179 DISALLOW_COPY_AND_ASSIGN(MediaStreamDispatcher);
167 }; 180 };
168 181
169 } // namespace content 182 } // namespace content
170 183
171 #endif // CONTENT_RENDERER_MEDIA_MEDIA_STREAM_DISPATCHER_H_ 184 #endif // CONTENT_RENDERER_MEDIA_MEDIA_STREAM_DISPATCHER_H_
OLDNEW
« no previous file with comments | « no previous file | content/renderer/media/media_stream_dispatcher.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698