OLD | NEW |
---|---|
(Empty) | |
1 // Copyright (c) 2011 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_BASE_DATA_SOURCE_H_ | |
6 #define MEDIA_BASE_DATA_SOURCE_H_ | |
7 | |
8 #include "base/callback.h" | |
9 #include "base/memory/ref_counted.h" | |
10 #include "media/base/media_export.h" | |
11 | |
12 namespace media { | |
13 | |
14 class DataSourceHost { | |
Ami GONE FROM CHROMIUM
2011/12/15 18:39:08
No MEDIA_EXPORT on this and the enum below?
acolwell GONE FROM CHROMIUM
2011/12/15 20:57:59
Didn't appear to be needed for my shared build, bu
| |
15 public: | |
16 // Set the total size of the media file. | |
17 virtual void SetTotalBytes(int64 total_bytes) = 0; | |
18 | |
19 // Sets the total number of bytes that are buffered on the client and ready to | |
20 // be played. | |
21 virtual void SetBufferedBytes(int64 buffered_bytes) = 0; | |
22 | |
23 // Sets the flag to indicate current network activity. | |
24 virtual void SetNetworkActivity(bool is_downloading_data) = 0; | |
25 | |
26 protected: | |
27 virtual ~DataSourceHost() {} | |
Ami GONE FROM CHROMIUM
2011/12/15 18:39:08
Comment about why?
acolwell GONE FROM CHROMIUM
2011/12/15 20:57:59
I don't have a good reason why so I'm just going t
| |
28 }; | |
29 | |
30 // Used to specify video preload states. They are "hints" to the browser about | |
31 // how aggressively the browser should load and buffer data. | |
32 // Please see the HTML5 spec for the descriptions of these values: | |
33 // http://www.w3.org/TR/html5/video.html#attr-media-preload | |
34 // | |
35 // Enum values must match the values in WebCore::MediaPlayer::Preload and | |
36 // there will be assertions at compile time if they do not match. | |
37 enum Preload { | |
Ami GONE FROM CHROMIUM
2011/12/15 18:39:08
I wonder whether this wants to live inside DataSou
acolwell GONE FROM CHROMIUM
2011/12/15 20:57:59
Actually after further thought, I don't think Data
Ami GONE FROM CHROMIUM
2011/12/15 22:39:18
Either of the latter 2 would cause a circular depe
| |
38 NONE, | |
39 METADATA, | |
40 AUTO, | |
41 }; | |
42 | |
43 class MEDIA_EXPORT DataSource : public base::RefCountedThreadSafe<DataSource> { | |
44 public: | |
45 typedef base::Callback<void(int64, int64)> StatusCallback; | |
46 typedef base::Callback<void(size_t)> ReadCallback; | |
47 static const size_t kReadError; | |
48 | |
49 virtual void set_host(DataSourceHost* host); | |
50 | |
51 // Reads |size| bytes from |position| into |data|. And when the read is done | |
52 // or failed, |read_callback| is called with the number of bytes read or | |
53 // kReadError in case of error. | |
54 // TODO(hclam): should change |size| to int! It makes the code so messy | |
55 // with size_t and int all over the place.. | |
56 virtual void Read(int64 position, size_t size, | |
57 uint8* data, | |
58 const DataSource::ReadCallback& read_callback) = 0; | |
59 | |
60 // Notifies the DataSource of a change in the current playback rate. | |
61 virtual void SetPlaybackRate(float playback_rate); | |
62 | |
63 // Stops the DataSource. Once this is called all future Read() calls will | |
64 // return an error. | |
65 virtual void Stop(const base::Closure& callback) = 0; | |
66 | |
67 // Returns true and the file size, false if the file size could not be | |
68 // retrieved. | |
69 virtual bool GetSize(int64* size_out) = 0; | |
70 | |
71 // Returns true if we are performing streaming. In this case seeking is | |
72 // not possible. | |
73 virtual bool IsStreaming() = 0; | |
74 | |
75 // Alert the DataSource that the video preload value has been changed. | |
76 virtual void SetPreload(Preload preload) = 0; | |
77 | |
78 // Notify the DataSource of the bitrate of the media. | |
79 // Values of |bitrate| <= 0 are invalid and should be ignored. | |
80 virtual void SetBitrate(int bitrate) = 0; | |
81 | |
82 protected: | |
83 friend class base::RefCountedThreadSafe<DataSource>; | |
Ami GONE FROM CHROMIUM
2011/12/15 18:39:08
This is necessary?
acolwell GONE FROM CHROMIUM
2011/12/15 20:57:59
Yes. This follows the pattern, in other parts of t
| |
84 | |
85 DataSource(); | |
Ami GONE FROM CHROMIUM
2011/12/15 18:39:08
doco why these are protected?
(generally, "protec
acolwell GONE FROM CHROMIUM
2011/12/15 20:57:59
Made this public since a DataSource can't be creat
| |
86 virtual ~DataSource(); | |
87 | |
88 DataSourceHost* host(); | |
89 | |
90 private: | |
91 DataSourceHost* host_; | |
92 | |
93 DISALLOW_COPY_AND_ASSIGN(DataSource); | |
94 }; | |
95 | |
96 } // namespace media | |
97 | |
98 #endif // MEDIA_BASE_DATA_SOURCE_H_ | |
OLD | NEW |