Save errno for logging before potentially overwriting it.
[chromium-blink-merge.git] / content / browser / renderer_host / media / media_stream_dispatcher_host.h
blob4b94496a898c0f7ff9fecb71931314d3dc023418
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
3 // found in the LICENSE file.
5 #ifndef CONTENT_BROWSER_RENDERER_HOST_MEDIA_MEDIA_STREAM_DISPATCHER_HOST_H_
6 #define CONTENT_BROWSER_RENDERER_HOST_MEDIA_MEDIA_STREAM_DISPATCHER_HOST_H_
8 #include <map>
9 #include <string>
10 #include <utility>
12 #include "content/browser/renderer_host/media/media_stream_manager.h"
13 #include "content/browser/renderer_host/media/media_stream_requester.h"
14 #include "content/common/content_export.h"
15 #include "content/common/media/media_stream_options.h"
16 #include "content/public/browser/browser_message_filter.h"
18 namespace content {
19 class MediaStreamManager;
21 // MediaStreamDispatcherHost is a delegate for Media Stream API messages used by
22 // MediaStreamImpl. It's the complement of MediaStreamDispatcher
23 // (owned by RenderView).
24 class CONTENT_EXPORT MediaStreamDispatcherHost : public BrowserMessageFilter,
25 public MediaStreamRequester {
26 public:
27 MediaStreamDispatcherHost(int render_process_id,
28 MediaStreamManager* media_stream_manager);
30 // MediaStreamRequester implementation.
31 virtual void StreamGenerated(
32 const std::string& label,
33 const StreamDeviceInfoArray& audio_devices,
34 const StreamDeviceInfoArray& video_devices) OVERRIDE;
35 virtual void StreamGenerationFailed(const std::string& label) OVERRIDE;
36 virtual void DevicesEnumerated(const std::string& label,
37 const StreamDeviceInfoArray& devices) OVERRIDE;
38 virtual void DeviceOpened(const std::string& label,
39 const StreamDeviceInfo& video_device) OVERRIDE;
41 // BrowserMessageFilter implementation.
42 virtual bool OnMessageReceived(const IPC::Message& message,
43 bool* message_was_ok) OVERRIDE;
44 virtual void OnChannelClosing() OVERRIDE;
46 protected:
47 virtual ~MediaStreamDispatcherHost();
49 private:
50 friend class MockMediaStreamDispatcherHost;
52 void OnGenerateStream(int render_view_id,
53 int page_request_id,
54 const StreamOptions& components,
55 const GURL& security_origin);
56 void OnCancelGenerateStream(int render_view_id,
57 int page_request_id);
58 void OnStopGeneratedStream(int render_view_id, const std::string& label);
60 void OnEnumerateDevices(int render_view_id,
61 int page_request_id,
62 MediaStreamType type,
63 const GURL& security_origin);
65 void OnOpenDevice(int render_view_id,
66 int page_request_id,
67 const std::string& device_id,
68 MediaStreamType type,
69 const GURL& security_origin);
71 int render_process_id_;
72 MediaStreamManager* media_stream_manager_;
74 struct StreamRequest;
75 typedef std::map<std::string, StreamRequest> StreamMap;
76 // Streams generated for this host.
77 StreamMap streams_;
79 DISALLOW_COPY_AND_ASSIGN(MediaStreamDispatcherHost);
82 } // namespace content
84 #endif // CONTENT_BROWSER_RENDERER_HOST_MEDIA_MEDIA_STREAM_DISPATCHER_HOST_H_