summaryrefslogtreecommitdiffstats
path: root/cmds
diff options
context:
space:
mode:
authorAndreas Huber <andih@google.com>2010-07-22 09:20:13 -0700
committerAndreas Huber <andih@google.com>2010-07-22 09:21:05 -0700
commit348a8eab84f4bba76c04ca83b2f5418467aa1a48 (patch)
treeb75461fcab7782b8029426e9976b8d805a3b1fd3 /cmds
parent66d6f1fcd9cb80a603b833e93779eb0dfb5e67ee (diff)
downloadframeworks_av-348a8eab84f4bba76c04ca83b2f5418467aa1a48.zip
frameworks_av-348a8eab84f4bba76c04ca83b2f5418467aa1a48.tar.gz
frameworks_av-348a8eab84f4bba76c04ca83b2f5418467aa1a48.tar.bz2
Various changes to improve rtsp networking, reduce packet loss and adapt to ALooper API changes.
Change-Id: I110e19d5ce33e597add3ffbd3e3ff3815862396d
Diffstat (limited to 'cmds')
-rw-r--r--cmds/stagefright/stagefright.cpp41
1 files changed, 36 insertions, 5 deletions
diff --git a/cmds/stagefright/stagefright.cpp b/cmds/stagefright/stagefright.cpp
index f74240f..4a1d27b 100644
--- a/cmds/stagefright/stagefright.cpp
+++ b/cmds/stagefright/stagefright.cpp
@@ -25,6 +25,8 @@
#include <binder/IServiceManager.h>
#include <binder/ProcessState.h>
#include <media/IMediaPlayerService.h>
+#include <media/stagefright/foundation/ALooper.h>
+#include "include/ARTSPController.h"
#include <media/stagefright/AudioPlayer.h>
#include <media/stagefright/DataSource.h>
#include <media/stagefright/JPEGSource.h>
@@ -365,6 +367,9 @@ int main(int argc, char **argv) {
gPlaybackAudio = false;
gWriteMP4 = false;
+ sp<ALooper> looper;
+ sp<ARTSPController> rtspController;
+
int res;
while ((res = getopt(argc, argv, "han:lm:b:ptsow:k")) >= 0) {
switch (res) {
@@ -576,7 +581,8 @@ int main(int argc, char **argv) {
sp<DataSource> dataSource = DataSource::CreateFromURI(filename);
- if (strncasecmp(filename, "sine:", 5) && dataSource == NULL) {
+ if ((strncasecmp(filename, "sine:", 5)
+ && strncasecmp(filename, "rtsp://", 7)) && dataSource == NULL) {
fprintf(stderr, "Unable to create data source.\n");
return 1;
}
@@ -601,10 +607,28 @@ int main(int argc, char **argv) {
}
mediaSource = new SineSource(sampleRate, 1);
} else {
- sp<MediaExtractor> extractor = MediaExtractor::Create(dataSource);
- if (extractor == NULL) {
- fprintf(stderr, "could not create extractor.\n");
- return -1;
+ sp<MediaExtractor> extractor;
+
+ if (!strncasecmp("rtsp://", filename, 7)) {
+ if (looper == NULL) {
+ looper = new ALooper;
+ looper->start();
+ }
+
+ rtspController = new ARTSPController(looper);
+ status_t err = rtspController->connect(filename);
+ if (err != OK) {
+ fprintf(stderr, "could not connect to rtsp server.\n");
+ return -1;
+ }
+
+ extractor = rtspController.get();
+ } else {
+ extractor = MediaExtractor::Create(dataSource);
+ if (extractor == NULL) {
+ fprintf(stderr, "could not create extractor.\n");
+ return -1;
+ }
}
size_t numTracks = extractor->countTracks();
@@ -654,6 +678,13 @@ int main(int argc, char **argv) {
} else {
playSource(&client, mediaSource);
}
+
+ if (rtspController != NULL) {
+ rtspController->disconnect();
+ rtspController.clear();
+
+ sleep(3);
+ }
}
client.disconnect();