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
commit4e4173b0af52bdf2b5730a5837476e400c5b2040 (patch)
tree8646f0b4c4783b9c14aac8868749856029b5b2a3 /cmds
parentff0ab64ca49c7a03835d414cd493d5dc37c2eb5e (diff)
downloadframeworks_base-4e4173b0af52bdf2b5730a5837476e400c5b2040.zip
frameworks_base-4e4173b0af52bdf2b5730a5837476e400c5b2040.tar.gz
frameworks_base-4e4173b0af52bdf2b5730a5837476e400c5b2040.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();