Home | History | Annotate | Download | only in media
      1 /*
      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 
     22 namespace android {
     23 
     24 enum 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 
     39 struct BufferingSettings : public Parcelable {
     40     static const int kNoWatermark = -1;
     41 
     42     static bool IsValidBufferingMode(int mode);
     43     static bool IsTimeBasedBufferingMode(int mode);
     44     static bool IsSizeBasedBufferingMode(int mode);
     45 
     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 
     69     String8 toString() const;
     70 };
     71 
     72 } // namespace android
     73 
     74 // ---------------------------------------------------------------------------
     75 
     76 #endif // ANDROID_BUFFERING_SETTINGS_H
     77