diff --git a/src-headers/wfd/IWFD.h b/src-headers/wfd/IWFD.h new file mode 100644 index 0000000..ecb1a57 --- /dev/null +++ b/src-headers/wfd/IWFD.h @@ -0,0 +1,82 @@ +/* ==================================================================== +* Copyright (C) 2012 Texas Instruments Incorporated +* +* All rights reserved. +* ==================================================================== */ + +#ifndef ANDROID_IWFD_H +#define ANDROID_IWFD_H + +typedef struct { + int cookie; + int w; + int h; + int fps; + int secure; + int mode; +} wfd_config; + +enum { + WFD_DISCONNECTED, + WFD_CONNECTED, + WFD_SETUP_COMPLETE, + WFD_TEARDOWN_COMPLETE, + WFD_MODE_CHANGED, +}; + +enum { + WFD_MODE_DISABLED = 0x0, + WFD_MODE_CLONING = 0x1, + WFD_MODE_DOCKING = 0x2, +}; + + + +#ifdef __cplusplus + +#include +#include +#include +#include +#include +#include + + + +namespace android { + +class IWFDClient; + +class IWFD: public IInterface +{ +public: + DECLARE_META_INTERFACE(WFD); + + virtual status_t prepare() = 0; + virtual status_t release() = 0; + virtual status_t setParameter(const String8& key, const String8& value) = 0; + virtual status_t getWFDDescriptor(Parcel *reply) = 0; + virtual status_t setupWFD(wfd_config *cfg) = 0; + virtual status_t teardownWFD() = 0; + virtual status_t setListener(const sp& listener) = 0; + +}; + +// ---------------------------------------------------------------------------- + +class BnWFD: public BnInterface +{ +public: + virtual status_t onTransact( uint32_t code, + const Parcel& data, + Parcel* reply, + uint32_t flags = 0); +}; + +}; // namespace android +#else + +#endif + + +#endif // ANDROID_IWFD_H diff --git a/src-headers/wfd/MPEG2TSRTPWriter.h b/src-headers/wfd/MPEG2TSRTPWriter.h new file mode 100644 index 0000000..6576a23 --- /dev/null +++ b/src-headers/wfd/MPEG2TSRTPWriter.h @@ -0,0 +1,157 @@ +/* ==================================================================== +* Copyright (C) 2012 Texas Instruments Incorporated +* +* All rights reserved. +* ==================================================================== */ + + +#ifndef MPEG2TS_RTP_WRITER_H_ + +#define MPEG2TS_RTP_WRITER_H_ + +#include +#include +#include + + +#include +#include +#include +#include +#include +#include + +#include +#include + + +namespace android { + +struct ABuffer; + +struct MPEG2TSRTPWriter : public MediaWriter { + MPEG2TSRTPWriter(int fd); + MPEG2TSRTPWriter(const char *filename); + + virtual status_t addSource(const sp &source); + virtual status_t start(MetaData *param = NULL); + virtual status_t stop(); + virtual status_t pause(); + virtual bool reachedEOS(); + virtual status_t dump(int fd, const Vector& args); + + void onMessageReceived(const sp &msg); + +protected: + virtual ~MPEG2TSRTPWriter(); + +private: + enum { + kWhatSourceNotify = 'noti' , + kWhatSendSR = 'sr ', + }; + + struct SourceInfo; + + FILE *mFile; + sp mLooper; + sp > mReflector; + + bool mStarted; + bool mPaused; + bool mDiscontinuityIndicator; + bool mIgnoreFirstPacket; + + Vector > mSources; + size_t mNumSourcesDone; + + int64_t mNumTSPacketsWritten; + int64_t mNumTSPacketsBeforeMeta; + +#if LOG_TO_FILES + int mRTPFd; + int mRTCPFd; +#endif + + + int mSocket; + struct sockaddr_in mRTPAddr; + struct sockaddr_in mRTCPAddr; + + AString mProfileLevel; + AString mSeqParamSet; + AString mPicParamSet; + + uint32_t mSourceID; + uint32_t mSeqNo; + uint32_t mRTPTimeBase; + uint32_t mNumRTPSent; + uint32_t mNumRTPOctetsSent; + uint32_t mLastRTPTime; + uint64_t mLastNTPTime; + + int32_t mNumSRsSent; + + int64_t mStartTime; + int32_t mBitRate; + uint32_t mPATContinuityCounter; + uint32_t mPMTContinuityCounter; + uint32_t mPCRContinuityCounter; + + int64_t mAudioDrift; + + char *mSinkIPAddr; + int32_t mSinkAVRtpPort; + + int64_t mStartTimestampUs; + + Mutex mLock; + + enum { + INVALID, + H264, + AAC, + LPCM, + } mMode; + + + void init(); + + void writeTS(); + void writeProgramAssociationTable(); + void writeProgramMap(); + void writePCRAccessUnit(int64_t pcr_clock); + uint8_t addPCRAdaptationField(uint8_t *data, int64_t PCR_base, int64_t PCR_ext, uint8_t adaptationStuffBytes); + uint8_t addDummyAdaptationField(uint8_t *data, uint8_t stuffBytes); + size_t addPESHeader(uint8_t *data, unsigned int stream_id, size_t PES_packet_length, int64_t PTS); + void writeAccessUnit(int32_t sourceIndex, const sp &buffer); + + void writeMPEG2TSToFile(uint8_t *data, size_t size); + + static uint64_t GetNowNTP(); + void onRead(const sp &msg); + void onSendSR(const sp &msg); + + void addSR(const sp &buffer); + void addSDES(const sp &buffer); + + void makeH264SPropParamSets(MediaBuffer *buffer); + void dumpSessionDesc(); + + void sendBye(); + + void send(const sp &buffer, bool isRTCP); + + void sendMPEG2TSData(sp &rtpBuffer, int64_t timestamp = 0); + + + void initializeCRCTable(); + + unsigned int calculateCRC(unsigned char *ptrSection, unsigned int length ); + + DISALLOW_EVIL_CONSTRUCTORS(MPEG2TSRTPWriter); +}; + +} // namespace android + +#endif // MPEG2TS_RTP_WRITER_H_