OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 EXAMPLES_MEDIA_TEST_MEDIA_TEST_H_ | 5 #ifndef EXAMPLES_MEDIA_TEST_MEDIA_TEST_H_ |
6 #define EXAMPLES_MEDIA_TEST_MEDIA_TEST_H_ | 6 #define EXAMPLES_MEDIA_TEST_MEDIA_TEST_H_ |
7 | 7 |
8 #include "base/macros.h" | 8 #include "base/macros.h" |
9 #include "mojo/public/cpp/application/application_impl.h" | |
10 #include "mojo/services/media/common/cpp/timeline_function.h" | 9 #include "mojo/services/media/common/cpp/timeline_function.h" |
11 #include "mojo/services/media/common/interfaces/rate_control.mojom.h" | 10 #include "mojo/services/media/common/interfaces/rate_control.mojom.h" |
12 #include "mojo/services/media/control/interfaces/media_factory.mojom.h" | 11 #include "mojo/services/media/control/interfaces/media_factory.mojom.h" |
13 #include "mojo/services/media/control/interfaces/media_player.mojom.h" | 12 #include "mojo/services/media/control/interfaces/media_player.mojom.h" |
14 | 13 |
15 namespace mojo { | 14 namespace mojo { |
| 15 |
| 16 class Shell; |
| 17 |
16 namespace media { | 18 namespace media { |
17 namespace examples { | 19 namespace examples { |
18 | 20 |
19 // Model for media test application. | 21 // Model for media test application. |
20 class MediaTest { | 22 class MediaTest { |
21 public: | 23 public: |
22 enum class State { kPaused, kPlaying, kEnded }; | 24 enum class State { kPaused, kPlaying, kEnded }; |
23 | 25 |
24 using UpdateCallback = std::function<void()>; | 26 using UpdateCallback = std::function<void()>; |
25 | 27 |
26 static std::unique_ptr<MediaTest> Create(mojo::ApplicationImpl* app, | 28 static std::unique_ptr<MediaTest> Create(mojo::Shell* shell, |
27 const std::string& input_file_name); | 29 const std::string& input_file_name); |
28 | 30 |
29 ~MediaTest(); | 31 ~MediaTest(); |
30 | 32 |
31 // Registers a callback signalling that the app should update its view. | 33 // Registers a callback signalling that the app should update its view. |
32 void RegisterUpdateCallback(const UpdateCallback& callback) { | 34 void RegisterUpdateCallback(const UpdateCallback& callback) { |
33 update_callback_ = callback; | 35 update_callback_ = callback; |
34 } | 36 } |
35 | 37 |
36 // Starts playback. | 38 // Starts playback. |
(...skipping 11 matching lines...) Expand all Loading... |
48 // Returns the current state of the player. | 50 // Returns the current state of the player. |
49 State state() const { return state_; } | 51 State state() const { return state_; } |
50 | 52 |
51 // Returns the current presentation time in nanoseconds. | 53 // Returns the current presentation time in nanoseconds. |
52 int64_t position_ns() const; | 54 int64_t position_ns() const; |
53 | 55 |
54 // Returns the current media metadata, if there is any. | 56 // Returns the current media metadata, if there is any. |
55 const MediaMetadataPtr& metadata() const; | 57 const MediaMetadataPtr& metadata() const; |
56 | 58 |
57 private: | 59 private: |
58 MediaTest(mojo::ApplicationImpl* app, const std::string& input_file_name); | 60 MediaTest(mojo::Shell* shell, const std::string& input_file_name); |
59 | 61 |
60 // Handles a status update from the player. When called with the default | 62 // Handles a status update from the player. When called with the default |
61 // argument values, initiates status updates. | 63 // argument values, initiates status updates. |
62 void HandleStatusUpdates(uint64_t version = MediaPlayer::kInitialStatus, | 64 void HandleStatusUpdates(uint64_t version = MediaPlayer::kInitialStatus, |
63 MediaPlayerStatusPtr status = nullptr); | 65 MediaPlayerStatusPtr status = nullptr); |
64 | 66 |
65 MediaPlayerPtr media_player_; | 67 MediaPlayerPtr media_player_; |
66 State previous_state_ = State::kPaused; | 68 State previous_state_ = State::kPaused; |
67 State state_ = State::kPaused; | 69 State state_ = State::kPaused; |
68 TimelineFunction timeline_function_; | 70 TimelineFunction timeline_function_; |
69 MediaMetadataPtr metadata_; | 71 MediaMetadataPtr metadata_; |
70 UpdateCallback update_callback_; | 72 UpdateCallback update_callback_; |
71 | 73 |
72 DISALLOW_COPY_AND_ASSIGN(MediaTest); | 74 DISALLOW_COPY_AND_ASSIGN(MediaTest); |
73 }; | 75 }; |
74 | 76 |
75 } // namespace examples | 77 } // namespace examples |
76 } // namespace media | 78 } // namespace media |
77 } // namespace mojo | 79 } // namespace mojo |
78 | 80 |
79 #endif // EXAMPLES_MEDIA_TEST_MEDIA_TEST_H_ | 81 #endif // EXAMPLES_MEDIA_TEST_MEDIA_TEST_H_ |
OLD | NEW |