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" | 9 #include "mojo/public/cpp/application/application_impl.h" |
10 #include "mojo/services/media/common/cpp/linear_transform.h" | 10 #include "mojo/services/media/common/cpp/linear_transform.h" |
11 #include "mojo/services/media/common/interfaces/rate_control.mojom.h" | 11 #include "mojo/services/media/common/interfaces/rate_control.mojom.h" |
12 #include "mojo/services/media/control/interfaces/media_factory.mojom.h" | 12 #include "mojo/services/media/control/interfaces/media_factory.mojom.h" |
13 #include "mojo/services/media/control/interfaces/media_player.mojom.h" | 13 #include "mojo/services/media/control/interfaces/media_player.mojom.h" |
14 | 14 |
15 namespace mojo { | 15 namespace mojo { |
16 namespace media { | 16 namespace media { |
17 namespace examples { | 17 namespace examples { |
18 | 18 |
19 // Model for media test application. | 19 // Model for media test application. |
20 class MediaTest { | 20 class MediaTest { |
21 public: | 21 public: |
22 using UpdateCallback = std::function<void()>; | 22 using UpdateCallback = std::function<void()>; |
23 | 23 |
24 static std::unique_ptr<MediaTest> Create( | 24 static std::unique_ptr<MediaTest> Create(mojo::ApplicationImpl* app, |
25 mojo::ApplicationImpl* app, | 25 const std::string& input_file_name); |
26 const std::string& input_file_name); | |
27 | 26 |
28 ~MediaTest(); | 27 ~MediaTest(); |
29 | 28 |
30 // Registers a callback signalling that the app should update its view. | 29 // Registers a callback signalling that the app should update its view. |
31 void RegisterUpdateCallback(const UpdateCallback& callback); | 30 void RegisterUpdateCallback(const UpdateCallback& callback); |
32 | 31 |
33 // Starts playback. | 32 // Starts playback. |
34 void Play(); | 33 void Play(); |
35 | 34 |
36 // Pauses playback. | 35 // Pauses playback. |
37 void Pause(); | 36 void Pause(); |
38 | 37 |
39 // Seeks to the position indicated in nanoseconds from the start of the media. | 38 // Seeks to the position indicated in nanoseconds from the start of the media. |
40 void Seek(int64_t position_ns); | 39 void Seek(int64_t position_ns); |
41 | 40 |
42 // Returns the current state of the player. | 41 // Returns the current state of the player. |
43 MediaState state() const; | 42 MediaState state() const; |
44 | 43 |
45 // Returns the current presentation time in nanoseconds. | 44 // Returns the current presentation time in nanoseconds. |
46 int64_t position_ns() const; | 45 int64_t position_ns() const; |
47 | 46 |
48 // Returns the current media metadata, if there is any. | 47 // Returns the current media metadata, if there is any. |
49 const MediaMetadataPtr& metadata() const; | 48 const MediaMetadataPtr& metadata() const; |
50 | 49 |
51 private: | 50 private: |
52 MediaTest(mojo::ApplicationImpl* app, const std::string& input_file_name); | 51 MediaTest(mojo::ApplicationImpl* app, const std::string& input_file_name); |
53 | 52 |
54 // Handles a status update from the player. When called with the default | 53 // Handles a status update from the player. When called with the default |
55 // argument values, initiates status updates. | 54 // argument values, initiates status updates. |
56 void HandleStatusUpdates( | 55 void HandleStatusUpdates(uint64_t version = MediaPlayer::kInitialStatus, |
57 uint64_t version = MediaPlayer::kInitialStatus, | 56 MediaPlayerStatusPtr status = nullptr); |
58 MediaPlayerStatusPtr status = nullptr); | |
59 | 57 |
60 MediaPlayerPtr media_player_; | 58 MediaPlayerPtr media_player_; |
61 MediaState state_; | 59 MediaState state_; |
62 LinearTransform transform_ = LinearTransform(0, 0, 1, 0); | 60 LinearTransform transform_ = LinearTransform(0, 0, 1, 0); |
63 MediaMetadataPtr metadata_; | 61 MediaMetadataPtr metadata_; |
64 UpdateCallback update_callback_; | 62 UpdateCallback update_callback_; |
65 | 63 |
66 DISALLOW_COPY_AND_ASSIGN(MediaTest); | 64 DISALLOW_COPY_AND_ASSIGN(MediaTest); |
67 }; | 65 }; |
68 | 66 |
69 } // namespace examples | 67 } // namespace examples |
70 } // namespace media | 68 } // namespace media |
71 } // namespace mojo | 69 } // namespace mojo |
72 | 70 |
73 #endif // EXAMPLES_MEDIA_TEST_MEDIA_TEST_H_ | 71 #endif // EXAMPLES_MEDIA_TEST_MEDIA_TEST_H_ |
OLD | NEW |