2 * Copyright (C) 2010 The Android Open Source Project
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
17 #ifndef MPEG2TS_WRITER_H_
19 #define MPEG2TS_WRITER_H_
21 #include <media/stagefright/foundation/ABase.h>
22 #include <media/stagefright/foundation/AHandlerReflector.h>
23 #include <media/stagefright/foundation/ALooper.h>
24 #include <media/stagefright/MediaWriter.h>
30 struct MPEG2TSWriter : public MediaWriter {
31 MPEG2TSWriter(int fd);
32 MPEG2TSWriter(const char *filename);
34 virtual status_t addSource(const sp<MediaSource> &source);
35 virtual status_t start(MetaData *param = NULL);
36 virtual status_t stop();
37 virtual status_t pause();
38 virtual bool reachedEOS();
39 virtual status_t dump(int fd, const Vector<String16>& args);
41 void onMessageReceived(const sp<AMessage> &msg);
44 virtual ~MPEG2TSWriter();
48 kWhatSourceNotify = 'noti'
55 sp<AHandlerReflector<MPEG2TSWriter> > mReflector;
59 Vector<sp<SourceInfo> > mSources;
60 size_t mNumSourcesDone;
62 int64_t mNumTSPacketsWritten;
63 int64_t mNumTSPacketsBeforeMeta;
68 void writeProgramAssociationTable();
69 void writeProgramMap();
70 void writeAccessUnit(int32_t sourceIndex, const sp<ABuffer> &buffer);
72 DISALLOW_EVIL_CONSTRUCTORS(MPEG2TSWriter);
75 } // namespace android
77 #endif // MPEG2TS_WRITER_H_