| 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_RENDERER_MEDIA_MOCK_MEDIA_STREAM_DISPATCHER_H_ | 5 #ifndef CONTENT_RENDERER_MEDIA_MOCK_MEDIA_STREAM_DISPATCHER_H_ | 
| 6 #define CONTENT_RENDERER_MEDIA_MOCK_MEDIA_STREAM_DISPATCHER_H_ | 6 #define CONTENT_RENDERER_MEDIA_MOCK_MEDIA_STREAM_DISPATCHER_H_ | 
| 7 | 7 | 
| 8 #include <string> | 8 #include <string> | 
| 9 | 9 | 
| 10 #include "content/renderer/media/media_stream_dispatcher.h" | 10 #include "content/renderer/media/media_stream_dispatcher.h" | 
| 11 #include "url/gurl.h" | 11 #include "url/gurl.h" | 
| 12 | 12 | 
| 13 namespace content { | 13 namespace content { | 
| 14 | 14 | 
| 15 // This class is a mock implementation of MediaStreamDispatcher. | 15 // This class is a mock implementation of MediaStreamDispatcher. | 
| 16 class MockMediaStreamDispatcher : public MediaStreamDispatcher { | 16 class MockMediaStreamDispatcher : public MediaStreamDispatcher { | 
| 17  public: | 17  public: | 
| 18   MockMediaStreamDispatcher(); | 18   MockMediaStreamDispatcher(); | 
| 19   virtual ~MockMediaStreamDispatcher(); | 19   virtual ~MockMediaStreamDispatcher(); | 
| 20 | 20 | 
| 21   virtual void GenerateStream( | 21   virtual void GenerateStream( | 
| 22       int request_id, | 22       int request_id, | 
| 23       const base::WeakPtr<MediaStreamDispatcherEventHandler>& event_handler, | 23       const base::WeakPtr<MediaStreamDispatcherEventHandler>& event_handler, | 
| 24       const StreamOptions& components, | 24       const StreamOptions& components, | 
| 25       const GURL& url) OVERRIDE; | 25       const GURL& url) OVERRIDE; | 
| 26   virtual void CancelGenerateStream( | 26   virtual void CancelGenerateStream( | 
| 27       int request_id, | 27       int request_id, | 
| 28       const base::WeakPtr<MediaStreamDispatcherEventHandler>& | 28       const base::WeakPtr<MediaStreamDispatcherEventHandler>& | 
| 29           event_handler) OVERRIDE; | 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) OVERRIDE; |  | 
| 35   virtual void StopStreamDevice(const StreamDeviceInfo& device_info) OVERRIDE; | 30   virtual void StopStreamDevice(const StreamDeviceInfo& device_info) OVERRIDE; | 
| 36   virtual bool IsStream(const std::string& label) OVERRIDE; | 31   virtual bool IsStream(const std::string& label) OVERRIDE; | 
| 37   virtual int video_session_id(const std::string& label, int index) OVERRIDE; | 32   virtual int video_session_id(const std::string& label, int index) OVERRIDE; | 
| 38   virtual int audio_session_id(const std::string& label, int index) OVERRIDE; | 33   virtual int audio_session_id(const std::string& label, int index) OVERRIDE; | 
| 39 | 34 | 
| 40   int audio_request_id() const { return audio_request_id_; } | 35   int request_id() const { return request_id_; } | 
| 41   int video_request_id() const { return video_request_id_; } |  | 
| 42   int request_stream_counter() const { return request_stream_counter_; } | 36   int request_stream_counter() const { return request_stream_counter_; } | 
| 43   void IncrementSessionId() { ++session_id_; } | 37   void IncrementSessionId() { ++session_id_; } | 
| 44 | 38 | 
| 45   int stop_audio_device_counter() const { return stop_audio_device_counter_; } | 39   int stop_audio_device_counter() const { return stop_audio_device_counter_; } | 
| 46   int stop_video_device_counter() const { return stop_video_device_counter_; } | 40   int stop_video_device_counter() const { return stop_video_device_counter_; } | 
| 47 | 41 | 
| 48   const std::string& stream_label() const { return stream_label_;} | 42   const std::string& stream_label() const { return stream_label_;} | 
| 49   StreamDeviceInfoArray audio_array() const { return audio_array_; } | 43   StreamDeviceInfoArray audio_array() const { return audio_array_; } | 
| 50   StreamDeviceInfoArray video_array() const { return video_array_; } | 44   StreamDeviceInfoArray video_array() const { return video_array_; } | 
| 51 | 45 | 
| 52  private: | 46  private: | 
| 53   void AddAudioDeviceToArray(); | 47   int request_id_; | 
| 54   void AddVideoDeviceToArray(); |  | 
| 55 |  | 
| 56   int audio_request_id_; |  | 
| 57   int video_request_id_;  // Only used for EnumerateDevices. |  | 
| 58   base::WeakPtr<MediaStreamDispatcherEventHandler> event_handler_; | 48   base::WeakPtr<MediaStreamDispatcherEventHandler> event_handler_; | 
| 59   int request_stream_counter_; | 49   int request_stream_counter_; | 
| 60   int stop_audio_device_counter_; | 50   int stop_audio_device_counter_; | 
| 61   int stop_video_device_counter_; | 51   int stop_video_device_counter_; | 
| 62 | 52 | 
| 63   std::string stream_label_; | 53   std::string stream_label_; | 
| 64   int session_id_; | 54   int session_id_; | 
| 65   StreamDeviceInfoArray audio_array_; | 55   StreamDeviceInfoArray audio_array_; | 
| 66   StreamDeviceInfoArray video_array_; | 56   StreamDeviceInfoArray video_array_; | 
| 67 | 57 | 
| 68   DISALLOW_COPY_AND_ASSIGN(MockMediaStreamDispatcher); | 58   DISALLOW_COPY_AND_ASSIGN(MockMediaStreamDispatcher); | 
| 69 }; | 59 }; | 
| 70 | 60 | 
| 71 }  // namespace content | 61 }  // namespace content | 
| 72 | 62 | 
| 73 #endif  // CONTENT_RENDERER_MEDIA_MOCK_MEDIA_STREAM_DISPATCHER_H_ | 63 #endif  // CONTENT_RENDERER_MEDIA_MOCK_MEDIA_STREAM_DISPATCHER_H_ | 
| OLD | NEW | 
|---|