Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / content / renderer / media / mock_media_stream_dispatcher.h
blobd77327a04a68293d64ed0b991ecb7c1b2887612b
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_RENDERER_MEDIA_MOCK_MEDIA_STREAM_DISPATCHER_H_
6 #define CONTENT_RENDERER_MEDIA_MOCK_MEDIA_STREAM_DISPATCHER_H_
8 #include <string>
10 #include "content/renderer/media/media_stream_dispatcher.h"
11 #include "url/gurl.h"
13 namespace content {
15 // This class is a mock implementation of MediaStreamDispatcher.
16 class MockMediaStreamDispatcher : public MediaStreamDispatcher {
17 public:
18 MockMediaStreamDispatcher();
19 ~MockMediaStreamDispatcher() override;
21 void GenerateStream(
22 int request_id,
23 const base::WeakPtr<MediaStreamDispatcherEventHandler>& event_handler,
24 const StreamOptions& components,
25 const GURL& url) override;
26 void CancelGenerateStream(
27 int request_id,
28 const base::WeakPtr<MediaStreamDispatcherEventHandler>& event_handler)
29 override;
30 void EnumerateDevices(
31 int request_id,
32 const base::WeakPtr<MediaStreamDispatcherEventHandler>& event_handler,
33 MediaStreamType type,
34 const GURL& security_origin) override;
35 void StopStreamDevice(const StreamDeviceInfo& device_info) override;
36 bool IsStream(const std::string& label) override;
37 int video_session_id(const std::string& label, int index) override;
38 int audio_session_id(const std::string& label, int index) override;
40 int audio_input_request_id() const { return audio_input_request_id_; }
41 int audio_output_request_id() const { return audio_output_request_id_; }
42 int video_request_id() const { return video_request_id_; }
43 int request_stream_counter() const { return request_stream_counter_; }
44 void IncrementSessionId() { ++session_id_; }
46 int stop_audio_device_counter() const { return stop_audio_device_counter_; }
47 int stop_video_device_counter() const { return stop_video_device_counter_; }
49 const std::string& stream_label() const { return stream_label_;}
50 const StreamDeviceInfoArray& audio_input_array() const {
51 return audio_input_array_;
53 const StreamDeviceInfoArray& audio_output_array() const {
54 return audio_output_array_;
56 const StreamDeviceInfoArray& video_array() const { return video_array_; }
58 private:
59 void AddAudioInputDeviceToArray(bool matched_output);
60 void AddAudioOutputDeviceToArray();
61 void AddVideoDeviceToArray(bool facing_user);
63 int audio_input_request_id_;
64 int audio_output_request_id_; // Only used for EnumerateDevices.
65 int video_request_id_; // Only used for EnumerateDevices.
66 base::WeakPtr<MediaStreamDispatcherEventHandler> event_handler_;
67 int request_stream_counter_;
68 int stop_audio_device_counter_;
69 int stop_video_device_counter_;
71 std::string stream_label_;
72 int session_id_;
73 StreamDeviceInfoArray audio_input_array_;
74 StreamDeviceInfoArray audio_output_array_;
75 StreamDeviceInfoArray video_array_;
77 DISALLOW_COPY_AND_ASSIGN(MockMediaStreamDispatcher);
80 } // namespace content
82 #endif // CONTENT_RENDERER_MEDIA_MOCK_MEDIA_STREAM_DISPATCHER_H_