forked from KFire-Android/android_device_amazon_otter
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Change-Id: Id767284c8ba8363b8efd68ab503fdf99a6223d0c
- Loading branch information
Showing
2 changed files
with
239 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 <utils/Errors.h> | ||
#include <utils/KeyedVector.h> | ||
#include <utils/RefBase.h> | ||
#include <utils/String8.h> | ||
#include <binder/IInterface.h> | ||
#include <binder/Parcel.h> | ||
|
||
|
||
|
||
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<IWFDClient>& listener) = 0; | ||
|
||
}; | ||
|
||
// ---------------------------------------------------------------------------- | ||
|
||
class BnWFD: public BnInterface<IWFD> | ||
{ | ||
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,157 @@ | ||
/* ==================================================================== | ||
* Copyright (C) 2012 Texas Instruments Incorporated | ||
* | ||
* All rights reserved. | ||
* ==================================================================== */ | ||
|
||
|
||
#ifndef MPEG2TS_RTP_WRITER_H_ | ||
|
||
#define MPEG2TS_RTP_WRITER_H_ | ||
|
||
#include <stdio.h> | ||
#include <sys/types.h> | ||
#include <sys/time.h> | ||
|
||
|
||
#include <media/stagefright/foundation/ABase.h> | ||
#include <media/stagefright/foundation/AHandlerReflector.h> | ||
#include <media/stagefright/foundation/ALooper.h> | ||
#include <media/stagefright/foundation/base64.h> | ||
#include <media/stagefright/MediaWriter.h> | ||
#include <media/stagefright/MediaBuffer.h> | ||
|
||
#include <arpa/inet.h> | ||
#include <sys/socket.h> | ||
|
||
|
||
namespace android { | ||
|
||
struct ABuffer; | ||
|
||
struct MPEG2TSRTPWriter : public MediaWriter { | ||
MPEG2TSRTPWriter(int fd); | ||
MPEG2TSRTPWriter(const char *filename); | ||
|
||
virtual status_t addSource(const sp<MediaSource> &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<String16>& args); | ||
|
||
void onMessageReceived(const sp<AMessage> &msg); | ||
|
||
protected: | ||
virtual ~MPEG2TSRTPWriter(); | ||
|
||
private: | ||
enum { | ||
kWhatSourceNotify = 'noti' , | ||
kWhatSendSR = 'sr ', | ||
}; | ||
|
||
struct SourceInfo; | ||
|
||
FILE *mFile; | ||
sp<ALooper> mLooper; | ||
sp<AHandlerReflector<MPEG2TSRTPWriter> > mReflector; | ||
|
||
bool mStarted; | ||
bool mPaused; | ||
bool mDiscontinuityIndicator; | ||
bool mIgnoreFirstPacket; | ||
|
||
Vector<sp<SourceInfo> > 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<ABuffer> &buffer); | ||
|
||
void writeMPEG2TSToFile(uint8_t *data, size_t size); | ||
|
||
static uint64_t GetNowNTP(); | ||
void onRead(const sp<AMessage> &msg); | ||
void onSendSR(const sp<AMessage> &msg); | ||
|
||
void addSR(const sp<ABuffer> &buffer); | ||
void addSDES(const sp<ABuffer> &buffer); | ||
|
||
void makeH264SPropParamSets(MediaBuffer *buffer); | ||
void dumpSessionDesc(); | ||
|
||
void sendBye(); | ||
|
||
void send(const sp<ABuffer> &buffer, bool isRTCP); | ||
|
||
void sendMPEG2TSData(sp<ABuffer> &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_ |