Bug 921963 - [RTSP] Support RTSP in Android JB build. r=sworkman

This commit is contained in:
Vincent Chang 2013-11-13 16:03:26 +08:00
parent 95f2bb6150
commit 45db1e1423
25 changed files with 80 additions and 72 deletions

View File

@ -240,6 +240,7 @@ if test -n "$gonkdir" ; then
MOZ_B2G_BT_BLUEDROID=1 MOZ_B2G_BT_BLUEDROID=1
fi fi
MOZ_RTSP=1
MOZ_NFC=1 MOZ_NFC=1
MOZ_B2G_CAMERA=1 MOZ_B2G_CAMERA=1
MOZ_OMX_DECODER=1 MOZ_OMX_DECODER=1

View File

@ -393,7 +393,7 @@ RtspMediaResource::Listener::OnConnected(uint8_t aTrackIdx,
} }
nsresult nsresult
RtspMediaResource::Listener::OnDisconnected(uint8_t aTrackIdx, uint32_t reason) RtspMediaResource::Listener::OnDisconnected(uint8_t aTrackIdx, nsresult reason)
{ {
if (!mResource) if (!mResource)
return NS_OK; return NS_OK;
@ -514,7 +514,7 @@ RtspMediaResource::OnConnected(uint8_t aTrackIdx,
} }
nsresult nsresult
RtspMediaResource::OnDisconnected(uint8_t aTrackIdx, uint32_t aReason) RtspMediaResource::OnDisconnected(uint8_t aTrackIdx, nsresult aReason)
{ {
NS_ASSERTION(NS_IsMainThread(), "Don't call on non-main thread"); NS_ASSERTION(NS_IsMainThread(), "Don't call on non-main thread");
@ -523,7 +523,7 @@ RtspMediaResource::OnDisconnected(uint8_t aTrackIdx, uint32_t aReason)
mTrackBuffer[i]->Reset(); mTrackBuffer[i]->Reset();
} }
if (aReason == (uint32_t)NS_ERROR_CONNECTION_REFUSED) { if (aReason == NS_ERROR_CONNECTION_REFUSED) {
mDecoder->NetworkError(); mDecoder->NetworkError();
} }
return NS_OK; return NS_OK;

View File

@ -108,7 +108,7 @@ interface nsIStreamingProtocolListener : nsISupports
* @param index Track number of the media stream. * @param index Track number of the media stream.
* @param reason The reason of disconnection. * @param reason The reason of disconnection.
*/ */
void onDisconnected(in uint8_t index, in uint32_t reason); void onDisconnected(in uint8_t index, in nsresult reason);
}; };
/** /**

View File

@ -55,8 +55,8 @@ child:
OnConnected(uint8_t index, OnConnected(uint8_t index,
RtspMetadataParam[] meta); RtspMetadataParam[] meta);
OnDisconnected(uint8_t index, OnDisconnected(uint8_t index,
uint32_t reason); nsresult reason);
AsyncOpenFailed(uint8_t reason); AsyncOpenFailed(nsresult reason);
}; };
} //namespace net } //namespace net

View File

@ -16,9 +16,16 @@ LOCAL_INCLUDES = \
-I$(srcdir) \ -I$(srcdir) \
-I$(srcdir)/rtsp \ -I$(srcdir)/rtsp \
-I$(srcdir)/controller \ -I$(srcdir)/controller \
-I$(ANDROID_SOURCE)/frameworks/base/media/libstagefright/mpeg2ts \
$(NULL) $(NULL)
ifeq ($(ANDROID_VERSION),$(findstring $(ANDROID_VERSION),15))
LOCAL_INCLUDES += -I$(ANDROID_SOURCE)/frameworks/base/media/libstagefright/mpeg2ts \
$(NULL)
else
LOCAL_INCLUDES += -I$(ANDROID_SOURCE)/frameworks/av/media/libstagefright/mpeg2ts \
$(NULL)
endif
include $(topsrcdir)/config/rules.mk include $(topsrcdir)/config/rules.mk
DEFINES += -DIMPL_NS_NET -Wno-multichar -DFORCE_PR_LOG DEFINES += -DIMPL_NS_NET -Wno-multichar -DFORCE_PR_LOG

View File

@ -302,7 +302,7 @@ class SendOnDisconnectedTask : public nsRunnable
public: public:
SendOnDisconnectedTask(nsIStreamingProtocolListener *listener, SendOnDisconnectedTask(nsIStreamingProtocolListener *listener,
uint8_t index, uint8_t index,
uint32_t reason) nsresult reason)
: mListener(listener) : mListener(listener)
, mIndex(index) , mIndex(index)
, mReason(reason) , mReason(reason)
@ -318,14 +318,14 @@ public:
private: private:
nsCOMPtr<nsIStreamingProtocolListener> mListener; nsCOMPtr<nsIStreamingProtocolListener> mListener;
uint8_t mIndex; uint8_t mIndex;
uint32_t mReason; nsresult mReason;
}; };
NS_IMETHODIMP NS_IMETHODIMP
RtspController::OnDisconnected(uint8_t index, RtspController::OnDisconnected(uint8_t index,
uint32_t reason) nsresult reason)
{ {
LOG(("RtspController::OnDisconnected()")); LOG(("RtspController::OnDisconnected() for track %d reason = 0x%x", index, reason));
mState = DISCONNECTED; mState = DISCONNECTED;
if (mListener) { if (mListener) {
nsRefPtr<SendOnDisconnectedTask> task = nsRefPtr<SendOnDisconnectedTask> task =

View File

@ -84,7 +84,7 @@ RtspControllerChild::RecvOnMediaDataAvailable(
{ {
nsRefPtr<RtspMetaData> meta = new RtspMetaData(); nsRefPtr<RtspMetaData> meta = new RtspMetaData();
nsresult rv = meta->DeserializeRtspMetaData(metaArray); nsresult rv = meta->DeserializeRtspMetaData(metaArray);
NS_ENSURE_SUCCESS(rv, false); NS_ENSURE_SUCCESS(rv, true);
if (mListener) { if (mListener) {
mListener->OnMediaDataAvailable(index, data, length, offset, meta.get()); mListener->OnMediaDataAvailable(index, data, length, offset, meta.get());
@ -115,7 +115,7 @@ RtspControllerChild::RecvOnConnected(
// Deserialize meta data. // Deserialize meta data.
nsRefPtr<RtspMetaData> meta = new RtspMetaData(); nsRefPtr<RtspMetaData> meta = new RtspMetaData();
nsresult rv = meta->DeserializeRtspMetaData(metaArray); nsresult rv = meta->DeserializeRtspMetaData(metaArray);
NS_ENSURE_SUCCESS(rv, false); NS_ENSURE_SUCCESS(rv, true);
meta->GetTotalTracks(&tracks); meta->GetTotalTracks(&tracks);
if (tracks <= 0) { if (tracks <= 0) {
LOG(("RtspControllerChild::RecvOnConnected invalid tracks %d", tracks)); LOG(("RtspControllerChild::RecvOnConnected invalid tracks %d", tracks));
@ -138,9 +138,9 @@ RtspControllerChild::RecvOnConnected(
bool bool
RtspControllerChild::RecvOnDisconnected( RtspControllerChild::RecvOnDisconnected(
const uint8_t& index, const uint8_t& index,
const uint32_t& reason) const nsresult& reason)
{ {
LOG(("RtspControllerChild::RecvOnDisconnected %d %d", index, reason)); LOG(("RtspControllerChild::RecvOnDisconnected for track %d reason = 0x%x", index, reason));
if (mListener) { if (mListener) {
mListener->OnDisconnected(index, reason); mListener->OnDisconnected(index, reason);
} }
@ -148,9 +148,9 @@ RtspControllerChild::RecvOnDisconnected(
} }
bool bool
RtspControllerChild::RecvAsyncOpenFailed(const uint8_t& reason) RtspControllerChild::RecvAsyncOpenFailed(const nsresult& reason)
{ {
LOG(("RtspControllerChild::RecvAsyncOpenFailed %d", reason)); LOG(("RtspControllerChild::RecvAsyncOpenFailed reason = 0x%x", reason));
if (mListener) { if (mListener) {
mListener->OnDisconnected(0, NS_ERROR_CONNECTION_REFUSED); mListener->OnDisconnected(0, NS_ERROR_CONNECTION_REFUSED);
} }
@ -249,7 +249,7 @@ NS_IMETHODIMP
RtspControllerChild::Play(void) RtspControllerChild::Play(void)
{ {
LOG(("RtspControllerChild::Play()")); LOG(("RtspControllerChild::Play()"));
NS_ENSURE_SUCCESS(mIPCOpen, NS_ERROR_FAILURE); NS_ENSURE_TRUE(mIPCOpen, NS_ERROR_FAILURE);
if (NS_IsMainThread()) { if (NS_IsMainThread()) {
if (!SendPlay()) if (!SendPlay())
@ -267,7 +267,7 @@ NS_IMETHODIMP
RtspControllerChild::Pause(void) RtspControllerChild::Pause(void)
{ {
LOG(("RtspControllerChild::Pause()")); LOG(("RtspControllerChild::Pause()"));
NS_ENSURE_SUCCESS(mIPCOpen, NS_ERROR_FAILURE); NS_ENSURE_TRUE(mIPCOpen, NS_ERROR_FAILURE);
if (NS_IsMainThread()) { if (NS_IsMainThread()) {
if (!SendPause()) if (!SendPause())
@ -285,7 +285,7 @@ NS_IMETHODIMP
RtspControllerChild::Resume(void) RtspControllerChild::Resume(void)
{ {
LOG(("RtspControllerChild::Resume()")); LOG(("RtspControllerChild::Resume()"));
NS_ENSURE_SUCCESS(mIPCOpen, NS_ERROR_FAILURE); NS_ENSURE_TRUE(mIPCOpen, NS_ERROR_FAILURE);
NS_ENSURE_TRUE(mSuspendCount > 0, NS_ERROR_UNEXPECTED); NS_ENSURE_TRUE(mSuspendCount > 0, NS_ERROR_UNEXPECTED);
if (!--mSuspendCount) { if (!--mSuspendCount) {
@ -306,7 +306,7 @@ NS_IMETHODIMP
RtspControllerChild::Suspend(void) RtspControllerChild::Suspend(void)
{ {
LOG(("RtspControllerChild::Suspend()")); LOG(("RtspControllerChild::Suspend()"));
NS_ENSURE_SUCCESS(mIPCOpen, NS_ERROR_FAILURE); NS_ENSURE_TRUE(mIPCOpen, NS_ERROR_FAILURE);
if (!mSuspendCount++) { if (!mSuspendCount++) {
if (NS_IsMainThread()) { if (NS_IsMainThread()) {
@ -326,7 +326,7 @@ NS_IMETHODIMP
RtspControllerChild::Seek(uint64_t seekTimeUs) RtspControllerChild::Seek(uint64_t seekTimeUs)
{ {
LOG(("RtspControllerChild::Seek() %llu", seekTimeUs)); LOG(("RtspControllerChild::Seek() %llu", seekTimeUs));
NS_ENSURE_SUCCESS(mIPCOpen, NS_ERROR_FAILURE); NS_ENSURE_TRUE(mIPCOpen, NS_ERROR_FAILURE);
if (NS_IsMainThread()) { if (NS_IsMainThread()) {
if (!SendSeek(seekTimeUs)) if (!SendSeek(seekTimeUs))
@ -344,7 +344,7 @@ NS_IMETHODIMP
RtspControllerChild::Stop() RtspControllerChild::Stop()
{ {
LOG(("RtspControllerChild::Stop()")); LOG(("RtspControllerChild::Stop()"));
NS_ENSURE_SUCCESS(mIPCOpen, NS_ERROR_FAILURE); NS_ENSURE_TRUE(mIPCOpen, NS_ERROR_FAILURE);
if (NS_IsMainThread()) { if (NS_IsMainThread()) {
if (!SendStop()) if (!SendStop())
@ -392,9 +392,9 @@ RtspControllerChild::OnConnected(uint8_t index,
NS_IMETHODIMP NS_IMETHODIMP
RtspControllerChild::OnDisconnected(uint8_t index, RtspControllerChild::OnDisconnected(uint8_t index,
uint32_t reason) nsresult reason)
{ {
LOG(("RtspControllerChild::OnDisconnected()")); LOG(("RtspControllerChild::OnDisconnected() reason = 0x%x", reason));
return NS_ERROR_NOT_IMPLEMENTED; return NS_ERROR_NOT_IMPLEMENTED;
} }

View File

@ -40,9 +40,9 @@ class RtspControllerChild : public nsIStreamingProtocolController
const InfallibleTArray<RtspMetadataParam>& meta); const InfallibleTArray<RtspMetadataParam>& meta);
bool RecvOnDisconnected(const uint8_t& index, bool RecvOnDisconnected(const uint8_t& index,
const uint32_t& reason); const nsresult& reason);
bool RecvAsyncOpenFailed(const uint8_t& reason); bool RecvAsyncOpenFailed(const nsresult& reason);
void AddIPDLReference(); void AddIPDLReference();
void ReleaseIPDLReference(); void ReleaseIPDLReference();
void AddMetaData(already_AddRefed<nsIStreamingProtocolMetaData> meta); void AddMetaData(already_AddRefed<nsIStreamingProtocolMetaData> meta);

View File

@ -72,10 +72,10 @@ bool
RtspControllerParent::RecvPlay() RtspControllerParent::RecvPlay()
{ {
LOG(("RtspControllerParent::RecvPlay()")); LOG(("RtspControllerParent::RecvPlay()"));
NS_ENSURE_TRUE(mController, NS_ERROR_NOT_INITIALIZED); NS_ENSURE_TRUE(mController, true);
nsresult rv = mController->Play(); nsresult rv = mController->Play();
NS_ENSURE_SUCCESS(rv, false); NS_ENSURE_SUCCESS(rv, true);
return true; return true;
} }
@ -83,10 +83,10 @@ bool
RtspControllerParent::RecvPause() RtspControllerParent::RecvPause()
{ {
LOG(("RtspControllerParent::RecvPause()")); LOG(("RtspControllerParent::RecvPause()"));
NS_ENSURE_TRUE(mController, NS_ERROR_NOT_INITIALIZED); NS_ENSURE_TRUE(mController, true);
nsresult rv = mController->Pause(); nsresult rv = mController->Pause();
NS_ENSURE_SUCCESS(rv, false); NS_ENSURE_SUCCESS(rv, true);
return true; return true;
} }
@ -94,10 +94,10 @@ bool
RtspControllerParent::RecvResume() RtspControllerParent::RecvResume()
{ {
LOG(("RtspControllerParent::RecvResume()")); LOG(("RtspControllerParent::RecvResume()"));
NS_ENSURE_TRUE(mController, NS_ERROR_NOT_INITIALIZED); NS_ENSURE_TRUE(mController, true);
nsresult rv = mController->Resume(); nsresult rv = mController->Resume();
NS_ENSURE_SUCCESS(rv, false); NS_ENSURE_SUCCESS(rv, true);
return true; return true;
} }
@ -105,10 +105,10 @@ bool
RtspControllerParent::RecvSuspend() RtspControllerParent::RecvSuspend()
{ {
LOG(("RtspControllerParent::RecvSuspend()")); LOG(("RtspControllerParent::RecvSuspend()"));
NS_ENSURE_TRUE(mController, NS_ERROR_NOT_INITIALIZED); NS_ENSURE_TRUE(mController, true);
nsresult rv = mController->Suspend(); nsresult rv = mController->Suspend();
NS_ENSURE_SUCCESS(rv, false); NS_ENSURE_SUCCESS(rv, true);
return true; return true;
} }
@ -116,10 +116,10 @@ bool
RtspControllerParent::RecvSeek(const uint64_t& offset) RtspControllerParent::RecvSeek(const uint64_t& offset)
{ {
LOG(("RtspControllerParent::RecvSeek()")); LOG(("RtspControllerParent::RecvSeek()"));
NS_ENSURE_TRUE(mController, NS_ERROR_NOT_INITIALIZED); NS_ENSURE_TRUE(mController, true);
nsresult rv = mController->Seek(offset); nsresult rv = mController->Seek(offset);
NS_ENSURE_SUCCESS(rv, false); NS_ENSURE_SUCCESS(rv, true);
return true; return true;
} }
@ -127,10 +127,10 @@ bool
RtspControllerParent::RecvStop() RtspControllerParent::RecvStop()
{ {
LOG(("RtspControllerParent::RecvStop()")); LOG(("RtspControllerParent::RecvStop()"));
NS_ENSURE_TRUE(mController, NS_ERROR_NOT_INITIALIZED); NS_ENSURE_TRUE(mController, true);
nsresult rv = mController->Stop(); nsresult rv = mController->Stop();
NS_ENSURE_SUCCESS(rv, false); NS_ENSURE_SUCCESS(rv, true);
return true; return true;
} }
@ -244,9 +244,9 @@ RtspControllerParent::OnConnected(uint8_t index,
NS_IMETHODIMP NS_IMETHODIMP
RtspControllerParent::OnDisconnected(uint8_t index, RtspControllerParent::OnDisconnected(uint8_t index,
uint32_t reason) nsresult reason)
{ {
LOG(("RtspControllerParent::OnDisconnected()")); LOG(("RtspControllerParent::OnDisconnected() for track %d reason = 0x%x", index, reason));
if (!mIPCOpen || !SendOnDisconnected(index, reason)) { if (!mIPCOpen || !SendOnDisconnected(index, reason)) {
return NS_ERROR_FAILURE; return NS_ERROR_FAILURE;
} }

View File

@ -14,9 +14,8 @@
* limitations under the License. * limitations under the License.
*/ */
//#define LOG_NDEBUG 0
#define LOG_TAG "AAMRAssembler" #define LOG_TAG "AAMRAssembler"
#include <utils/Log.h> #include "RtspPrlog.h"
#include "AAMRAssembler.h" #include "AAMRAssembler.h"

