• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 StopStreamDevice(const StreamDeviceInfo& device_info) OVERRIDE;
31   virtual bool IsStream(const std::string& label) OVERRIDE;
32   virtual int video_session_id(const std::string& label, int index) OVERRIDE;
33   virtual int audio_session_id(const std::string& label, int index) OVERRIDE;
34 
request_id()35   int request_id() const { return request_id_; }
request_stream_counter()36   int request_stream_counter() const { return request_stream_counter_; }
IncrementSessionId()37   void IncrementSessionId() { ++session_id_; }
38 
stop_audio_device_counter()39   int stop_audio_device_counter() const { return stop_audio_device_counter_; }
stop_video_device_counter()40   int stop_video_device_counter() const { return stop_video_device_counter_; }
41 
stream_label()42   const std::string& stream_label() const { return stream_label_;}
audio_array()43   StreamDeviceInfoArray audio_array() const { return audio_array_; }
video_array()44   StreamDeviceInfoArray video_array() const { return video_array_; }
45 
46  private:
47   int request_id_;
48   base::WeakPtr<MediaStreamDispatcherEventHandler> event_handler_;
49   int request_stream_counter_;
50   int stop_audio_device_counter_;
51   int stop_video_device_counter_;
52 
53   std::string stream_label_;
54   int session_id_;
55   StreamDeviceInfoArray audio_array_;
56   StreamDeviceInfoArray video_array_;
57 
58   DISALLOW_COPY_AND_ASSIGN(MockMediaStreamDispatcher);
59 };
60 
61 }  // namespace content
62 
63 #endif  // CONTENT_RENDERER_MEDIA_MOCK_MEDIA_STREAM_DISPATCHER_H_
64