• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 
23 #include <media/stagefright/MediaWriter.h>
24 #include <utils/threads.h>
25 
26 namespace android {
27 
28 struct AMRWriter : public MediaWriter {
29     AMRWriter(int fd);
30 
31     status_t initCheck() const;
32 
33     virtual status_t addSource(const sp<MediaSource> &source);
34     virtual bool reachedEOS();
35     virtual status_t start(MetaData *params = NULL);
stopAMRWriter36     virtual status_t stop() { return reset(); }
37     virtual status_t pause();
38 
39 protected:
40     virtual ~AMRWriter();
41 
42 private:
43     int   mFd;
44     status_t mInitCheck;
45     sp<MediaSource> mSource;
46     bool mStarted;
47     volatile bool mPaused;
48     volatile bool mResumed;
49     volatile bool mDone;
50     volatile bool mReachedEOS;
51     pthread_t mThread;
52     int64_t mEstimatedSizeBytes;
53     int64_t mEstimatedDurationUs;
54 
55     static void *ThreadWrapper(void *);
56     status_t threadFunc();
57     bool exceedsFileSizeLimit();
58     bool exceedsFileDurationLimit();
59     status_t reset();
60 
61     AMRWriter(const AMRWriter &);
62     AMRWriter &operator=(const AMRWriter &);
63 };
64 
65 }  // namespace android
66 
67 #endif  // AMR_WRITER_H_
68