View File

@ -14,9 +14,8 @@
* limitations under the License. * limitations under the License.
*/ */
//#define LOG_NDEBUG 0
#define LOG_TAG "AAVCAssembler" #define LOG_TAG "AAVCAssembler"
#include <utils/Log.h> #include "RtspPrlog.h"
#include "AAVCAssembler.h" #include "AAVCAssembler.h"

View File

@ -14,8 +14,8 @@
* limitations under the License. * limitations under the License.
*/ */
//#define LOG_NDEBUG 0
#define LOG_TAG "AMPEG4AudioAssembler" #define LOG_TAG "AMPEG4AudioAssembler"
#include "RtspPrlog.h"
#include "AMPEG4AudioAssembler.h" #include "AMPEG4AudioAssembler.h"

View File

@ -14,9 +14,8 @@
* limitations under the License. * limitations under the License.
*/ */
//#define LOG_NDEBUG 0
#define LOG_TAG "AMPEG4ElementaryAssembler" #define LOG_TAG "AMPEG4ElementaryAssembler"
#include <utils/Log.h> #include "RtspPrlog.h"
#include "AMPEG4ElementaryAssembler.h" #include "AMPEG4ElementaryAssembler.h"

View File

@ -14,9 +14,8 @@
* limitations under the License. * limitations under the License.
*/ */
//#define LOG_NDEBUG 0
#define LOG_TAG "APacketSource" #define LOG_TAG "APacketSource"
#include <utils/Log.h> #include "RtspPrlog.h"
#include "APacketSource.h" #include "APacketSource.h"

