OLD | NEW |
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_BROWSER_RENDERER_HOST_MEDIA_VIDEO_CAPTURE_HOST_H_ | 5 #ifndef CONTENT_BROWSER_RENDERER_HOST_MEDIA_VIDEO_CAPTURE_HOST_H_ |
6 #define CONTENT_BROWSER_RENDERER_HOST_MEDIA_VIDEO_CAPTURE_HOST_H_ | 6 #define CONTENT_BROWSER_RENDERER_HOST_MEDIA_VIDEO_CAPTURE_HOST_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 | 9 |
10 #include "base/macros.h" | 10 #include "base/macros.h" |
11 #include "base/memory/ref_counted.h" | 11 #include "base/memory/ref_counted.h" |
12 #include "base/memory/weak_ptr.h" | 12 #include "base/memory/weak_ptr.h" |
13 #include "base/sequenced_task_runner_helpers.h" | 13 #include "base/sequenced_task_runner_helpers.h" |
14 #include "content/browser/renderer_host/media/video_capture_controller.h" | 14 #include "content/browser/renderer_host/media/video_capture_controller.h" |
15 #include "content/browser/renderer_host/media/video_capture_controller_event_han
dler.h" | 15 #include "content/browser/renderer_host/media/video_capture_controller_event_han
dler.h" |
16 #include "content/common/content_export.h" | 16 #include "content/common/content_export.h" |
17 #include "content/common/video_capture.mojom.h" | 17 #include "content/common/video_capture.mojom.h" |
18 #include "content/public/browser/browser_associated_interface.h" | |
19 #include "content/public/browser/browser_message_filter.h" | |
20 #include "ipc/ipc_message.h" | |
21 | 18 |
22 namespace content { | 19 namespace content { |
23 class MediaStreamManager; | 20 class MediaStreamManager; |
24 | 21 |
25 // VideoCaptureHost is the IO thread browser process communication endpoint | 22 // VideoCaptureHost is the IO thread browser process communication endpoint |
26 // between a renderer process (which can initiate and receive a video capture | 23 // between a renderer process (which can initiate and receive a video capture |
27 // stream) and a VideoCaptureController in the browser process (which provides | 24 // stream) and a VideoCaptureController in the browser process (which provides |
28 // the stream from a video device). Every remote client is identified via a | 25 // the stream from a video device). Every remote client is identified via a |
29 // unique |device_id|, and is paired with a single VideoCaptureController. | 26 // unique |device_id|, and is paired with a single VideoCaptureController. |
30 // | |
31 // This class is owned by RenderProcessHostImpl, and instantiated on UI thread, | |
32 // but all other operations and method calls happen on IO thread. | |
33 class CONTENT_EXPORT VideoCaptureHost | 27 class CONTENT_EXPORT VideoCaptureHost |
34 : public BrowserMessageFilter, | 28 : public VideoCaptureControllerEventHandler, |
35 public VideoCaptureControllerEventHandler, | |
36 public BrowserAssociatedInterface<mojom::VideoCaptureHost>, | |
37 public mojom::VideoCaptureHost { | 29 public mojom::VideoCaptureHost { |
38 public: | 30 public: |
39 explicit VideoCaptureHost(MediaStreamManager* media_stream_manager); | 31 explicit VideoCaptureHost(MediaStreamManager* media_stream_manager); |
40 | 32 |
41 private: | 33 static void Create(MediaStreamManager* media_stream_manager, |
42 friend class BrowserThread; | 34 mojom::VideoCaptureHostRequest request); |
43 friend class base::DeleteHelper<VideoCaptureHost>; | |
44 friend class VideoCaptureHostTest; | |
45 | 35 |
46 ~VideoCaptureHost() override; | 36 ~VideoCaptureHost() override; |
47 | 37 |
48 // BrowserMessageFilter implementation. | 38 private: |
49 void OnChannelClosing() override; | 39 friend class VideoCaptureHostTest; |
50 void OnDestruct() const override; | |
51 bool OnMessageReceived(const IPC::Message& message) override; | |
52 | 40 |
53 // VideoCaptureControllerEventHandler implementation. | 41 // VideoCaptureControllerEventHandler implementation. |
54 void OnError(VideoCaptureControllerID id) override; | 42 void OnError(VideoCaptureControllerID id) override; |
55 void OnBufferCreated(VideoCaptureControllerID id, | 43 void OnBufferCreated(VideoCaptureControllerID id, |
56 mojo::ScopedSharedBufferHandle handle, | 44 mojo::ScopedSharedBufferHandle handle, |
57 int length, | 45 int length, |
58 int buffer_id) override; | 46 int buffer_id) override; |
59 void OnBufferDestroyed(VideoCaptureControllerID id, | 47 void OnBufferDestroyed(VideoCaptureControllerID id, |
60 int buffer_id) override; | 48 int buffer_id) override; |
61 void OnBufferReady(VideoCaptureControllerID id, | 49 void OnBufferReady(VideoCaptureControllerID id, |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
106 // A map of VideoCaptureControllerID to the VideoCaptureController to which it | 94 // A map of VideoCaptureControllerID to the VideoCaptureController to which it |
107 // is connected. An entry in this map holds a null controller while it is in | 95 // is connected. An entry in this map holds a null controller while it is in |
108 // the process of starting. | 96 // the process of starting. |
109 std::map<VideoCaptureControllerID, base::WeakPtr<VideoCaptureController>> | 97 std::map<VideoCaptureControllerID, base::WeakPtr<VideoCaptureController>> |
110 controllers_; | 98 controllers_; |
111 | 99 |
112 // VideoCaptureObservers map, each one is used and should be valid between | 100 // VideoCaptureObservers map, each one is used and should be valid between |
113 // Start() and the corresponding Stop(). | 101 // Start() and the corresponding Stop(). |
114 std::map<int32_t, mojom::VideoCaptureObserverPtr> device_id_to_observer_map_; | 102 std::map<int32_t, mojom::VideoCaptureObserverPtr> device_id_to_observer_map_; |
115 | 103 |
| 104 base::WeakPtrFactory<VideoCaptureHost> weak_factory_; |
| 105 |
116 DISALLOW_COPY_AND_ASSIGN(VideoCaptureHost); | 106 DISALLOW_COPY_AND_ASSIGN(VideoCaptureHost); |
117 }; | 107 }; |
118 | 108 |
119 } // namespace content | 109 } // namespace content |
120 | 110 |
121 #endif // CONTENT_BROWSER_RENDERER_HOST_MEDIA_VIDEO_CAPTURE_HOST_H_ | 111 #endif // CONTENT_BROWSER_RENDERER_HOST_MEDIA_VIDEO_CAPTURE_HOST_H_ |
OLD | NEW |