Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(391)

Side by Side Diff: chrome/renderer/media/cast_session_delegate.h

Issue 883293005: Cast: Basic cast_receiver API for chrome. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: merged Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 CHROME_RENDERER_MEDIA_CAST_SESSION_DELEGATE_H_ 5 #ifndef CHROME_RENDERER_MEDIA_CAST_SESSION_DELEGATE_H_
6 #define CHROME_RENDERER_MEDIA_CAST_SESSION_DELEGATE_H_ 6 #define CHROME_RENDERER_MEDIA_CAST_SESSION_DELEGATE_H_
7 7
8 #include <map> 8 #include <map>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 21 matching lines...) Expand all
32 class CastEnvironment; 32 class CastEnvironment;
33 class FrameInput; 33 class FrameInput;
34 class RawEventSubscriberBundle; 34 class RawEventSubscriberBundle;
35 35
36 namespace transport { 36 namespace transport {
37 class CastTransportSender; 37 class CastTransportSender;
38 } // namespace transport 38 } // namespace transport
39 } // namespace cast 39 } // namespace cast
40 } // namespace media 40 } // namespace media
41 41
42 // Breaks out functionality that is common between.
miu 2015/02/11 02:52:50 Please finish this sentence.
hubbe 2015/02/11 22:38:17 Done.
43 class CastSessionDelegateBase {
44 public:
45 CastSessionDelegateBase();
46 virtual ~CastSessionDelegateBase();
47
48 // This will start the session by configuring and creating the Cast transport
49 // and the Cast sender.
50 // Must be called before initialization of audio or video.
51 void StartUDP(const net::IPEndPoint& local_endpoint,
52 const net::IPEndPoint& remote_endpoint,
53 scoped_ptr<base::DictionaryValue> options);
54
55 protected:
56 void StatusNotificationCB(
57 media::cast::CastTransportStatus status);
58 virtual void LogRawEvents(
59 const std::vector<media::cast::PacketEvent>& packet_events,
60 const std::vector<media::cast::FrameEvent>& frame_events) = 0;
61
62 base::ThreadChecker thread_checker_;
63 scoped_refptr<media::cast::CastEnvironment> cast_environment_;
64 scoped_ptr<media::cast::CastTransportSender> cast_transport_;
65
66 // Proxy to the IO message loop.
67 scoped_refptr<base::MessageLoopProxy> io_message_loop_proxy_;
miu 2015/02/11 02:52:50 nit: const scoped_refptr<...>
hubbe 2015/02/11 22:38:17 Done.
68 base::WeakPtrFactory<CastSessionDelegateBase> weak_factory_;
69
70 DISALLOW_COPY_AND_ASSIGN(CastSessionDelegateBase);
71 };
72
42 // This class hosts CastSender and connects it to audio/video frame input 73 // This class hosts CastSender and connects it to audio/video frame input
43 // and network socket. 74 // and network socket.
44 // This class is created on the render thread and destroyed on the IO 75 // This class is created on the render thread and destroyed on the IO
45 // thread. All methods are accessible only on the IO thread. 76 // thread. All methods are accessible only on the IO thread.
46 class CastSessionDelegate { 77 class CastSessionDelegate : public CastSessionDelegateBase {
47 public: 78 public:
48 typedef base::Callback<void(const scoped_refptr< 79 typedef base::Callback<void(const scoped_refptr<
49 media::cast::AudioFrameInput>&)> AudioFrameInputAvailableCallback; 80 media::cast::AudioFrameInput>&)> AudioFrameInputAvailableCallback;
50 typedef base::Callback<void(const scoped_refptr< 81 typedef base::Callback<void(const scoped_refptr<
51 media::cast::VideoFrameInput>&)> VideoFrameInputAvailableCallback; 82 media::cast::VideoFrameInput>&)> VideoFrameInputAvailableCallback;
52 typedef base::Callback<void(scoped_ptr<base::BinaryValue>)> EventLogsCallback; 83 typedef base::Callback<void(scoped_ptr<base::BinaryValue>)> EventLogsCallback;
53 typedef base::Callback<void(scoped_ptr<base::DictionaryValue>)> StatsCallback; 84 typedef base::Callback<void(scoped_ptr<base::DictionaryValue>)> StatsCallback;
54 typedef base::Callback<void(const std::string&)> ErrorCallback; 85 typedef base::Callback<void(const std::string&)> ErrorCallback;
55 86
56 CastSessionDelegate(); 87 CastSessionDelegate();
57 virtual ~CastSessionDelegate(); 88 ~CastSessionDelegate() override;
58 89
59 // This will start the session by configuring and creating the Cast transport 90 void StartUDP(const net::IPEndPoint& local_endpoint,
60 // and the Cast sender. 91 const net::IPEndPoint& remote_endpoint,
61 // Must be called before initialization of audio or video.
62 void StartUDP(const net::IPEndPoint& remote_endpoint,
63 scoped_ptr<base::DictionaryValue> options); 92 scoped_ptr<base::DictionaryValue> options);
64 93
65 // After calling StartAudio() or StartVideo() encoding of that media will 94 // After calling StartAudio() or StartVideo() encoding of that media will
66 // begin as soon as data is delivered to its sink, if the second method is 95 // begin as soon as data is delivered to its sink, if the second method is
67 // called the first media will be restarted. It is strongly recommended not to 96 // called the first media will be restarted. It is strongly recommended not to
68 // deliver any data between calling the two methods. 97 // deliver any data between calling the two methods.
69 // It's OK to call only one of the two methods. 98 // It's OK to call only one of the two methods.
70 // StartUDP must be called before these methods. 99 // StartUDP must be called before these methods.
71 void StartAudio(const media::cast::AudioSenderConfig& config, 100 void StartAudio(const media::cast::AudioSenderConfig& config,
72 const AudioFrameInputAvailableCallback& callback, 101 const AudioFrameInputAvailableCallback& callback,
(...skipping 19 matching lines...) Expand all
92 // audio/video frames. If this is called with an error that has halted the 121 // audio/video frames. If this is called with an error that has halted the
93 // session, the |error_callback| provided to StartXXX() will be run. This 122 // session, the |error_callback| provided to StartXXX() will be run. This
94 // method may be called multiple times during the session to indicate codec 123 // method may be called multiple times during the session to indicate codec
95 // re-initializations are taking place and/or runtime errors have occurred. 124 // re-initializations are taking place and/or runtime errors have occurred.
96 void OnOperationalStatusChange( 125 void OnOperationalStatusChange(
97 bool is_for_audio, 126 bool is_for_audio,
98 const ErrorCallback& error_callback, 127 const ErrorCallback& error_callback,
99 media::cast::OperationalStatus result); 128 media::cast::OperationalStatus result);
100 129
101 private: 130 private:
102 void StatusNotificationCB(
103 media::cast::CastTransportStatus status);
104
105 // Adds logs collected from transport on browser side. 131 // Adds logs collected from transport on browser side.
106 void LogRawEvents(const std::vector<media::cast::PacketEvent>& packet_events, 132 void LogRawEvents(const std::vector<media::cast::PacketEvent>& packet_events,
107 const std::vector<media::cast::FrameEvent>& frame_events); 133 const std::vector<media::cast::FrameEvent>& frame_events)
134 override;
108 135
109 base::ThreadChecker thread_checker_;
110 scoped_refptr<media::cast::CastEnvironment> cast_environment_;
111 scoped_ptr<media::cast::CastSender> cast_sender_; 136 scoped_ptr<media::cast::CastSender> cast_sender_;
112 scoped_ptr<media::cast::CastTransportSender> cast_transport_;
113 137
114 AudioFrameInputAvailableCallback audio_frame_input_available_callback_; 138 AudioFrameInputAvailableCallback audio_frame_input_available_callback_;
115 VideoFrameInputAvailableCallback video_frame_input_available_callback_; 139 VideoFrameInputAvailableCallback video_frame_input_available_callback_;
116 140
117 scoped_ptr<media::cast::RawEventSubscriberBundle> event_subscribers_; 141 scoped_ptr<media::cast::RawEventSubscriberBundle> event_subscribers_;
118 142
119 // Proxy to the IO message loop.
120 scoped_refptr<base::MessageLoopProxy> io_message_loop_proxy_;
121 base::WeakPtrFactory<CastSessionDelegate> weak_factory_; 143 base::WeakPtrFactory<CastSessionDelegate> weak_factory_;
122 144
123 DISALLOW_COPY_AND_ASSIGN(CastSessionDelegate); 145 DISALLOW_COPY_AND_ASSIGN(CastSessionDelegate);
124 }; 146 };
125 147
126 #endif // CHROME_RENDERER_MEDIA_CAST_SESSION_DELEGATE_H_ 148 #endif // CHROME_RENDERER_MEDIA_CAST_SESSION_DELEGATE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698