Andreas Huber | 07bf09d | 2010-01-25 14:27:12 -0800 | [diff] [blame] | 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 AMR_WRITER_H_ |
| 18 | |
| 19 | #define AMR_WRITER_H_ |
| 20 | |
| 21 | #include <stdio.h> |
| 22 | |
Andreas Huber | 996dddf | 2010-01-25 15:30:31 -0800 | [diff] [blame] | 23 | #include <media/stagefright/MediaWriter.h> |
Andreas Huber | 07bf09d | 2010-01-25 14:27:12 -0800 | [diff] [blame] | 24 | #include <utils/threads.h> |
| 25 | |
| 26 | namespace android { |
| 27 | |
| 28 | struct MediaSource; |
James Dong | 6feaa46 | 2010-06-20 08:20:54 -0700 | [diff] [blame] | 29 | struct MetaData; |
Andreas Huber | 07bf09d | 2010-01-25 14:27:12 -0800 | [diff] [blame] | 30 | |
Andreas Huber | 996dddf | 2010-01-25 15:30:31 -0800 | [diff] [blame] | 31 | struct AMRWriter : public MediaWriter { |
Andreas Huber | 07bf09d | 2010-01-25 14:27:12 -0800 | [diff] [blame] | 32 | AMRWriter(const char *filename); |
| 33 | AMRWriter(int fd); |
| 34 | |
| 35 | status_t initCheck() const; |
| 36 | |
Andreas Huber | 996dddf | 2010-01-25 15:30:31 -0800 | [diff] [blame] | 37 | virtual status_t addSource(const sp<MediaSource> &source); |
| 38 | virtual bool reachedEOS(); |
James Dong | 6feaa46 | 2010-06-20 08:20:54 -0700 | [diff] [blame] | 39 | virtual status_t start(MetaData *params = NULL); |
James Dong | c2240b1 | 2012-02-02 15:07:52 -0800 | [diff] [blame] | 40 | virtual status_t stop() { return reset(); } |
James Dong | d036662 | 2010-08-18 19:10:39 -0700 | [diff] [blame] | 41 | virtual status_t pause(); |
Andreas Huber | 07bf09d | 2010-01-25 14:27:12 -0800 | [diff] [blame] | 42 | |
| 43 | protected: |
| 44 | virtual ~AMRWriter(); |
| 45 | |
| 46 | private: |
James Dong | b1262a8 | 2010-11-16 14:04:54 -0800 | [diff] [blame] | 47 | int mFd; |
Andreas Huber | 07bf09d | 2010-01-25 14:27:12 -0800 | [diff] [blame] | 48 | status_t mInitCheck; |
| 49 | sp<MediaSource> mSource; |
| 50 | bool mStarted; |
James Dong | 08c7473 | 2010-06-10 12:28:15 -0700 | [diff] [blame] | 51 | volatile bool mPaused; |
| 52 | volatile bool mResumed; |
Andreas Huber | 07bf09d | 2010-01-25 14:27:12 -0800 | [diff] [blame] | 53 | volatile bool mDone; |
Andreas Huber | e2018ca | 2010-03-23 14:33:02 -0700 | [diff] [blame] | 54 | volatile bool mReachedEOS; |
Andreas Huber | 07bf09d | 2010-01-25 14:27:12 -0800 | [diff] [blame] | 55 | pthread_t mThread; |
James Dong | 1824486 | 2010-05-11 14:57:02 -0700 | [diff] [blame] | 56 | int64_t mEstimatedSizeBytes; |
| 57 | int64_t mEstimatedDurationUs; |
Andreas Huber | 07bf09d | 2010-01-25 14:27:12 -0800 | [diff] [blame] | 58 | |
| 59 | static void *ThreadWrapper(void *); |
James Dong | d036662 | 2010-08-18 19:10:39 -0700 | [diff] [blame] | 60 | status_t threadFunc(); |
James Dong | 1824486 | 2010-05-11 14:57:02 -0700 | [diff] [blame] | 61 | bool exceedsFileSizeLimit(); |
| 62 | bool exceedsFileDurationLimit(); |
James Dong | c2240b1 | 2012-02-02 15:07:52 -0800 | [diff] [blame] | 63 | status_t reset(); |
Andreas Huber | 07bf09d | 2010-01-25 14:27:12 -0800 | [diff] [blame] | 64 | |
| 65 | AMRWriter(const AMRWriter &); |
| 66 | AMRWriter &operator=(const AMRWriter &); |
| 67 | }; |
| 68 | |
| 69 | } // namespace android |
| 70 | |
| 71 | #endif // AMR_WRITER_H_ |