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