View File

@ -14,9 +14,8 @@
* limitations under the License. * limitations under the License.
*/ */
//#define LOG_NDEBUG 0
#define LOG_TAG "ARTPConnection" #define LOG_TAG "ARTPConnection"
#include <utils/Log.h> #include "RtspPrlog.h"
#include "ARTPConnection.h" #include "ARTPConnection.h"

View File

@ -14,7 +14,6 @@
* limitations under the License. * limitations under the License.
*/ */
//#define LOG_NDEBUG 0
#define LOG_TAG "ARTPSession" #define LOG_TAG "ARTPSession"
#include <utils/Log.h> #include <utils/Log.h>

View File

@ -14,9 +14,8 @@
* limitations under the License. * limitations under the License.
*/ */
//#define LOG_NDEBUG 0
#define LOG_TAG "ARTPSource" #define LOG_TAG "ARTPSource"
#include <utils/Log.h> #include "RtspPrlog.h"
#include "ARTPSource.h" #include "ARTPSource.h"

View File

@ -14,9 +14,8 @@
* limitations under the License. * limitations under the License.
*/ */
//#define LOG_NDEBUG 0
#define LOG_TAG "ARTPWriter" #define LOG_TAG "ARTPWriter"
#include <utils/Log.h> #include "RtspPrlog.h"
#include "ARTPWriter.h" #include "ARTPWriter.h"

