diff options
| author | John Grossman <johngro@google.com> | 2012-02-22 15:38:35 -0800 |
|---|---|---|
| committer | John Grossman <johngro@google.com> | 2012-03-01 14:41:35 -0800 |
| commit | c795b64060c3af9d7961fc1371e4ccfa8ee3e450 (patch) | |
| tree | aafa8ecde306b5420e96b7a6e0965d1f1f4c4fa6 /media/libaah_rtp | |
| parent | 4b77dc28097288cb062fce6bf5de0fb3394877a9 (diff) | |
| download | frameworks_av-c795b64060c3af9d7961fc1371e4ccfa8ee3e450.zip frameworks_av-c795b64060c3af9d7961fc1371e4ccfa8ee3e450.tar.gz frameworks_av-c795b64060c3af9d7961fc1371e4ccfa8ee3e450.tar.bz2 | |
Switch the way we configure for MediaPlayer retransmission.
This is a cherry-pick of I6ab07d89b2eeb0650e634b8c3b7a0b36aba4e7dd
with merge conflicts addressed by hand and additional changes made in
response to code review feedback.
Move in the direction of a more publishable API for configuring a
media player for retransmission. It used to be that we used a custom
invoke and a modified URL (prefixed with aahTX://). There are many
issues with this technique and it was never meant to stand the test of
time.
This CL gets rid of all that. A new (but currently hidden) method was
introduced to the java level MediaPlayer API, called
setRetransmitTarget(InetSocketAddress), which allows an app writer to
set the retransmit target. For now, this method needs to be called
before a call to setDataSource (which is pretty unusual for the
MediaPlayer API) because this mid level code uses this as a cue to
instantiate an aahTX player instead of relying on the data source to
select a player. When retranmit functionality becomes part of the
existing android player implemenation, this
set-retrans-before-set-data-source behavior can go away, along with
the aahTX player itself.
Change-Id: I3b46c5227bbf69acb2f3cc4f93cfccad9777be98
Signed-off-by: John Grossman <johngro@google.com>
Diffstat (limited to 'media/libaah_rtp')
| -rw-r--r-- | media/libaah_rtp/aah_tx_player.cpp | 89 | ||||
| -rw-r--r-- | media/libaah_rtp/aah_tx_player.h | 12 | ||||
| -rw-r--r-- | media/libaah_rtp/aah_tx_sender.cpp | 4 |
3 files changed, 24 insertions, 81 deletions
diff --git a/media/libaah_rtp/aah_tx_player.cpp b/media/libaah_rtp/aah_tx_player.cpp index 90f7894..974805b 100644 --- a/media/libaah_rtp/aah_tx_player.cpp +++ b/media/libaah_rtp/aah_tx_player.cpp @@ -149,14 +149,7 @@ status_t AAH_TXPlayer::setDataSource_l( const KeyedVector<String8, String8> *headers) { reset_l(); - // the URL must consist of "aahTX://" followed by the real URL of - // the data source - const char *kAAHPrefix = "aahTX://"; - if (strncasecmp(url, kAAHPrefix, strlen(kAAHPrefix))) { - return INVALID_OPERATION; - } - - mUri.setTo(url + strlen(kAAHPrefix)); + mUri.setTo(url); if (headers) { mUriHeaders = *headers; @@ -794,67 +787,7 @@ status_t AAH_TXPlayer::getParameter(int key, Parcel *reply) { } status_t AAH_TXPlayer::invoke(const Parcel& request, Parcel *reply) { - if (!reply) { - return BAD_VALUE; - } - - int32_t methodID; - status_t err = request.readInt32(&methodID); - if (err != android::OK) { - return err; - } - - switch (methodID) { - case kInvokeSetAAHDstIPPort: - case kInvokeSetAAHConfigBlob: { - if (mEndpointValid) { - return INVALID_OPERATION; - } - - String8 addr; - uint16_t port; - - if (methodID == kInvokeSetAAHDstIPPort) { - addr = String8(request.readString16()); - - int32_t port32; - err = request.readInt32(&port32); - if (err != android::OK) { - return err; - } - port = static_cast<uint16_t>(port32); - } else { - String8 blob(request.readString16()); - - char addr_buf[101]; - if (sscanf(blob.string(), "V1:%100s %" SCNu16, - addr_buf, &port) != 2) { - return BAD_VALUE; - } - if (addr.setTo(addr_buf) != OK) { - return NO_MEMORY; - } - } - - struct hostent* ent = gethostbyname(addr.string()); - if (ent == NULL) { - return ERROR_UNKNOWN_HOST; - } - if (!(ent->h_addrtype == AF_INET && ent->h_length == 4)) { - return BAD_VALUE; - } - - Mutex::Autolock lock(mEndpointLock); - mEndpoint = AAH_TXSender::Endpoint( - reinterpret_cast<struct in_addr*>(ent->h_addr)->s_addr, - port); - mEndpointValid = true; - return OK; - }; - - default: - return INVALID_OPERATION; - } + return INVALID_OPERATION; } status_t AAH_TXPlayer::getMetadata(const media::Metadata::Filter& ids, @@ -889,6 +822,24 @@ status_t AAH_TXPlayer::setAudioStreamType(audio_stream_type_t streamType) { return OK; } +status_t AAH_TXPlayer::setRetransmitEndpoint( + const struct sockaddr_in* endpoint) { + Mutex::Autolock lock(mLock); + + if (NULL == endpoint) + return BAD_VALUE; + + // Once the endpoint has been registered, it may not be changed. + if (mEndpointRegistered) + return INVALID_OPERATION; + + mEndpoint.addr = endpoint->sin_addr.s_addr; + mEndpoint.port = endpoint->sin_port; + mEndpointValid = true; + + return OK; +} + void AAH_TXPlayer::notifyListener_l(int msg, int ext1, int ext2) { sendEvent(msg, ext1, ext2); } diff --git a/media/libaah_rtp/aah_tx_player.h b/media/libaah_rtp/aah_tx_player.h index 094c6f2..2e4b1f7 100644 --- a/media/libaah_rtp/aah_tx_player.h +++ b/media/libaah_rtp/aah_tx_player.h @@ -63,16 +63,8 @@ class AAH_TXPlayer : public MediaPlayerHWInterface { Parcel* records); virtual status_t setVolume(float leftVolume, float rightVolume); virtual status_t setAudioStreamType(audio_stream_type_t streamType); - - // invoke method IDs - enum { - // set the IP address and port of the A@H receiver - kInvokeSetAAHDstIPPort = 1, - - // set the destination IP address and port (and perhaps any additional - // parameters added in the future) packaged in one string - kInvokeSetAAHConfigBlob, - }; + virtual status_t setRetransmitEndpoint( + const struct sockaddr_in* endpoint); static const int64_t kAAHRetryKeepAroundTimeNs; diff --git a/media/libaah_rtp/aah_tx_sender.cpp b/media/libaah_rtp/aah_tx_sender.cpp index 499068c..08e32d2 100644 --- a/media/libaah_rtp/aah_tx_sender.cpp +++ b/media/libaah_rtp/aah_tx_sender.cpp @@ -243,7 +243,7 @@ void AAH_TXSender::doSendPacket_l(const sp<TRTPPacket>& packet, memset(&addr, 0, sizeof(addr)); addr.sin_family = AF_INET; addr.sin_addr.s_addr = endpoint.addr; - addr.sin_port = htons(endpoint.port); + addr.sin_port = endpoint.port; ssize_t result = sendto(mSocket, packet->getPacket(), @@ -412,7 +412,7 @@ void AAH_TXSender::RetryReceiver::handleRetryRequest() { return; } - Endpoint endpoint(request.endpointIP, ntohs(request.endpointPort)); + Endpoint endpoint(request.endpointIP, request.endpointPort); Mutex::Autolock lock(mSender->mEndpointLock); |
