NuPlayerSource.h revision ced1c2f8f6c422063092f5cc5c675ccdebb2dc10
1/* 2 * Copyright (C) 2010 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 NUPLAYER_SOURCE_H_ 18 19#define NUPLAYER_SOURCE_H_ 20 21#include "NuPlayer.h" 22 23#include <media/stagefright/foundation/AMessage.h> 24#include <media/stagefright/MetaData.h> 25#include <utils/Vector.h> 26 27namespace android { 28 29struct ABuffer; 30struct MetaData; 31struct MediaBuffer; 32 33struct NuPlayer::Source : public AHandler { 34 enum Flags { 35 FLAG_CAN_PAUSE = 1, 36 FLAG_CAN_SEEK_BACKWARD = 2, // the "10 sec back button" 37 FLAG_CAN_SEEK_FORWARD = 4, // the "10 sec forward button" 38 FLAG_CAN_SEEK = 8, // the "seek bar" 39 FLAG_DYNAMIC_DURATION = 16, 40 FLAG_SECURE = 32, 41 }; 42 43 enum { 44 kWhatPrepared, 45 kWhatFlagsChanged, 46 kWhatVideoSizeChanged, 47 kWhatBufferingStart, 48 kWhatBufferingEnd, 49 kWhatSubtitleData, 50 kWhatTimedTextData, 51 kWhatQueueDecoderShutdown, 52 }; 53 54 // The provides message is used to notify the player about various 55 // events. 56 Source(const sp<AMessage> ¬ify) 57 : mNotify(notify) { 58 } 59 60 virtual void prepareAsync() = 0; 61 62 virtual void start() = 0; 63 virtual void stop() {} 64 virtual void pause() {} 65 virtual void resume() {} 66 67 // Returns OK iff more data was available, 68 // an error or ERROR_END_OF_STREAM if not. 69 virtual status_t feedMoreTSData() = 0; 70 71 virtual sp<AMessage> getFormat(bool audio); 72 virtual sp<MetaData> getFormatMeta(bool /* audio */) { return NULL; } 73 74 virtual status_t dequeueAccessUnit( 75 bool audio, sp<ABuffer> *accessUnit) = 0; 76 77 virtual status_t getDuration(int64_t * /* durationUs */) { 78 return INVALID_OPERATION; 79 } 80 81 virtual size_t getTrackCount() const { 82 return 0; 83 } 84 85 virtual sp<AMessage> getTrackInfo(size_t /* trackIndex */) const { 86 return NULL; 87 } 88 89 virtual status_t selectTrack(size_t /* trackIndex */, bool /* select */) { 90 return INVALID_OPERATION; 91 } 92 93 virtual status_t seekTo(int64_t /* seekTimeUs */) { 94 return INVALID_OPERATION; 95 } 96 97 virtual status_t setBuffers(bool /* audio */, Vector<MediaBuffer *> &/* buffers */) { 98 return INVALID_OPERATION; 99 } 100 101 virtual bool isRealTime() const { 102 return false; 103 } 104 105protected: 106 virtual ~Source() {} 107 108 virtual void onMessageReceived(const sp<AMessage> &msg); 109 110 sp<AMessage> dupNotify() const { return mNotify->dup(); } 111 112 void notifyFlagsChanged(uint32_t flags); 113 void notifyVideoSizeChanged(const sp<AMessage> &format = NULL); 114 void notifyPrepared(status_t err = OK); 115 116private: 117 sp<AMessage> mNotify; 118 119 DISALLOW_EVIL_CONSTRUCTORS(Source); 120}; 121 122} // namespace android 123 124#endif // NUPLAYER_SOURCE_H_ 125 126