1 /* 2 * Copyright (C) 2009 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 #include <media/stagefright/MediaSource.h> 18 19 namespace android { 20 21 MediaSource::MediaSource() {} 22 23 MediaSource::~MediaSource() {} 24 25 //////////////////////////////////////////////////////////////////////////////// 26 27 MediaSource::ReadOptions::ReadOptions() { 28 reset(); 29 } 30 31 void MediaSource::ReadOptions::reset() { 32 mOptions = 0; 33 mSeekTimeUs = 0; 34 mLatenessUs = 0; 35 mSkipFrameUntilTimeUs = 0; 36 } 37 38 void MediaSource::ReadOptions::setSeekTo(int64_t time_us, SeekMode mode) { 39 mOptions |= kSeekTo_Option; 40 mSeekTimeUs = time_us; 41 mSeekMode = mode; 42 } 43 44 void MediaSource::ReadOptions::clearSeekTo() { 45 mOptions &= ~kSeekTo_Option; 46 mSeekTimeUs = 0; 47 mSeekMode = SEEK_CLOSEST_SYNC; 48 } 49 50 bool MediaSource::ReadOptions::getSeekTo( 51 int64_t *time_us, SeekMode *mode) const { 52 *time_us = mSeekTimeUs; 53 *mode = mSeekMode; 54 return (mOptions & kSeekTo_Option) != 0; 55 } 56 57 void MediaSource::ReadOptions::clearSkipFrame() { 58 mOptions &= ~kSkipFrame_Option; 59 mSkipFrameUntilTimeUs = 0; 60 } 61 62 void MediaSource::ReadOptions::setSkipFrame(int64_t timeUs) { 63 mOptions |= kSkipFrame_Option; 64 mSkipFrameUntilTimeUs = timeUs; 65 } 66 67 bool MediaSource::ReadOptions::getSkipFrame(int64_t *timeUs) const { 68 *timeUs = mSkipFrameUntilTimeUs; 69 return (mOptions & kSkipFrame_Option) != 0; 70 } 71 72 void MediaSource::ReadOptions::setLateBy(int64_t lateness_us) { 73 mLatenessUs = lateness_us; 74 } 75 76 int64_t MediaSource::ReadOptions::getLateBy() const { 77 return mLatenessUs; 78 } 79 80 } // namespace android 81