View File

@ -14,9 +14,8 @@
* limitations under the License. * limitations under the License.
*/ */
//#define LOG_NDEBUG 0
#define LOG_TAG "ARTSPConnection" #define LOG_TAG "ARTSPConnection"
#include <utils/Log.h> #include "RtspPrlog.h"
#include "ARTSPConnection.h" #include "ARTSPConnection.h"

View File

@ -14,9 +14,8 @@
* limitations under the License. * limitations under the License.
*/ */
//#define LOG_NDEBUG 0
#define LOG_TAG "ARawAudioAssembler" #define LOG_TAG "ARawAudioAssembler"
#include <utils/Log.h> #include "RtspPrlog.h"
#include "ARawAudioAssembler.h" #include "ARawAudioAssembler.h"

View File

@ -14,9 +14,8 @@
* limitations under the License. * limitations under the License.
*/ */
//#define LOG_NDEBUG 0
#define LOG_TAG "ASessionDescription" #define LOG_TAG "ASessionDescription"
#include <utils/Log.h> #include "RtspPrlog.h"
#include "ASessionDescription.h" #include "ASessionDescription.h"

View File

@ -14,6 +14,7 @@
* limitations under the License. * limitations under the License.
*/ */
#include "RtspPrlog.h"
#include "RTSPSource.h" #include "RTSPSource.h"
#include "ARTPConnection.h" #include "ARTPConnection.h"
#include "RTSPConnectionHandler.h" #include "RTSPConnectionHandler.h"
@ -28,13 +29,6 @@
#include "nsString.h" #include "nsString.h"
#include "nsStringStream.h" #include "nsStringStream.h"
#include "nsAutoPtr.h" #include "nsAutoPtr.h"
#include "prlog.h"
extern PRLogModuleInfo* gRtspLog;
#define LOGI(msg, ...) PR_LOG(gRtspLog, PR_LOG_ALWAYS, (msg, ##__VA_ARGS__))
#define LOGV(msg, ...) PR_LOG(gRtspLog, PR_LOG_DEBUG, (msg, ##__VA_ARGS__))
#define LOGE(msg, ...) PR_LOG(gRtspLog, PR_LOG_ERROR, (msg, ##__VA_ARGS__))
#define LOGW(msg, ...) PR_LOG(gRtspLog, PR_LOG_WARNING, (msg, ##__VA_ARGS__))
using namespace mozilla; using namespace mozilla;
using namespace mozilla::net; using namespace mozilla::net;

