• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2020 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_MIRRORING_APPLICATION_H_
6 #define CAST_STANDALONE_RECEIVER_MIRRORING_APPLICATION_H_
7 
8 #include <memory>
9 #include <string>
10 #include <vector>
11 
12 #include "cast/receiver/application_agent.h"
13 #include "cast/standalone_receiver/streaming_playback_controller.h"
14 #include "platform/api/scoped_wake_lock.h"
15 #include "platform/api/serial_delete_ptr.h"
16 #include "platform/base/error.h"
17 #include "platform/base/ip_address.h"
18 
19 namespace openscreen {
20 
21 class TaskRunner;
22 
23 namespace cast {
24 
25 class MessagePort;
26 class ReceiverSession;
27 
28 // Implements a basic Cast V2 Mirroring Application which, at launch time,
29 // bootstraps a ReceiverSession and StreamingPlaybackController, which set-up
30 // and manage the media data streaming and play it out in an on-screen window.
31 class MirroringApplication final : public ApplicationAgent::Application,
32                                    public StreamingPlaybackController::Client {
33  public:
34   MirroringApplication(TaskRunner* task_runner,
35                        const IPAddress& interface_address,
36                        ApplicationAgent* agent);
37 
38   ~MirroringApplication() final;
39 
40   // ApplicationAgent::Application overrides.
41   const std::vector<std::string>& GetAppIds() const final;
42   bool Launch(const std::string& app_id,
43               const Json::Value& app_params,
44               MessagePort* message_port) final;
45   std::string GetSessionId() final;
46   std::string GetDisplayName() final;
47   std::vector<std::string> GetSupportedNamespaces() final;
48   void Stop() final;
49 
50   // StreamingPlaybackController::Client overrides
51   void OnPlaybackError(StreamingPlaybackController* controller,
52                        Error error) final;
53 
54  private:
55   TaskRunner* const task_runner_;
56   const IPAddress interface_address_;
57   const std::vector<std::string> app_ids_;
58   ApplicationAgent* const agent_;
59 
60   SerialDeletePtr<ScopedWakeLock> wake_lock_;
61   std::unique_ptr<Environment> environment_;
62   std::unique_ptr<StreamingPlaybackController> controller_;
63   std::unique_ptr<ReceiverSession> current_session_;
64 };
65 
66 }  // namespace cast
67 }  // namespace openscreen
68 
69 #endif  // CAST_STANDALONE_RECEIVER_MIRRORING_APPLICATION_H_
70