diff options
author | Wonsik Kim <wonsik@google.com> | 2015-04-13 10:59:06 +0900 |
---|---|---|
committer | Wonsik Kim <wonsik@google.com> | 2015-05-20 21:58:54 +0900 |
commit | 540006666b4191cd78391378f1c66c21bcf0c4cd (patch) | |
tree | 78f7893bb1716c7f6cfffab681f75394fcc173b7 /media/libstagefright/mpeg2ts/ATSParser.h | |
parent | 6267b539d0d1ee7118aafd976d75cb8db397bc24 (diff) | |
download | frameworks_av-540006666b4191cd78391378f1c66c21bcf0c4cd.zip frameworks_av-540006666b4191cd78391378f1c66c21bcf0c4cd.tar.gz frameworks_av-540006666b4191cd78391378f1c66c21bcf0c4cd.tar.bz2 |
Implement seek for MPEG2TSExtractor
TODO: Use bandwidth-based estimation to seek forward long period.
Bug: 20126845
Change-Id: I5e2f90784a9ce0dce348715dfcfc4f83ee196170
Diffstat (limited to 'media/libstagefright/mpeg2ts/ATSParser.h')
-rw-r--r-- | media/libstagefright/mpeg2ts/ATSParser.h | 56 |
1 files changed, 50 insertions, 6 deletions
diff --git a/media/libstagefright/mpeg2ts/ATSParser.h b/media/libstagefright/mpeg2ts/ATSParser.h index 4def333..430a8d5 100644 --- a/media/libstagefright/mpeg2ts/ATSParser.h +++ b/media/libstagefright/mpeg2ts/ATSParser.h @@ -22,6 +22,7 @@ #include <media/stagefright/foundation/ABase.h> #include <media/stagefright/foundation/AMessage.h> +#include <media/stagefright/MediaSource.h> #include <utils/KeyedVector.h> #include <utils/Vector.h> #include <utils/RefBase.h> @@ -30,7 +31,6 @@ namespace android { class ABitReader; struct ABuffer; -struct MediaSource; struct ATSParser : public RefBase { enum DiscontinuityType { @@ -62,9 +62,43 @@ struct ATSParser : public RefBase { ALIGNED_VIDEO_DATA = 2, }; + // Event is used to signal sync point event at feedTSPacket(). + struct SyncEvent { + SyncEvent(off64_t offset); + + void init(off64_t offset, const sp<MediaSource> &source, + int64_t timeUs); + + bool isInit() { return mInit; } + off64_t getOffset() { return mOffset; } + const sp<MediaSource> &getMediaSource() { return mMediaSource; } + int64_t getTimeUs() { return mTimeUs; } + + private: + bool mInit; + /* + * mInit == false: the current offset + * mInit == true: the start offset of sync payload + */ + off64_t mOffset; + /* The media source object for this event. */ + sp<MediaSource> mMediaSource; + /* The timestamp of the sync frame. */ + int64_t mTimeUs; + }; + ATSParser(uint32_t flags = 0); - status_t feedTSPacket(const void *data, size_t size); + // Feed a TS packet into the parser. uninitialized event with the start + // offset of this TS packet goes in, and if the parser detects PES with + // a sync frame, the event will be initiailzed with the start offset of the + // PES. Note that the offset of the event can be different from what we fed, + // as a PES may consist of multiple TS packets. + // + // Even in the case feedTSPacket() returns non-OK value, event still may be + // initialized if the parsing failed after the detection. + status_t feedTSPacket( + const void *data, size_t size, SyncEvent *event = NULL); void signalDiscontinuity( DiscontinuityType type, const sp<AMessage> &extra); @@ -126,15 +160,25 @@ private: void parseProgramAssociationTable(ABitReader *br); void parseProgramMap(ABitReader *br); - void parsePES(ABitReader *br); - + // Parse PES packet where br is pointing to. If the PES contains a sync + // frame, set event with the time and the start offset of this PES. + // Note that the method itself does not touch event. + void parsePES(ABitReader *br, SyncEvent *event); + + // Strip remaining packet headers and pass to appropriate program/stream + // to parse the payload. If the payload turns out to be PES and contains + // a sync frame, event shall be set with the time and start offset of the + // PES. + // Note that the method itself does not touch event. status_t parsePID( ABitReader *br, unsigned PID, unsigned continuity_counter, - unsigned payload_unit_start_indicator); + unsigned payload_unit_start_indicator, + SyncEvent *event); status_t parseAdaptationField(ABitReader *br, unsigned PID); - status_t parseTS(ABitReader *br); + // see feedTSPacket(). + status_t parseTS(ABitReader *br, SyncEvent *event); void updatePCR(unsigned PID, uint64_t PCR, size_t byteOffsetFromStart); |