blob: e812d2ac5ab8de64e4ff4ae78b21bc172e524b92 [file] [log] [blame]
Wei Jiad399e7e2016-10-26 15:49:11 -07001/*
2 * Copyright 2016 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#ifndef ANDROID_BUFFERING_SETTINGS_H
18#define ANDROID_BUFFERING_SETTINGS_H
19
20#include <binder/Parcelable.h>
21
22namespace android {
23
24enum BufferingMode : int {
25 // Do not support buffering.
26 BUFFERING_MODE_NONE = 0,
27 // Support only time based buffering.
28 BUFFERING_MODE_TIME_ONLY = 1,
29 // Support only size based buffering.
30 BUFFERING_MODE_SIZE_ONLY = 2,
31 // Support both time and size based buffering, time based calculation precedes size based.
32 // Size based calculation will be used only when time information is not available for
33 // the stream.
34 BUFFERING_MODE_TIME_THEN_SIZE = 3,
35 // Number of modes.
36 BUFFERING_MODE_COUNT = 4,
37};
38
39struct BufferingSettings : public Parcelable {
40 static const int kNoWatermark = -1;
41
42 static bool IsValidBufferingMode(int mode);
Wei Jia48fa06d2016-12-20 15:30:49 -080043 static bool IsTimeBasedBufferingMode(int mode);
44 static bool IsSizeBasedBufferingMode(int mode);
Wei Jiad399e7e2016-10-26 15:49:11 -070045
46 BufferingMode mInitialBufferingMode; // for prepare
47 BufferingMode mRebufferingMode; // for playback
48
49 int mInitialWatermarkMs; // time based
50 int mInitialWatermarkKB; // size based
51
52 // When cached data is below this mark, playback will be paused for buffering
53 // till data reach |mRebufferingWatermarkHighMs| or end of stream.
54 int mRebufferingWatermarkLowMs;
55 // When cached data is above this mark, buffering will be paused.
56 int mRebufferingWatermarkHighMs;
57
58 // When cached data is below this mark, playback will be paused for buffering
59 // till data reach |mRebufferingWatermarkHighKB| or end of stream.
60 int mRebufferingWatermarkLowKB;
61 // When cached data is above this mark, buffering will be paused.
62 int mRebufferingWatermarkHighKB;
63
64 BufferingSettings();
65
66 status_t writeToParcel(Parcel* parcel) const override;
67 status_t readFromParcel(const Parcel* parcel) override;
68
Wei Jiadc6f3402017-01-09 15:04:18 -080069 String8 toString() const;
Wei Jiad399e7e2016-10-26 15:49:11 -070070};
71
72} // namespace android
73
74// ---------------------------------------------------------------------------
75
76#endif // ANDROID_BUFFERING_SETTINGS_H