View File

@ -0,0 +1,19 @@
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set sw=2 ts=8 et tw=80 : */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifndef RTSPPRLOG_H
#define RTSPPRLOG_H
#include "prlog.h"
extern PRLogModuleInfo* gRtspLog;
#define LOGI(msg, ...) PR_LOG(gRtspLog, PR_LOG_ALWAYS, (msg, ##__VA_ARGS__))
#define LOGV(msg, ...) PR_LOG(gRtspLog, PR_LOG_DEBUG, (msg, ##__VA_ARGS__))
#define LOGE(msg, ...) PR_LOG(gRtspLog, PR_LOG_ERROR, (msg, ##__VA_ARGS__))
#define LOGW(msg, ...) PR_LOG(gRtspLog, PR_LOG_WARNING, (msg, ##__VA_ARGS__))
#endif // RTSPPRLOG_H

View File

@ -14,7 +14,6 @@
* limitations under the License. * limitations under the License.
*/ */
//#define LOG_NDEBUG 0
#define LOG_TAG "UDPPusher" #define LOG_TAG "UDPPusher"
#include <utils/Log.h> #include <utils/Log.h>

View File

@ -14,7 +14,6 @@
* limitations under the License. * limitations under the License.
*/ */
//#define LOG_NDEBUG 0
#define LOG_TAG "rtp_test" #define LOG_TAG "rtp_test"
#include <utils/Log.h> #include <utils/Log.h>