1 // Copyright 2019 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 CAST_STANDALONE_RECEIVER_STREAMING_PLAYBACK_CONTROLLER_H_ 6 #define CAST_STANDALONE_RECEIVER_STREAMING_PLAYBACK_CONTROLLER_H_ 7 8 #include <memory> 9 10 #include "cast/streaming/receiver_session.h" 11 #include "platform/impl/task_runner.h" 12 13 #if defined(CAST_STANDALONE_RECEIVER_HAVE_EXTERNAL_LIBS) 14 #include "cast/standalone_receiver/sdl_audio_player.h" 15 #include "cast/standalone_receiver/sdl_glue.h" 16 #include "cast/standalone_receiver/sdl_video_player.h" 17 #else 18 #include "cast/standalone_receiver/dummy_player.h" 19 #endif // defined(CAST_STANDALONE_RECEIVER_HAVE_EXTERNAL_LIBS) 20 21 namespace openscreen { 22 namespace cast { 23 24 class StreamingPlaybackController final : public ReceiverSession::Client { 25 public: 26 class Client { 27 public: 28 virtual void OnPlaybackError(StreamingPlaybackController* controller, 29 Error error) = 0; 30 }; 31 32 StreamingPlaybackController(TaskRunner* task_runner, 33 StreamingPlaybackController::Client* client); 34 35 // ReceiverSession::Client overrides. 36 void OnMirroringNegotiated( 37 const ReceiverSession* session, 38 ReceiverSession::ConfiguredReceivers receivers) override; 39 40 void OnReceiversDestroying(const ReceiverSession* session, 41 ReceiversDestroyingReason reason) override; 42 43 void OnError(const ReceiverSession* session, Error error) override; 44 45 private: 46 TaskRunner* const task_runner_; 47 StreamingPlaybackController::Client* client_; 48 49 #if defined(CAST_STANDALONE_RECEIVER_HAVE_EXTERNAL_LIBS) 50 // NOTE: member ordering is important, since the sub systems must be 51 // first-constructed, last-destroyed. Make sure any new SDL related 52 // members are added below the sub systems. 53 const ScopedSDLSubSystem<SDL_INIT_AUDIO> sdl_audio_sub_system_; 54 const ScopedSDLSubSystem<SDL_INIT_VIDEO> sdl_video_sub_system_; 55 const SDLEventLoopProcessor sdl_event_loop_; 56 57 SDLWindowUniquePtr window_; 58 SDLRendererUniquePtr renderer_; 59 std::unique_ptr<SDLAudioPlayer> audio_player_; 60 std::unique_ptr<SDLVideoPlayer> video_player_; 61 #else 62 std::unique_ptr<DummyPlayer> audio_player_; 63 std::unique_ptr<DummyPlayer> video_player_; 64 #endif // defined(CAST_STANDALONE_RECEIVER_HAVE_EXTERNAL_LIBS) 65 }; 66 67 } // namespace cast 68 } // namespace openscreen 69 70 #endif // CAST_STANDALONE_RECEIVER_STREAMING_PLAYBACK_CONTROLLER_H_ 71