├── .classpath
├── .project
├── .settings
└── org.eclipse.jdt.core.prefs
├── AndroidManifest.xml
├── README.rdoc
├── Thumbs.db
├── bin
├── AndroidManifest.xml
├── bpolloc3_clientStream.apk
├── classes.dex
├── classes
│ └── com
│ │ └── ben
│ │ └── bpolloc3_clientstream
│ │ ├── BuildConfig.class
│ │ ├── MainClientView$1.class
│ │ ├── MainClientView$2.class
│ │ ├── MainClientView.class
│ │ ├── R$attr.class
│ │ ├── R$drawable.class
│ │ ├── R$id.class
│ │ ├── R$layout.class
│ │ ├── R$menu.class
│ │ ├── R$string.class
│ │ ├── R$style.class
│ │ ├── R.class
│ │ ├── Rtp.class
│ │ ├── RtpPacket.class
│ │ └── Rtsp.class
├── dexedLibs
│ ├── android-support-v4-7b74c6badcfc579f28428359cca7c543.jar
│ └── android-support-v4-b91eb43b0bdde54915d8186d6c9578a7.jar
├── jarlist.cache
├── res
│ ├── drawable-hdpi
│ │ └── ic_launcher.png
│ ├── drawable-ldpi
│ │ └── ic_launcher.png
│ ├── drawable-mdpi
│ │ └── ic_launcher.png
│ └── drawable-xhdpi
│ │ └── ic_launcher.png
└── resources.ap_
├── gen
└── com
│ └── ben
│ └── bpolloc3_clientstream
│ ├── BuildConfig.java
│ └── R.java
├── ic_launcher-web.png
├── libs
└── android-support-v4.jar
├── proguard-project.txt
├── project.properties
├── res
├── drawable-hdpi
│ └── ic_launcher.png
├── drawable-ldpi
│ └── ic_launcher.png
├── drawable-mdpi
│ └── ic_launcher.png
├── drawable-xhdpi
│ └── ic_launcher.png
├── layout
│ └── activity_main_client_view.xml
├── menu
│ └── activity_main_client_view.xml
├── values-v11
│ └── styles.xml
├── values-v14
│ └── styles.xml
└── values
│ ├── strings.xml
│ └── styles.xml
└── src
└── com
└── ben
└── bpolloc3_clientstream
├── MainClientView.java
├── Rtp.java
├── RtpPacket.java
└── Rtsp.java
/.classpath:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/.project:
--------------------------------------------------------------------------------
1 |
2 |
3 | bpolloc3_clientStream
4 |
5 |
6 |
7 |
8 |
9 | com.android.ide.eclipse.adt.ResourceManagerBuilder
10 |
11 |
12 |
13 |
14 | com.android.ide.eclipse.adt.PreCompilerBuilder
15 |
16 |
17 |
18 |
19 | org.eclipse.jdt.core.javabuilder
20 |
21 |
22 |
23 |
24 | com.android.ide.eclipse.adt.ApkBuilder
25 |
26 |
27 |
28 |
29 |
30 | com.android.ide.eclipse.adt.AndroidNature
31 | org.eclipse.jdt.core.javanature
32 |
33 |
34 |
--------------------------------------------------------------------------------
/.settings/org.eclipse.jdt.core.prefs:
--------------------------------------------------------------------------------
1 | eclipse.preferences.version=1
2 | org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
3 | org.eclipse.jdt.core.compiler.compliance=1.6
4 | org.eclipse.jdt.core.compiler.source=1.6
5 |
--------------------------------------------------------------------------------
/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
10 |
11 |
13 |
14 |
19 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
--------------------------------------------------------------------------------
/README.rdoc:
--------------------------------------------------------------------------------
1 | == Android RTP Video Streaming Client
2 |
3 | Description
4 |
5 | This android application is designed to stream video. It sends RTSP messages to the server using the user-inputted port number and .mjpeg name. Then, it receives RTP packets over UDP and strips the payload bytes. The bytes are converted into a human-viewable image.
6 |
7 | How To Use
8 |
9 | Ensure the video streamer is installed, and use the Setup/Play/Pause/Teardown buttons to control playback. If running in the android emulator, proper URL redirection must be setup through telnet.
--------------------------------------------------------------------------------
/Thumbs.db:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/BenPollock/AndroidRTPVideoStreamer/d494e1a699d9fc477d7cbbbb822c9b6285c7b43d/Thumbs.db
--------------------------------------------------------------------------------
/bin/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
10 |
11 |
13 |
14 |
19 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
--------------------------------------------------------------------------------
/bin/bpolloc3_clientStream.apk:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/BenPollock/AndroidRTPVideoStreamer/d494e1a699d9fc477d7cbbbb822c9b6285c7b43d/bin/bpolloc3_clientStream.apk
--------------------------------------------------------------------------------
/bin/classes.dex:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/BenPollock/AndroidRTPVideoStreamer/d494e1a699d9fc477d7cbbbb822c9b6285c7b43d/bin/classes.dex
--------------------------------------------------------------------------------
/bin/classes/com/ben/bpolloc3_clientstream/BuildConfig.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/BenPollock/AndroidRTPVideoStreamer/d494e1a699d9fc477d7cbbbb822c9b6285c7b43d/bin/classes/com/ben/bpolloc3_clientstream/BuildConfig.class
--------------------------------------------------------------------------------
/bin/classes/com/ben/bpolloc3_clientstream/MainClientView$1.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/BenPollock/AndroidRTPVideoStreamer/d494e1a699d9fc477d7cbbbb822c9b6285c7b43d/bin/classes/com/ben/bpolloc3_clientstream/MainClientView$1.class
--------------------------------------------------------------------------------
/bin/classes/com/ben/bpolloc3_clientstream/MainClientView$2.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/BenPollock/AndroidRTPVideoStreamer/d494e1a699d9fc477d7cbbbb822c9b6285c7b43d/bin/classes/com/ben/bpolloc3_clientstream/MainClientView$2.class
--------------------------------------------------------------------------------
/bin/classes/com/ben/bpolloc3_clientstream/MainClientView.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/BenPollock/AndroidRTPVideoStreamer/d494e1a699d9fc477d7cbbbb822c9b6285c7b43d/bin/classes/com/ben/bpolloc3_clientstream/MainClientView.class
--------------------------------------------------------------------------------
/bin/classes/com/ben/bpolloc3_clientstream/R$attr.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/BenPollock/AndroidRTPVideoStreamer/d494e1a699d9fc477d7cbbbb822c9b6285c7b43d/bin/classes/com/ben/bpolloc3_clientstream/R$attr.class
--------------------------------------------------------------------------------
/bin/classes/com/ben/bpolloc3_clientstream/R$drawable.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/BenPollock/AndroidRTPVideoStreamer/d494e1a699d9fc477d7cbbbb822c9b6285c7b43d/bin/classes/com/ben/bpolloc3_clientstream/R$drawable.class
--------------------------------------------------------------------------------
/bin/classes/com/ben/bpolloc3_clientstream/R$id.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/BenPollock/AndroidRTPVideoStreamer/d494e1a699d9fc477d7cbbbb822c9b6285c7b43d/bin/classes/com/ben/bpolloc3_clientstream/R$id.class
--------------------------------------------------------------------------------
/bin/classes/com/ben/bpolloc3_clientstream/R$layout.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/BenPollock/AndroidRTPVideoStreamer/d494e1a699d9fc477d7cbbbb822c9b6285c7b43d/bin/classes/com/ben/bpolloc3_clientstream/R$layout.class
--------------------------------------------------------------------------------
/bin/classes/com/ben/bpolloc3_clientstream/R$menu.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/BenPollock/AndroidRTPVideoStreamer/d494e1a699d9fc477d7cbbbb822c9b6285c7b43d/bin/classes/com/ben/bpolloc3_clientstream/R$menu.class
--------------------------------------------------------------------------------
/bin/classes/com/ben/bpolloc3_clientstream/R$string.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/BenPollock/AndroidRTPVideoStreamer/d494e1a699d9fc477d7cbbbb822c9b6285c7b43d/bin/classes/com/ben/bpolloc3_clientstream/R$string.class
--------------------------------------------------------------------------------
/bin/classes/com/ben/bpolloc3_clientstream/R$style.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/BenPollock/AndroidRTPVideoStreamer/d494e1a699d9fc477d7cbbbb822c9b6285c7b43d/bin/classes/com/ben/bpolloc3_clientstream/R$style.class
--------------------------------------------------------------------------------
/bin/classes/com/ben/bpolloc3_clientstream/R.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/BenPollock/AndroidRTPVideoStreamer/d494e1a699d9fc477d7cbbbb822c9b6285c7b43d/bin/classes/com/ben/bpolloc3_clientstream/R.class
--------------------------------------------------------------------------------
/bin/classes/com/ben/bpolloc3_clientstream/Rtp.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/BenPollock/AndroidRTPVideoStreamer/d494e1a699d9fc477d7cbbbb822c9b6285c7b43d/bin/classes/com/ben/bpolloc3_clientstream/Rtp.class
--------------------------------------------------------------------------------
/bin/classes/com/ben/bpolloc3_clientstream/RtpPacket.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/BenPollock/AndroidRTPVideoStreamer/d494e1a699d9fc477d7cbbbb822c9b6285c7b43d/bin/classes/com/ben/bpolloc3_clientstream/RtpPacket.class
--------------------------------------------------------------------------------
/bin/classes/com/ben/bpolloc3_clientstream/Rtsp.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/BenPollock/AndroidRTPVideoStreamer/d494e1a699d9fc477d7cbbbb822c9b6285c7b43d/bin/classes/com/ben/bpolloc3_clientstream/Rtsp.class
--------------------------------------------------------------------------------
/bin/dexedLibs/android-support-v4-7b74c6badcfc579f28428359cca7c543.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/BenPollock/AndroidRTPVideoStreamer/d494e1a699d9fc477d7cbbbb822c9b6285c7b43d/bin/dexedLibs/android-support-v4-7b74c6badcfc579f28428359cca7c543.jar
--------------------------------------------------------------------------------
/bin/dexedLibs/android-support-v4-b91eb43b0bdde54915d8186d6c9578a7.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/BenPollock/AndroidRTPVideoStreamer/d494e1a699d9fc477d7cbbbb822c9b6285c7b43d/bin/dexedLibs/android-support-v4-b91eb43b0bdde54915d8186d6c9578a7.jar
--------------------------------------------------------------------------------
/bin/jarlist.cache:
--------------------------------------------------------------------------------
1 | # cache for current jar dependecy. DO NOT EDIT.
2 | # format is
3 | # Encoding is UTF-8
4 |
--------------------------------------------------------------------------------
/bin/res/drawable-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/BenPollock/AndroidRTPVideoStreamer/d494e1a699d9fc477d7cbbbb822c9b6285c7b43d/bin/res/drawable-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/bin/res/drawable-ldpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/BenPollock/AndroidRTPVideoStreamer/d494e1a699d9fc477d7cbbbb822c9b6285c7b43d/bin/res/drawable-ldpi/ic_launcher.png
--------------------------------------------------------------------------------
/bin/res/drawable-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/BenPollock/AndroidRTPVideoStreamer/d494e1a699d9fc477d7cbbbb822c9b6285c7b43d/bin/res/drawable-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/bin/res/drawable-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/BenPollock/AndroidRTPVideoStreamer/d494e1a699d9fc477d7cbbbb822c9b6285c7b43d/bin/res/drawable-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/bin/resources.ap_:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/BenPollock/AndroidRTPVideoStreamer/d494e1a699d9fc477d7cbbbb822c9b6285c7b43d/bin/resources.ap_
--------------------------------------------------------------------------------
/gen/com/ben/bpolloc3_clientstream/BuildConfig.java:
--------------------------------------------------------------------------------
1 | /** Automatically generated file. DO NOT MODIFY */
2 | package com.ben.bpolloc3_clientstream;
3 |
4 | public final class BuildConfig {
5 | public final static boolean DEBUG = true;
6 | }
--------------------------------------------------------------------------------
/gen/com/ben/bpolloc3_clientstream/R.java:
--------------------------------------------------------------------------------
1 | /* AUTO-GENERATED FILE. DO NOT MODIFY.
2 | *
3 | * This class was automatically generated by the
4 | * aapt tool from the resource data it found. It
5 | * should not be modified by hand.
6 | */
7 |
8 | package com.ben.bpolloc3_clientstream;
9 |
10 | public final class R {
11 | public static final class attr {
12 | }
13 | public static final class drawable {
14 | public static final int ic_launcher=0x7f020000;
15 | }
16 | public static final class id {
17 | public static final int buttonPause=0x7f070003;
18 | public static final int buttonPlay=0x7f070001;
19 | public static final int buttonSetup=0x7f070002;
20 | public static final int buttonTeardown=0x7f070000;
21 | public static final int editIP=0x7f070004;
22 | public static final int editMjpeg=0x7f070006;
23 | public static final int editPort=0x7f070005;
24 | public static final int imageView=0x7f070007;
25 | public static final int menu_settings=0x7f070008;
26 | }
27 | public static final class layout {
28 | public static final int activity_main_client_view=0x7f030000;
29 | }
30 | public static final class menu {
31 | public static final int activity_main_client_view=0x7f060000;
32 | }
33 | public static final class string {
34 | public static final int app_name=0x7f040000;
35 | public static final int hello_world=0x7f040001;
36 | public static final int menu_settings=0x7f040002;
37 | }
38 | public static final class style {
39 | /**
40 | Base application theme, dependent on API level. This theme is replaced
41 | by AppBaseTheme from res/values-vXX/styles.xml on newer devices.
42 |
43 |
44 | Theme customizations available in newer API levels can go in
45 | res/values-vXX/styles.xml, while customizations related to
46 | backward-compatibility can go here.
47 |
48 |
49 | Base application theme for API 11+. This theme completely replaces
50 | AppBaseTheme from res/values/styles.xml on API 11+ devices.
51 |
52 | API 11 theme customizations can go here.
53 |
54 | Base application theme for API 14+. This theme completely replaces
55 | AppBaseTheme from BOTH res/values/styles.xml and
56 | res/values-v11/styles.xml on API 14+ devices.
57 |
58 | API 14 theme customizations can go here.
59 | */
60 | public static final int AppBaseTheme=0x7f050000;
61 | /** Application theme.
62 | All customizations that are NOT specific to a particular API-level can go here.
63 | */
64 | public static final int AppTheme=0x7f050001;
65 | }
66 | }
67 |
--------------------------------------------------------------------------------
/ic_launcher-web.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/BenPollock/AndroidRTPVideoStreamer/d494e1a699d9fc477d7cbbbb822c9b6285c7b43d/ic_launcher-web.png
--------------------------------------------------------------------------------
/libs/android-support-v4.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/BenPollock/AndroidRTPVideoStreamer/d494e1a699d9fc477d7cbbbb822c9b6285c7b43d/libs/android-support-v4.jar
--------------------------------------------------------------------------------
/proguard-project.txt:
--------------------------------------------------------------------------------
1 | # To enable ProGuard in your project, edit project.properties
2 | # to define the proguard.config property as described in that file.
3 | #
4 | # Add project specific ProGuard rules here.
5 | # By default, the flags in this file are appended to flags specified
6 | # in ${sdk.dir}/tools/proguard/proguard-android.txt
7 | # You can edit the include path and order by changing the ProGuard
8 | # include property in project.properties.
9 | #
10 | # For more details, see
11 | # http://developer.android.com/guide/developing/tools/proguard.html
12 |
13 | # Add any project specific keep options here:
14 |
15 | # If your project uses WebView with JS, uncomment the following
16 | # and specify the fully qualified class name to the JavaScript interface
17 | # class:
18 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
19 | # public *;
20 | #}
21 |
--------------------------------------------------------------------------------
/project.properties:
--------------------------------------------------------------------------------
1 | # This file is automatically generated by Android Tools.
2 | # Do not modify this file -- YOUR CHANGES WILL BE ERASED!
3 | #
4 | # This file must be checked in Version Control Systems.
5 | #
6 | # To customize properties used by the Ant build system edit
7 | # "ant.properties", and override values to adapt the script to your
8 | # project structure.
9 | #
10 | # To enable ProGuard to shrink and obfuscate your code, uncomment this (available properties: sdk.dir, user.home):
11 | #proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt
12 |
13 | # Project target.
14 | target=android-17
15 |
--------------------------------------------------------------------------------
/res/drawable-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/BenPollock/AndroidRTPVideoStreamer/d494e1a699d9fc477d7cbbbb822c9b6285c7b43d/res/drawable-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/res/drawable-ldpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/BenPollock/AndroidRTPVideoStreamer/d494e1a699d9fc477d7cbbbb822c9b6285c7b43d/res/drawable-ldpi/ic_launcher.png
--------------------------------------------------------------------------------
/res/drawable-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/BenPollock/AndroidRTPVideoStreamer/d494e1a699d9fc477d7cbbbb822c9b6285c7b43d/res/drawable-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/res/drawable-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/BenPollock/AndroidRTPVideoStreamer/d494e1a699d9fc477d7cbbbb822c9b6285c7b43d/res/drawable-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/res/layout/activity_main_client_view.xml:
--------------------------------------------------------------------------------
1 |
6 |
7 |
16 |
17 |
26 |
27 |
36 |
37 |
45 |
46 |
55 |
56 |
57 |
58 |
59 |
69 |
70 |
79 |
80 |
89 |
90 |
91 |
--------------------------------------------------------------------------------
/res/menu/activity_main_client_view.xml:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/res/values-v11/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
7 |
10 |
11 |
--------------------------------------------------------------------------------
/res/values-v14/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
8 |
11 |
12 |
--------------------------------------------------------------------------------
/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | bpolloc3_clientStream
5 | Hello world!
6 | Settings
7 |
8 |
--------------------------------------------------------------------------------
/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
7 |
14 |
15 |
16 |
19 |
20 |
--------------------------------------------------------------------------------
/src/com/ben/bpolloc3_clientstream/MainClientView.java:
--------------------------------------------------------------------------------
1 | package com.ben.bpolloc3_clientstream;
2 |
3 | import java.util.Timer;
4 | import java.util.TimerTask;
5 |
6 | import android.os.Bundle;
7 | import android.os.StrictMode;
8 | import android.app.Activity;
9 | import android.graphics.Bitmap;
10 | import android.graphics.BitmapFactory;
11 | import android.view.Menu;
12 | import android.view.View;
13 | import android.view.inputmethod.InputMethodManager;
14 | import android.widget.EditText;
15 | import android.widget.ImageView;
16 |
17 | public class MainClientView extends Activity {
18 |
19 | StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build();
20 |
21 | public Rtsp RTSP;
22 | public String state; //START->READY->PLAY/PAUSE/TEAR
23 | public Timer timer;
24 | public Rtp RTP;
25 |
26 | @Override
27 | protected void onCreate(Bundle savedInstanceState) {
28 | super.onCreate(savedInstanceState);
29 | setContentView(R.layout.activity_main_client_view);
30 | StrictMode.setThreadPolicy(policy);
31 | state = "START";
32 | timer = new Timer();
33 | }
34 |
35 | @Override
36 | public boolean onCreateOptionsMenu(Menu menu) {
37 | // Inflate the menu; this adds items to the action bar if it is present.
38 | getMenuInflater().inflate(R.menu.activity_main_client_view, menu);
39 | return true;
40 | }
41 |
42 | public void setup(View view){
43 |
44 | //Send Setup Message
45 | try{
46 | if(state.equals("START")){
47 | System.out.println("Setup");
48 |
49 | //Get the variables
50 | String movie_file = ((EditText)findViewById(R.id.editMjpeg)).getText().toString();
51 | String ip_addr = ((EditText)findViewById(R.id.editIP)).getText().toString();
52 | String string_port = ((EditText)findViewById(R.id.editPort)).getText().toString();
53 | int port = Integer.parseInt(string_port);
54 |
55 | //Create RTSP and call setup
56 | RTSP = new Rtsp(movie_file,ip_addr,port);
57 | if(RTSP.setup()){
58 | state = "READY";
59 | RTP = new Rtp(port);
60 | System.out.println("State is now ready");
61 | }
62 | }
63 | }catch(Exception e){
64 | System.out.println(e);
65 | }
66 |
67 | }
68 |
69 | public void play(View view){
70 | if(state.equals("READY")){
71 | try{
72 | //Call Play
73 | if(RTSP.play()){
74 | state = "PLAY";
75 | System.out.println("Now Playing");
76 |
77 | //Init Timer
78 | timer.schedule(new TimerTask(){
79 | @Override
80 | public void run(){
81 | TimerTick();
82 | }
83 | }, 0,60);
84 | }
85 | }catch(Exception e){
86 | System.out.println(e);
87 | }
88 | }
89 |
90 | //If paused, notify the timer to run
91 | if(state.equals("PAUSE")){
92 | try{
93 | if(RTSP.play()){
94 | state = "PLAY";
95 | System.out.println("Video Unpaused");
96 |
97 | //Notify timer
98 | timer.notify();
99 | }
100 | }catch(Exception e){
101 | System.out.println(e);
102 | }
103 | }
104 |
105 |
106 | }
107 |
108 | public void pause(View view){
109 | if(state.equals("PLAY")){
110 | try{
111 | //Call Pause
112 | if(RTSP.pause()){
113 | state = "PAUSE";
114 | System.out.println("Video Paused");
115 |
116 | //Stop Timer
117 | timer.wait();
118 | }
119 | }catch(Exception e){
120 | System.out.println(e);
121 | }
122 | }
123 | }
124 |
125 | public void teardown(View view){
126 | if(state.equals("PLAY") || state.equals("PAUSE") || state.equals("READY")){
127 | try{
128 | //Call teardown
129 | if(RTSP.teardown()){
130 | state = "START";
131 | RTP.destroySocket();
132 | //Destroy timer
133 | timer.wait();
134 | }
135 | }catch(Exception e){
136 | System.out.println(e);
137 | }
138 | }
139 |
140 | }
141 |
142 | //Hides the keyboard
143 | public void hideKeyboard(View view){
144 | InputMethodManager inputMethodManager = (InputMethodManager) this.getSystemService(Activity.INPUT_METHOD_SERVICE);
145 | inputMethodManager.hideSoftInputFromWindow(this.getCurrentFocus().getWindowToken(), 0);
146 | }
147 |
148 | //Called when the timer goes off
149 | private void TimerTick(){
150 |
151 | //RTP should handle this stuff
152 | runOnUiThread(new Runnable(){
153 | public void run(){
154 | Bitmap bmp = RTP.timerEvent();
155 | if(bmp != null){
156 | try{
157 | ImageView image = (ImageView)findViewById(R.id.imageView);
158 | image.setImageBitmap(bmp);
159 | }catch(Exception e){
160 | System.out.println(e);
161 | }
162 | }
163 | }
164 | });
165 |
166 | }
167 |
168 | }
169 |
--------------------------------------------------------------------------------
/src/com/ben/bpolloc3_clientstream/Rtp.java:
--------------------------------------------------------------------------------
1 | package com.ben.bpolloc3_clientstream;
2 |
3 | import java.net.DatagramPacket;
4 | import java.net.DatagramSocket;
5 |
6 | import android.graphics.Bitmap;
7 | import android.os.StrictMode;
8 |
9 | public class Rtp {
10 | StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build();
11 | //Each Rtp instance should have a packet
12 | //Previous packets will be overwritten by the current packet
13 | RtpPacket rtp_packet;
14 | private byte[] buf;
15 | private DatagramSocket socket;
16 | private int port;
17 | private DatagramPacket receive_packet;
18 | private int plength;
19 | private int largestFrame;
20 | private boolean finished;
21 |
22 | //Constructor
23 | public Rtp(int port){
24 | buf = new byte[15000];
25 | this.port = port;
26 | largestFrame = 0;
27 |
28 | try{
29 | socket = new DatagramSocket(25000);
30 | socket.setSoTimeout(10);
31 | }catch(Exception e){
32 | System.out.println("Error Creating Socket: " + e);
33 | finished = false;
34 | }
35 | }
36 |
37 | //Get the next video frame
38 | public Bitmap timerEvent(){
39 | finished = false;
40 |
41 | //Create packet
42 | receive_packet = new DatagramPacket(buf, buf.length);
43 |
44 | try{
45 | //Receive packet
46 | socket.receive(receive_packet);
47 | rtp_packet = new RtpPacket(receive_packet.getData(), receive_packet.getLength());
48 | Bitmap bmp = rtp_packet.getBmp();
49 |
50 | //Commented out now that we're getting BMP in packet
51 | //Get payload
52 | /*plength = rtp_packet.getLength();
53 | if(plength>largestFrame){
54 | largestFrame = plength;
55 | System.out.println("The Largest Frame is: " + largestFrame);
56 | }
57 | byte[] payload = new byte[plength];
58 | for(int i = 0; i < plength; i++){
59 | payload[i] = rtp_packet.getPayload()[i];
60 | }*/
61 |
62 | System.out.println("Got Payload!!!!!");
63 | return bmp;
64 |
65 | }
66 | //Sometimes the socket won't be made correctly if the user puts in an incorrect IP
67 | catch(java.lang.NullPointerException en){
68 | try{
69 | socket = new DatagramSocket(25000);
70 | socket.setSoTimeout(10);
71 | }catch(Exception e){
72 | System.out.println("Error Creating Socket Again!");
73 | }
74 | return null;
75 | }
76 | catch(java.net.BindException be){
77 | System.out.println("UH oh, bind exception");
78 | return null;
79 | }
80 | catch(java.net.SocketTimeoutException se){
81 | System.out.println("Reached end of video, teardown");
82 | finished = true;
83 | return null;
84 | }
85 | catch(Exception e){
86 | System.out.println("Error with UDP, Packet Dropped");
87 | System.out.println(e);
88 | return null;
89 | }
90 |
91 | }
92 |
93 | public int getPlength(){
94 | return plength;
95 | }
96 |
97 | public void destroySocket(){
98 | socket.close();
99 | }
100 | public boolean getFinished(){
101 | return finished;
102 | }
103 |
104 |
105 |
106 |
107 | }
108 |
--------------------------------------------------------------------------------
/src/com/ben/bpolloc3_clientstream/RtpPacket.java:
--------------------------------------------------------------------------------
1 | package com.ben.bpolloc3_clientstream;
2 |
3 | import java.util.Date;
4 |
5 | import android.graphics.Bitmap;
6 | import android.graphics.BitmapFactory;
7 |
8 | public class RtpPacket {
9 | private Bitmap bmp;
10 |
11 | private byte[] header;
12 | private byte[] payload;
13 |
14 |
15 | //Constructor
16 | public RtpPacket(){
17 |
18 | }
19 |
20 | //Special Constructor for received packets
21 | public RtpPacket(byte[] packet, int size){
22 |
23 | //This is commented out because the bmp line removes the need for it
24 | /*
25 | //Load header
26 | header = new byte[12];
27 | for(int i = 0; i < 12; i++)
28 | header[i] = packet[i];
29 |
30 | //Load payload
31 | int payload_length = size - 12;
32 | payload = new byte[payload_length];
33 | for (int i = 12; i < payload_length; i++)
34 | payload[i-12] = packet[i];
35 | */
36 |
37 | bmp = BitmapFactory.decodeByteArray(packet, 12, packet.length - 12);
38 | }
39 |
40 | public void initPacket(String server_message){
41 |
42 | }
43 |
44 | public byte[] getPayload(){
45 | return payload;
46 | }
47 |
48 | public int getLength(){
49 | return payload.length;
50 | }
51 |
52 | public Bitmap getBmp(){
53 | return bmp;
54 | }
55 |
56 | }
57 |
--------------------------------------------------------------------------------
/src/com/ben/bpolloc3_clientstream/Rtsp.java:
--------------------------------------------------------------------------------
1 | package com.ben.bpolloc3_clientstream;
2 |
3 | import java.net.*;
4 | import java.util.StringTokenizer;
5 | import java.io.*;
6 |
7 | import android.os.StrictMode;
8 |
9 | public class Rtsp {
10 |
11 |
12 | private String movie_file;
13 | private String ip_addr;
14 | private int port;
15 | private int c_seq;
16 | private int session;
17 | private int id; //The RTSP ID given by the server
18 | private BufferedReader RTSPBufferedReader;
19 | private BufferedWriter RTSPBufferedWriter;
20 | private InetAddress addr;
21 |
22 | private Socket rtsp_socket;
23 |
24 | //Constructor
25 | public Rtsp(String movie_file, String ip_addr, int port) throws IOException{
26 | this.movie_file = movie_file;
27 | this.ip_addr = ip_addr;
28 | this.port = port;
29 | this.c_seq = 1;
30 | this.id = 0;
31 | //Session given from setup
32 | this.session = 0;
33 | this.addr = InetAddress.getByName(ip_addr);
34 |
35 | //Create RTSP Socket
36 | this.rtsp_socket = new Socket(ip_addr,port);
37 | //Create RTSP Writers/Readers
38 | RTSPBufferedReader = new BufferedReader(new InputStreamReader(rtsp_socket.getInputStream()) );
39 | RTSPBufferedWriter = new BufferedWriter(new OutputStreamWriter(rtsp_socket.getOutputStream()) );
40 | }
41 |
42 | //SETUP
43 | public boolean setup(){
44 |
45 | //Create RTSP Message
46 | String rtsp_setup = "SETUP rtsp://" + ip_addr + ":" + port + "/" + movie_file + " RTSP/1.0" + "\nCSeq: " + c_seq +"\n"+"Transport: RTP/UDP; client_port= " + 25000;
47 | c_seq++;
48 |
49 | //Create & Send Packet
50 | try{
51 | RTSPBufferedWriter.write(rtsp_setup);
52 | RTSPBufferedWriter.flush();
53 | }catch(Exception e){
54 | return false;
55 | }
56 |
57 | //Receive response
58 | if(getRTSPResponse() == 200)
59 | return true;
60 | else
61 | return false;
62 | }
63 |
64 | public boolean play(){
65 | //Create RTSP Message
66 | String rtsp_play = "PLAY rtsp://" + ip_addr + ":" + port + "/" + movie_file + " RTSP/1.0" + "\nCSeq: " + c_seq +"\n"+"Session: " + id;
67 | c_seq++;
68 |
69 | //Create & Send Packet
70 | try{
71 | RTSPBufferedWriter.write(rtsp_play);
72 | RTSPBufferedWriter.flush();
73 | }catch(Exception e){
74 | return false;
75 | }
76 |
77 | //Receive Response
78 | if(getRTSPResponse()==200)
79 | return true;
80 | else
81 | return false;
82 | }
83 |
84 | public boolean pause(){
85 | //Create RTSP Message
86 | String rtsp_pause = "PAUSE rtsp://" + ip_addr + ":" + port + "/" + movie_file + " RTSP/1.0" + "\nCSeq: " + c_seq +"\n"+"Session: " + id;
87 | c_seq++;
88 |
89 | //Create and send packet
90 | try{
91 | RTSPBufferedWriter.write(rtsp_pause);
92 | RTSPBufferedWriter.flush();
93 | }catch(Exception e){
94 | return false;
95 | }
96 |
97 | //Receive Response
98 | if(getRTSPResponse() == 200)
99 | return true;
100 | else
101 | return false;
102 | }
103 |
104 | public boolean teardown(){
105 | //Create RTSP Message
106 | String rtsp_teardown = "TEARDOWN rtsp://" + ip_addr + ":" + port + "/" + movie_file + " RTSP/1.0" + "\nCSeq: " + c_seq +"\n"+"Session: " + id;
107 | c_seq++;
108 |
109 | //Create and send packet
110 | try{
111 | RTSPBufferedWriter.write(rtsp_teardown);
112 | RTSPBufferedWriter.flush();
113 | }catch(Exception e){
114 | return false;
115 | }
116 |
117 | //Receive Response
118 | if(getRTSPResponse() == 200)
119 | return true;
120 | else
121 | return false;
122 | }
123 |
124 |
125 |
126 | //Gets the return code
127 | private int getRTSPResponse(){
128 | int reply = 0;
129 | try{
130 | //Get Response
131 | String status = RTSPBufferedReader.readLine();
132 | StringTokenizer tokens = new StringTokenizer(status);
133 | tokens.nextToken();
134 | reply = Integer.parseInt(tokens.nextToken());
135 | }catch(Exception e){
136 | reply = -1;
137 | }
138 |
139 | //Parse the response to get ID
140 | try{
141 | String seq = RTSPBufferedReader.readLine();
142 | String session = RTSPBufferedReader.readLine();
143 | StringTokenizer tokens = new StringTokenizer(session);
144 | tokens.nextToken();
145 | id = Integer.parseInt(tokens.nextToken());
146 | }catch(Exception e){
147 | reply = -1;
148 | }
149 |
150 | return reply;
151 | }
152 |
153 |
154 |
155 | //Getters and Setters
156 | public String getMovie_file(){
157 | return movie_file;
158 | }
159 | public void setMovie_file(String movie_file){
160 | this.movie_file = movie_file;
161 | }
162 |
163 | public String getIp_addr(){
164 | return ip_addr;
165 | }
166 | public void setIp_addr(String ip_addr){
167 | this.ip_addr = ip_addr;
168 | }
169 |
170 | public int getPort(){
171 | return port;
172 | }
173 | public void setPort(int port){
174 | this.port = port;
175 | }
176 |
177 |
178 |
179 |
180 | }
181 |
--------------------------------------------------------------------------------