Gloria Wang | c6091dd | 2011-05-03 15:59:03 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2011 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 TIMEDTEXT_PLAYER_H_ |
| 18 | |
| 19 | #define TIMEDTEXT_PLAYER_H_ |
| 20 | |
| 21 | #include <media/MediaPlayerInterface.h> |
| 22 | #include <media/stagefright/foundation/ABase.h> |
| 23 | |
| 24 | #include "include/TimedEventQueue.h" |
| 25 | |
| 26 | namespace android { |
| 27 | |
| 28 | class MediaSource; |
| 29 | class AwesomePlayer; |
| 30 | class MediaBuffer; |
| 31 | |
| 32 | class TimedTextPlayer { |
| 33 | public: |
| 34 | TimedTextPlayer(AwesomePlayer *observer, |
| 35 | const wp<MediaPlayerBase> &listener, |
| 36 | TimedEventQueue *queue); |
| 37 | |
| 38 | virtual ~TimedTextPlayer(); |
| 39 | |
| 40 | // index: the index of the text track which will |
| 41 | // be turned on |
| 42 | status_t start(uint8_t index); |
| 43 | |
| 44 | void pause(); |
| 45 | |
| 46 | void resume(); |
| 47 | |
| 48 | status_t seekTo(int64_t time_us); |
| 49 | |
| 50 | void addTextSource(sp<MediaSource> source); |
| 51 | |
| 52 | status_t setTimedTextTrackIndex(int32_t index); |
| 53 | |
| 54 | private: |
| 55 | Mutex mLock; |
| 56 | |
| 57 | sp<MediaSource> mSource; |
| 58 | |
| 59 | bool mSeeking; |
| 60 | int64_t mSeekTimeUs; |
| 61 | |
| 62 | bool mStarted; |
| 63 | |
| 64 | sp<TimedEventQueue::Event> mTextEvent; |
| 65 | bool mTextEventPending; |
| 66 | |
| 67 | TimedEventQueue *mQueue; |
| 68 | |
| 69 | wp<MediaPlayerBase> mListener; |
| 70 | AwesomePlayer *mObserver; |
| 71 | |
| 72 | MediaBuffer *mTextBuffer; |
| 73 | Parcel mData; |
| 74 | |
| 75 | Vector<sp<MediaSource> > mTextTrackVector; |
| 76 | |
| 77 | void reset(); |
| 78 | |
| 79 | void onTextEvent(); |
| 80 | void postTextEvent(int64_t delayUs = -1); |
| 81 | void cancelTextEvent(); |
| 82 | |
| 83 | void notifyListener( |
| 84 | int msg, const void *data = NULL, size_t size = 0); |
| 85 | |
| 86 | DISALLOW_EVIL_CONSTRUCTORS(TimedTextPlayer); |
| 87 | }; |
| 88 | |
| 89 | } // namespace android |
| 90 | |
| 91 | #endif // TIMEDTEXT_PLAYER_H_ |