diff options
author | Andreas Huber <andih@google.com> | 2012-10-30 15:53:03 -0700 |
---|---|---|
committer | Andreas Huber <andih@google.com> | 2012-10-31 09:21:24 -0700 |
commit | 90a92053219ae50ddf4bb54e3d54db2d309e2b8d (patch) | |
tree | 1d624b3c800a6cd2e755c379058bb43949f91ab0 /media/libstagefright/wifi-display/source/Sender.h | |
parent | 2295ce2c6fcf07ffaa134440691a8cea5fe35b43 (diff) |
Various tweaks to wfd
related-to-bug: 7426218
Squashed commit of the following:
commit 1553f1a1c66af998674168f7f7a3be23fcb0c794
Author: Andreas Huber <andih@google.com>
Date: Tue Oct 30 15:51:27 2012 -0700
Add LPCM, AVC and AVC HRD descriptors as necessary.
Change-Id: Ibc836fced0fe37e8a25574c2295e886765b9ea6f
commit 4e74db61d2d31ebe239acbdec8f110f88016a4ea
Author: Andreas Huber <andih@google.com>
Date: Tue Oct 30 15:50:52 2012 -0700
added copyright headers to Sender.{cpp,h}
Change-Id: If615ccb8767e32bd83ed1f0f669acc39a72489f6
commit 7144bf8ae68c5cdb8faa6e219547aabbd750f04e
Author: Andreas Huber <andih@google.com>
Date: Tue Oct 30 15:50:25 2012 -0700
Reenable suspension of the RepeaterSource
Change-Id: I765338fcde89c65e4b69be45a5949eba6bcdcf6f
commit 812164bcfa0699821d7d8eefcc0dff96b2e2cd08
Author: Andreas Huber <andih@google.com>
Date: Tue Oct 30 14:03:50 2012 -0700
Add 2 stuffing bytes to the PES headers for audio tracks.
Change-Id: I8b9c634f6a565ab7fa7ecdb610f7d8557e0b139b
commit a084a741a63015d47c92d99fcd8b980fe615dc7d
Author: Andreas Huber <andih@google.com>
Date: Tue Oct 30 13:19:38 2012 -0700
Fix PCM audio packetization in WFD.
Change-Id: I99a435f9fe6b4397f24d6c22afae5ae2505ffc14
commit c5cb9369585f701f34bce41534940d5f9b59248f
Author: Andreas Huber <andih@google.com>
Date: Tue Oct 30 13:19:12 2012 -0700
Support extraction of PCM audio from transport streams.
Change-Id: I28a0516756ebcb5587325b6588df013ac871ffb9
commit b0a0512300ae037d6b39c2d04952d34b5fc12b2d
Author: Andreas Huber <andih@google.com>
Date: Tue Oct 30 08:54:13 2012 -0700
disable suspend of the RepeaterSource
Change-Id: Ibf42a98185b0567f817ae582a82e6580f95d3d40
commit 4330e8b7668dc92a6d882b5622c0697cf292d04c
Author: Andreas Huber <andih@google.com>
Date: Mon Oct 29 14:11:25 2012 -0700
Better handling of datagrams in ANetworkSession
reduce unnecessary copy overhead.
Change-Id: I2ed8c767274ba07764f03e8d4913041168e5755f
commit a44e73c322ba3f2c336f7cc4e1d63d3a74faa75d
Author: Andreas Huber <andih@google.com>
Date: Mon Oct 29 11:14:47 2012 -0700
Network traffic is now handled on a separate thread.
Audio and video are queued to ensure proper A/V interleaving.
Scheduled packet sends according to capture timestamps to reduce
send-jitter.
Change-Id: Ibd6357c1e663086cf87bec0a98f8e54dfdfaa0e5
related-to-bug: 7426218
Change-Id: Ia440129d656c35814abf18df06da50b73d5bb554
Diffstat (limited to 'media/libstagefright/wifi-display/source/Sender.h')
-rw-r--r-- | media/libstagefright/wifi-display/source/Sender.h | 166 |
1 files changed, 166 insertions, 0 deletions
diff --git a/media/libstagefright/wifi-display/source/Sender.h b/media/libstagefright/wifi-display/source/Sender.h new file mode 100644 index 00000000..e476e846 --- /dev/null +++ b/media/libstagefright/wifi-display/source/Sender.h @@ -0,0 +1,166 @@ +/* + * Copyright 2012, The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef SENDER_H_ + +#define SENDER_H_ + +#include <media/stagefright/foundation/AHandler.h> + +namespace android { + +#define LOG_TRANSPORT_STREAM 0 +#define ENABLE_RETRANSMISSION 0 +#define TRACK_BANDWIDTH 0 + +struct ABuffer; +struct ANetworkSession; + +struct Sender : public AHandler { + Sender(const sp<ANetworkSession> &netSession, const sp<AMessage> ¬ify); + + enum { + kWhatInitDone, + kWhatSessionDead, + kWhatBinaryData, + }; + + enum TransportMode { + TRANSPORT_UDP, + TRANSPORT_TCP_INTERLEAVED, + TRANSPORT_TCP, + }; + status_t init( + const char *clientIP, int32_t clientRtp, int32_t clientRtcp, + TransportMode transportMode); + + status_t finishInit(); + + int32_t getRTPPort() const; + + void queuePackets(int64_t timeUs, const sp<ABuffer> &packets); + void scheduleSendSR(); + +protected: + virtual ~Sender(); + virtual void onMessageReceived(const sp<AMessage> &msg); + +private: + enum { + kWhatQueuePackets, + kWhatSendSR, + kWhatRTPNotify, + kWhatRTCPNotify, +#if ENABLE_RETRANSMISSION + kWhatRTPRetransmissionNotify, + kWhatRTCPRetransmissionNotify +#endif + }; + + static const int64_t kSendSRIntervalUs = 10000000ll; + + static const uint32_t kSourceID = 0xdeadbeef; + static const size_t kMaxHistoryLength = 128; + +#if ENABLE_RETRANSMISSION + static const size_t kRetransmissionPortOffset = 120; +#endif + + sp<ANetworkSession> mNetSession; + sp<AMessage> mNotify; + + sp<ABuffer> mTSQueue; + + TransportMode mTransportMode; + AString mClientIP; + + // in TCP mode + int32_t mRTPChannel; + int32_t mRTCPChannel; + + // in UDP mode + int32_t mRTPPort; + int32_t mRTPSessionID; + int32_t mRTCPSessionID; + +#if ENABLE_RETRANSMISSION + int32_t mRTPRetransmissionSessionID; + int32_t mRTCPRetransmissionSessionID; +#endif + + int32_t mClientRTPPort; + int32_t mClientRTCPPort; + bool mRTPConnected; + bool mRTCPConnected; + + + int64_t mFirstOutputBufferReadyTimeUs; + int64_t mFirstOutputBufferSentTimeUs; + + uint32_t mRTPSeqNo; +#if ENABLE_RETRANSMISSION + uint32_t mRTPRetransmissionSeqNo; +#endif + + uint64_t mLastNTPTime; + uint32_t mLastRTPTime; + uint32_t mNumRTPSent; + uint32_t mNumRTPOctetsSent; + uint32_t mNumSRsSent; + + bool mSendSRPending; + +#if ENABLE_RETRANSMISSION + List<sp<ABuffer> > mHistory; + size_t mHistoryLength; +#endif + +#if TRACK_BANDWIDTH + int64_t mFirstPacketTimeUs; + uint64_t mTotalBytesSent; +#endif + + void onSendSR(); + void addSR(const sp<ABuffer> &buffer); + void addSDES(const sp<ABuffer> &buffer); + static uint64_t GetNowNTP(); + +#if LOG_TRANSPORT_STREAM + FILE *mLogFile; +#endif + + ssize_t appendTSData( + const void *data, size_t size, bool timeDiscontinuity, bool flush); + + void onQueuePackets(const sp<ABuffer> &packets); + +#if ENABLE_RETRANSMISSION + status_t parseTSFB(const uint8_t *data, size_t size); +#endif + + status_t parseRTCP(const sp<ABuffer> &buffer); + + status_t sendPacket(int32_t sessionID, const void *data, size_t size); + + void notifyInitDone(); + void notifySessionDead(); + + DISALLOW_EVIL_CONSTRUCTORS(Sender); +}; + +} // namespace android + +#endif // SENDER_H_ |