OLD | NEW |
(Empty) | |
| 1 // Copyright 2017 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 MEDIA_REMOTING_STREAM_PROVIDER_H_ |
| 6 #define MEDIA_REMOTING_STREAM_PROVIDER_H_ |
| 7 |
| 8 #include <deque> |
| 9 |
| 10 #include "base/memory/weak_ptr.h" |
| 11 #include "media/base/audio_decoder_config.h" |
| 12 #include "media/base/demuxer_stream.h" |
| 13 #include "media/base/media_resource.h" |
| 14 #include "media/base/video_decoder_config.h" |
| 15 #include "media/remoting/rpc_broker.h" |
| 16 |
| 17 namespace media { |
| 18 namespace remoting { |
| 19 |
| 20 class MediaStream; |
| 21 |
| 22 // The media stream provider for Media Remoting receiver. |
| 23 class StreamProvider final : public MediaResource { |
| 24 public: |
| 25 StreamProvider(RpcBroker* rpc_broker, const base::Closure& error_callback); |
| 26 |
| 27 ~StreamProvider() override; |
| 28 |
| 29 // MediaResource implemenation. |
| 30 std::vector<DemuxerStream*> GetAllStreams() override; |
| 31 void SetStreamStatusChangeCB(const StreamStatusChangeCB& cb) override {} |
| 32 |
| 33 void Initialize(int remote_audio_handle, |
| 34 int remote_video_handle, |
| 35 const base::Closure& callback); |
| 36 void AppendBuffer(DemuxerStream::Type type, |
| 37 scoped_refptr<DecoderBuffer> buffer); |
| 38 void FlushUntil(DemuxerStream::Type type, int count); |
| 39 |
| 40 private: |
| 41 // Called when audio/video stream is initialized. |
| 42 void AudioStreamInitialized(); |
| 43 void VideoStreamInitialized(); |
| 44 |
| 45 // Called when any error occurs. |
| 46 void OnError(const std::string& error); |
| 47 |
| 48 RpcBroker* const rpc_broker_; // Outlives this class. |
| 49 std::unique_ptr<MediaStream> video_stream_; |
| 50 std::unique_ptr<MediaStream> audio_stream_; |
| 51 bool audio_stream_initialized_ = false; |
| 52 bool video_stream_initialized_ = false; |
| 53 |
| 54 // Set when Initialize() is called, and will run only once when both video |
| 55 // and audio streams are initialized or error occurs. |
| 56 base::Closure init_done_callback_; |
| 57 |
| 58 // Run only once when first error occurs; |
| 59 base::Closure error_callback_; |
| 60 |
| 61 base::WeakPtrFactory<StreamProvider> weak_factory_; |
| 62 |
| 63 DISALLOW_COPY_AND_ASSIGN(StreamProvider); |
| 64 }; |
| 65 |
| 66 } // namespace remoting |
| 67 } // namespace media |
| 68 |
| 69 #endif // MEDIA_REMOTING_STREAM_PROVIDER_H_ |
OLD | NEW |