├── .gitignore ├── ONVIF_Protocol.md ├── README.md ├── app ├── app.iml ├── build.gradle ├── libs │ ├── acra-4.4.0.jar │ ├── sc-light-jdk15on-1.47.0.2.jar │ ├── scpkix-jdk15on-1.47.0.2.jar │ └── scprov-jdk15on-1.47.0.2.jar ├── lint.xml ├── proguard-project.txt └── src │ └── main │ ├── AndroidManifest.xml │ ├── assets │ ├── wsdl │ │ ├── device_service.wsdl │ │ ├── docs.oasis-open.org.wsn.b-2.xsd │ │ ├── docs.oasis-open.org.wsn.t-1.xsd │ │ ├── docs.oasis-open.org.wsrf.bf-2.xsd │ │ ├── imaging_service.wsdl │ │ ├── media2_service.wsdl │ │ ├── media_service.wsdl │ │ ├── ptz_service.wsdl │ │ ├── www.onvif.org.ver10.device.wsdl │ │ ├── www.onvif.org.ver10.media.wsdl │ │ ├── www.onvif.org.ver10.schema.xsd │ │ ├── www.onvif.org.ver20.imaging.wsdl │ │ ├── www.onvif.org.ver20.media.wsdl │ │ ├── www.onvif.org.ver20.ptz.wsdl │ │ ├── www.w3.org.2001.xml.xsd │ │ ├── www.w3.org.2003.05.soap-envelope.xsd │ │ ├── www.w3.org.2004.08.xop.include.xsd │ │ ├── www.w3.org.2005.05.xmlmime.xsd │ │ └── www.w3.org.2005.08.addressing.ws-addr.xsd │ └── www │ │ ├── credits.htm │ │ ├── fonts │ │ ├── bangers.eot │ │ ├── bangers.woff │ │ ├── sunshiney.eot │ │ └── sunshiney.woff │ │ ├── images │ │ ├── blue-button.png │ │ ├── camera.png │ │ ├── eye.png │ │ ├── facebook.png │ │ ├── install.jpg │ │ ├── lamp.png │ │ ├── phone.png │ │ ├── quote.png │ │ ├── red-button.png │ │ ├── speaker.png │ │ └── spydroid.png │ │ ├── index.htm │ │ ├── js │ │ ├── ie.js │ │ ├── jquery-1.9.1.min.js │ │ ├── less-1.2.2.min.js │ │ ├── translations.js │ │ └── ui.js │ │ ├── less │ │ ├── #vlc.less# │ │ ├── accordion.less │ │ ├── base.less │ │ ├── fonts.less │ │ ├── ie.less │ │ ├── index.htm │ │ ├── mixins.less │ │ ├── styles.css │ │ ├── styles.less │ │ └── vlc.less │ │ └── tests │ │ └── test1.htm │ ├── java │ └── net │ │ └── majorkernelpanic │ │ ├── http │ │ ├── ModAssetServer.java │ │ ├── ModInternationalization.java │ │ ├── ModOnvifServer.java │ │ ├── ModSSL.java │ │ └── TinyHttpServer.java │ │ ├── onvif │ │ ├── DeviceBackBean.java │ │ ├── DeviceStaticInfo.java │ │ ├── ONVIFDevDiscoveryReqHeader.java │ │ ├── ONVIFPacketHandler.java │ │ ├── SimpleONVIFManager.java │ │ └── network │ │ │ └── ONVIFHttpServer.java │ │ ├── spydroid │ │ ├── SpydroidApplication.java │ │ ├── Utilities.java │ │ ├── api │ │ │ ├── CustomHttpServer.java │ │ │ ├── CustomRtspServer.java │ │ │ └── RequestHandler.java │ │ └── ui │ │ │ ├── AboutFragment.java │ │ │ ├── HandsetFragment.java │ │ │ ├── OptionsActivity.java │ │ │ ├── PreviewFragment.java │ │ │ ├── SpydroidActivity.java │ │ │ └── TabletFragment.java │ │ └── streaming │ │ ├── MediaStream.java │ │ ├── Session.java │ │ ├── SessionBuilder.java │ │ ├── Stream.java │ │ ├── audio │ │ ├── AACStream.java │ │ ├── AMRNBStream.java │ │ ├── AudioQuality.java │ │ └── AudioStream.java │ │ ├── exceptions │ │ ├── CameraInUseException.java │ │ ├── ConfNotSupportedException.java │ │ ├── InvalidSurfaceException.java │ │ └── StorageUnavailableException.java │ │ ├── gl │ │ ├── SurfaceManager.java │ │ ├── SurfaceView.java │ │ └── TextureManager.java │ │ ├── hw │ │ ├── CodecManager.java │ │ ├── EncoderDebugger.java │ │ └── NV21Convertor.java │ │ ├── mp4 │ │ ├── MP4Config.java │ │ └── MP4Parser.java │ │ ├── rtcp │ │ └── SenderReport.java │ │ ├── rtp │ │ ├── AACADTSPacketizer.java │ │ ├── AACLATMPacketizer.java │ │ ├── AMRNBPacketizer.java │ │ ├── AbstractPacketizer.java │ │ ├── H263Packetizer.java │ │ ├── H264Packetizer.java │ │ ├── MediaCodecInputStream.java │ │ └── RtpSocket.java │ │ ├── rtsp │ │ ├── RtspClient.java │ │ ├── RtspServer.java │ │ └── UriParser.java │ │ └── video │ │ ├── CodecManager.java │ │ ├── H263Stream.java │ │ ├── H264Stream.java │ │ ├── VideoQuality.java │ │ └── VideoStream.java │ └── res │ ├── anim │ └── pulse.xml │ ├── drawable-hdpi │ ├── background.png │ ├── check.png │ ├── icon.png │ ├── quit.png │ └── settings.png │ ├── drawable-ldpi │ ├── icon.png │ ├── quit.png │ └── settings.png │ ├── drawable-mdpi │ ├── icon.png │ ├── quit.png │ └── settings.png │ ├── drawable │ └── preview.xml │ ├── layout-sw600dp │ ├── preview.xml │ ├── spydroid.xml │ └── tablet.xml │ ├── layout │ ├── about.xml │ ├── main.xml │ ├── preview.xml │ ├── spydroid.xml │ └── tablet.xml │ ├── menu │ └── menu.xml │ ├── raw │ ├── animals_cat.mp3 │ ├── animals_dog.mp3 │ ├── funny_fart.mp3 │ ├── funny_fart2.mp3 │ ├── funny_snoring.mp3 │ ├── scary_breath.mp3 │ ├── scary_evil_laughter.mp3 │ ├── scary_horror.mp3 │ ├── scary_insane_laughter.mp3 │ ├── scary_long_growl.mp3 │ ├── scary_thunder.mp3 │ ├── war_explosion.mp3 │ └── war_gunshot.mp3 │ ├── values-de │ └── strings.xml │ ├── values-fr │ └── strings.xml │ ├── values-ru │ └── strings.xml │ ├── values │ ├── arrays.xml │ └── strings.xml │ └── xml │ └── preferences.xml ├── build.gradle ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── import-summary.txt ├── ipcamerafinder ├── .gitignore ├── README.md ├── build.gradle ├── ipcamerafinder.iml ├── proguard-rules.pro └── src │ ├── androidTest │ └── java │ │ └── org │ │ └── onvif │ │ └── ipcamera_finder │ │ └── ExampleInstrumentedTest.java │ ├── main │ ├── AndroidManifest.xml │ ├── java │ │ └── org │ │ │ └── onvif │ │ │ └── ipcamera_finder │ │ │ └── MainActivity.java │ └── res │ │ ├── drawable-v24 │ │ └── ic_launcher_foreground.xml │ │ ├── drawable │ │ └── ic_launcher_background.xml │ │ ├── layout │ │ └── activity_main.xml │ │ ├── mipmap-anydpi-v26 │ │ ├── ic_launcher.xml │ │ └── ic_launcher_round.xml │ │ ├── mipmap-hdpi │ │ ├── ic_launcher.png │ │ └── ic_launcher_round.png │ │ ├── mipmap-mdpi │ │ ├── ic_launcher.png │ │ └── ic_launcher_round.png │ │ ├── mipmap-xhdpi │ │ ├── ic_launcher.png │ │ └── ic_launcher_round.png │ │ ├── mipmap-xxhdpi │ │ ├── ic_launcher.png │ │ └── ic_launcher_round.png │ │ ├── mipmap-xxxhdpi │ │ ├── ic_launcher.png │ │ └── ic_launcher_round.png │ │ └── values │ │ ├── colors.xml │ │ ├── strings.xml │ │ └── styles.xml │ └── test │ └── java │ └── org │ └── onvif │ └── ipcamera_finder │ └── ExampleUnitTest.java ├── local.properties ├── sample_get_profile_request_packet.xml ├── sample_get_profile_response_packet.xml ├── sample_probe_packet.xml └── settings.gradle /.gitignore: -------------------------------------------------------------------------------- 1 | .gradle/ 2 | .idea/ 3 | spydroid-ipcamera.iml 4 | app/build/ 5 | ipcamerafinder/build/ -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ## 关于`ONVIF-SpyDroid-Camera` 2 | 3 | 这里是将`Android`设备实现成`ONVIF`协议的`server`. 4 | 5 | 可以通过[ONVIF-Camera](https://github.com/yashrs/ONVIF-Camera.git)工程来验证`ONVIF-SpyDroid-Camera` 6 | 是否工作正常。 7 | 如果通过[ONVIF-Camera](https://github.com/yashrs/ONVIF-Camera.git)可以连接到`ONVIF-SpyDroid-Camera` 8 | 的话,就代表`Discovery`协议是可以工作。 9 | 10 | > 目前[ONVIF-Camera](https://github.com/yashrs/ONVIF-Camera.git)有一些问题,就是拉取到`RTSP`流之后播放有问题
,只可以播放一帧,应该是视频格式不支持。但是通过`ffplay`是可以播放`ONVIF-SpyDroid-Camera`的`RTSP`视频流的. 11 | 12 | 13 | -------------------------------------------------------------- 14 | 15 | -------------------------------------------------------------------------------- /app/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.application' 2 | 3 | android { 4 | compileSdkVersion 19 5 | buildToolsVersion '28.0.3' 6 | 7 | defaultConfig { 8 | applicationId "net.majorkernelpanic.spydroid" 9 | minSdkVersion 14 10 | targetSdkVersion 19 11 | } 12 | 13 | buildTypes { 14 | release { 15 | minifyEnabled true 16 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-project.txt' 17 | } 18 | } 19 | compileOptions { 20 | sourceCompatibility = '1.7' 21 | targetCompatibility = '1.7' 22 | } 23 | } 24 | 25 | dependencies { 26 | compile 'com.android.support:support-v4:19.1.0' 27 | compile files('libs/acra-4.4.0.jar') 28 | compile files('libs/sc-light-jdk15on-1.47.0.2.jar') 29 | compile files('libs/scpkix-jdk15on-1.47.0.2.jar') 30 | compile files('libs/scprov-jdk15on-1.47.0.2.jar') 31 | } 32 | -------------------------------------------------------------------------------- /app/libs/acra-4.4.0.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/extinguish/onvif-camera/47445b42823d3b96670413ead36a37505d0e8b7d/app/libs/acra-4.4.0.jar -------------------------------------------------------------------------------- /app/libs/sc-light-jdk15on-1.47.0.2.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/extinguish/onvif-camera/47445b42823d3b96670413ead36a37505d0e8b7d/app/libs/sc-light-jdk15on-1.47.0.2.jar -------------------------------------------------------------------------------- /app/libs/scpkix-jdk15on-1.47.0.2.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/extinguish/onvif-camera/47445b42823d3b96670413ead36a37505d0e8b7d/app/libs/scpkix-jdk15on-1.47.0.2.jar -------------------------------------------------------------------------------- /app/libs/scprov-jdk15on-1.47.0.2.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/extinguish/onvif-camera/47445b42823d3b96670413ead36a37505d0e8b7d/app/libs/scprov-jdk15on-1.47.0.2.jar -------------------------------------------------------------------------------- /app/lint.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /app/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 | 22 | 23 | -dontwarn org.spongycastle.x509.util.LDAPStoreHelper 24 | -dontwarn org.spongycastle.jce.provider.X509LDAPCertStoreSpi 25 | 26 | -keep public class net.majorkernelpanic.http.* { 27 | *; 28 | } 29 | 30 | -keepclassmembers class **.R$* { 31 | public static ; 32 | } 33 | 34 | -keep class **.R$* 35 | 36 | -keep public class org.spongycastle.jcajce.provider.** { 37 | *; 38 | } 39 | 40 | -keep public class org.spongycastle.jce.provider.JCEBlockCipher$PBEWithSHAAndTwofish { 41 | *; 42 | } 43 | 44 | -keep public class org.spongycastle.jce.provider.JCESecretKeyFactory$PBEWithSHAAndDES3Key { 45 | *; 46 | } 47 | 48 | -keep public class org.spongycastle.jce.provider.JCESecretKeyFactory$PBEWithSHAAndTwofish { 49 | *; 50 | } 51 | -------------------------------------------------------------------------------- /app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 29 | 30 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | -------------------------------------------------------------------------------- /app/src/main/assets/wsdl/device_service.wsdl: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /app/src/main/assets/wsdl/docs.oasis-open.org.wsrf.bf-2.xsd: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | Get access to the xml: attribute groups for xml:lang as declared on 'schema' 8 | and 'documentation' below 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | -------------------------------------------------------------------------------- /app/src/main/assets/wsdl/imaging_service.wsdl: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /app/src/main/assets/wsdl/media2_service.wsdl: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /app/src/main/assets/wsdl/media_service.wsdl: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /app/src/main/assets/wsdl/ptz_service.wsdl: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /app/src/main/assets/wsdl/www.w3.org.2003.05.soap-envelope.xsd: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | Elements replacing the wildcard MUST be namespace qualified, but can be in the targetNamespace 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | Fault reporting structure 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | -------------------------------------------------------------------------------- /app/src/main/assets/wsdl/www.w3.org.2004.08.xop.include.xsd: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /app/src/main/assets/wsdl/www.w3.org.2005.05.xmlmime.xsd: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /app/src/main/assets/wsdl/www.w3.org.2005.08.addressing.ws-addr.xsd: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | -------------------------------------------------------------------------------- /app/src/main/assets/www/credits.htm: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | Spydroid 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 20 | 21 | 22 | 23 | 24 | 25 | 26 |
27 | 36 | 37 |
38 | 39 |
40 | Spydroid 41 | A famous quote ! 42 |
43 | 44 |
Return
45 | 46 |
47 |
48 |
49 |
50 | 51 | 52 | 53 |
54 | 55 |

Here is a list of all medias used in Spydroid with the name of their author !

56 | 57 |
58 |

Sounds were found on freesound.org

59 |
60 |
61 | 69 |
70 |
71 | 79 |
80 |
81 |
82 | 83 | 89 | 90 |
91 | 92 | 93 | 94 | 95 | -------------------------------------------------------------------------------- /app/src/main/assets/www/fonts/bangers.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/extinguish/onvif-camera/47445b42823d3b96670413ead36a37505d0e8b7d/app/src/main/assets/www/fonts/bangers.eot -------------------------------------------------------------------------------- /app/src/main/assets/www/fonts/bangers.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/extinguish/onvif-camera/47445b42823d3b96670413ead36a37505d0e8b7d/app/src/main/assets/www/fonts/bangers.woff -------------------------------------------------------------------------------- /app/src/main/assets/www/fonts/sunshiney.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/extinguish/onvif-camera/47445b42823d3b96670413ead36a37505d0e8b7d/app/src/main/assets/www/fonts/sunshiney.eot -------------------------------------------------------------------------------- /app/src/main/assets/www/fonts/sunshiney.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/extinguish/onvif-camera/47445b42823d3b96670413ead36a37505d0e8b7d/app/src/main/assets/www/fonts/sunshiney.woff -------------------------------------------------------------------------------- /app/src/main/assets/www/images/blue-button.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/extinguish/onvif-camera/47445b42823d3b96670413ead36a37505d0e8b7d/app/src/main/assets/www/images/blue-button.png -------------------------------------------------------------------------------- /app/src/main/assets/www/images/camera.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/extinguish/onvif-camera/47445b42823d3b96670413ead36a37505d0e8b7d/app/src/main/assets/www/images/camera.png -------------------------------------------------------------------------------- /app/src/main/assets/www/images/eye.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/extinguish/onvif-camera/47445b42823d3b96670413ead36a37505d0e8b7d/app/src/main/assets/www/images/eye.png -------------------------------------------------------------------------------- /app/src/main/assets/www/images/facebook.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/extinguish/onvif-camera/47445b42823d3b96670413ead36a37505d0e8b7d/app/src/main/assets/www/images/facebook.png -------------------------------------------------------------------------------- /app/src/main/assets/www/images/install.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/extinguish/onvif-camera/47445b42823d3b96670413ead36a37505d0e8b7d/app/src/main/assets/www/images/install.jpg -------------------------------------------------------------------------------- /app/src/main/assets/www/images/lamp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/extinguish/onvif-camera/47445b42823d3b96670413ead36a37505d0e8b7d/app/src/main/assets/www/images/lamp.png -------------------------------------------------------------------------------- /app/src/main/assets/www/images/phone.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/extinguish/onvif-camera/47445b42823d3b96670413ead36a37505d0e8b7d/app/src/main/assets/www/images/phone.png -------------------------------------------------------------------------------- /app/src/main/assets/www/images/quote.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/extinguish/onvif-camera/47445b42823d3b96670413ead36a37505d0e8b7d/app/src/main/assets/www/images/quote.png -------------------------------------------------------------------------------- /app/src/main/assets/www/images/red-button.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/extinguish/onvif-camera/47445b42823d3b96670413ead36a37505d0e8b7d/app/src/main/assets/www/images/red-button.png -------------------------------------------------------------------------------- /app/src/main/assets/www/images/speaker.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/extinguish/onvif-camera/47445b42823d3b96670413ead36a37505d0e8b7d/app/src/main/assets/www/images/speaker.png -------------------------------------------------------------------------------- /app/src/main/assets/www/images/spydroid.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/extinguish/onvif-camera/47445b42823d3b96670413ead36a37505d0e8b7d/app/src/main/assets/www/images/spydroid.png -------------------------------------------------------------------------------- /app/src/main/assets/www/js/ie.js: -------------------------------------------------------------------------------- 1 | document.createElement('header'); 2 | document.createElement('nav'); 3 | document.createElement('section'); 4 | document.createElement('article'); 5 | document.createElement('aside'); 6 | document.createElement('footer'); 7 | document.createElement('hgroup'); 8 | 9 | $(document).ready(function () { 10 | $('.section-content,#status-container').addClass('ie8-background'); 11 | $('.category-separator').hide(); 12 | }); -------------------------------------------------------------------------------- /app/src/main/assets/www/less/#vlc.less#: -------------------------------------------------------------------------------- 1 | @vlcWidth: 640px; 2 | @vlcHeight: 480px; 3 | 4 | 5 | @-moz-keyframes move { 6 | 0% { 7 | margin-left: 0px; 8 | } 9 | 100% { 10 | margin-left: 190px; 11 | } 12 | } 13 | 14 | @-o-keyframes move { 15 | 0% { 16 | margin-left: 0px; 17 | } 18 | 100% { 19 | margin-left: 190px; 20 | } 21 | } 22 | 23 | @-ms-keyframes move { 24 | 0% { 25 | margin-left: 0px; 26 | } 27 | 100% { 28 | margin-left: 190px; 29 | } 30 | } 31 | 32 | @-webkit-keyframes move { 33 | 0% { 34 | margin-left: 0px; 35 | } 36 | 100% { 37 | margin-left: 190px; 38 | } 39 | } 40 | 41 | #vlc-container { 42 | background: black; 43 | width: @vlcWidth; 44 | height: @vlcHeight; 45 | float: left; 46 | margin-bottom: 20px; 47 | .box-shadow(2px 2px 5px rgba(0,0,0,0.7)); 48 | position: relative; 49 | 50 | #upper-layer { 51 | display: table; 52 | position: absolute; 53 | background: url("../images/eye.png") center no-repeat; 54 | top: 0px; 55 | left: 0px; 56 | width: @vlcWidth; 57 | height: @vlcHeight; 58 | z-index:10; 59 | overflow: hidden; 60 | 61 | h1 { 62 | font-size: 20px; 63 | letter-spacing: 8px; 64 | } 65 | 66 | #wrapper { 67 | display: table-cell; 68 | vertical-align: middle; 69 | 70 | p { 71 | padding: 0px 90px 0px 90px; 72 | text-align: center; 73 | } 74 | } 75 | 76 | #mask { 77 | opacity: 0.9; 78 | .animation(move 2s infinite alternate ease-in-out); 79 | position: absolute; 80 | z-index:100; 81 | width: 460px; 82 | height: 55px; 83 | top: 0; 84 | bottom: 0; 85 | left: 0; 86 | right: 0; 87 | margin: auto; 88 | 89 | background: -moz-linear-gradient(left, rgba(0,0,0,1) 0%, rgba(0,0,0,1) 35%, rgba(0,0,0,0) 50%, rgba(0,0,0,1) 65%, rgba(0,0,0,1) 100%); /* FF3.6+ */ 90 | background: -webkit-gradient(linear, left top, right top, color-stop(0%,rgba(0,0,0,1)), color-stop(35%,rgba(0,0,0,1)), color-stop(50%,rgba(0,0,0,0)), color-stop(65%,rgba(0,0,0,1)), color-stop(100%,rgba(0,0,0,1))); 91 | background: -webkit-linear-gradient(left, rgba(0,0,0,1) 0%,rgba(0,0,0,1) 35%,rgba(0,0,0,0) 50%,rgba(0,0,0,1) 65%,rgba(0,0,0,1) 100%); /* Chrome10+,Safari5.1+ */ 92 | background: -o-linear-gradient(left, rgba(0,0,0,1) 0%,rgba(0,0,0,1) 35%,rgba(0,0,0,0) 50%,rgba(0,0,0,1) 65%,rgba(0,0,0,1) 100%); /* Opera 11.10+ */ 93 | background: -ms-linear-gradient(left, rgba(0,0,0,1) 0%,rgba(0,0,0,1) 35%,rgba(0,0,0,0) 50%,rgba(0,0,0,1) 65%,rgba(0,0,0,1) 100%); /* IE10+ */ 94 | background: linear-gradient(to right, rgba(0,0,0,1) 0%,rgba(0,0,0,1) 35%,rgba(0,0,0,0) 50%,rgba(0,0,0,1) 65%,rgba(0,0,0,1) 100%); /* W3C */ 95 | //filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#000000', endColorstr='#000000',GradientType=1 ); /* IE6-9 */ 96 | 97 | } 98 | 99 | } 100 | 101 | #vlc { 102 | visibility: hidden; 103 | } 104 | 105 | #fullscreen { 106 | position: absolute; 107 | z-index: 0; 108 | bottom: -25px; 109 | left: 20px; 110 | padding: 5px 20px 4px 20px; 111 | background: rgba(7, 63, 131, 0.2); 112 | } 113 | #fullscreen:hover { 114 | cursor: pointer; 115 | color: lighten(red,20%); 116 | } 117 | 118 | } 119 | -------------------------------------------------------------------------------- /app/src/main/assets/www/less/accordion.less: -------------------------------------------------------------------------------- 1 | @startHeight: 45px; 2 | @endHeight: 340px; 3 | 4 | .accordion { 5 | 6 | .section { 7 | 8 | // border: black 1px solid; 9 | overflow: hidden; 10 | .transition(height 1s); 11 | height: @startHeight; 12 | cursor: pointer; 13 | position: relative; 14 | z-index: 0; 15 | 16 | .title { 17 | position: absolute; 18 | z-index: 2; 19 | top: 0; 20 | left: 0; 21 | width: 257px; 22 | background: url('../images/blue-button.png'); 23 | height: @startHeight; 24 | clear: both; 25 | h1 { 26 | line-height: @startHeight - 4; 27 | } 28 | } 29 | 30 | .title:hover { 31 | 32 | } 33 | 34 | .section-content { 35 | position: absolute; 36 | z-index: 1; 37 | top: 40px; 38 | left: 17px; 39 | width: 220px; 40 | height: @endHeight; 41 | margin: auto; 42 | padding-top: 1px; 43 | background: rgba(255,255,255,0.1); 44 | } 45 | 46 | } 47 | 48 | .selected { 49 | height: @endHeight; 50 | .title { 51 | // background-color: lighten(#fd9595,10%); 52 | } 53 | } 54 | 55 | 56 | .block { 57 | 58 | width: 180px; 59 | margin: 15px auto; 60 | 61 | >div { 62 | height: 27px; 63 | clear: both; 64 | } 65 | .checkbox-group { 66 | input { 67 | margin: -1px 5px 0 0; 68 | display: inline-block; 69 | } 70 | label { 71 | margin-right: 10px; 72 | display: inline; 73 | } 74 | } 75 | .select-group { 76 | label { 77 | width: 90px; 78 | float: left; 79 | } 80 | select { 81 | padding: 1px; 82 | margin: 0; 83 | height: 22px; 84 | float:left; 85 | width: 90px; 86 | } 87 | } 88 | } 89 | 90 | 91 | } 92 | -------------------------------------------------------------------------------- /app/src/main/assets/www/less/fonts.less: -------------------------------------------------------------------------------- 1 | 2 | @font-face { 3 | font-family: 'Sunshiney'; 4 | font-style: normal; 5 | font-weight: 400; 6 | src: url(../fonts/sunshiney.eot); 7 | src: local('Sunshiney'), url(../fonts/sunshiney.eot) format('embedded-opentype'), url(../fonts/sunshiney.woff) format('woff'); 8 | } 9 | 10 | @font-face { 11 | font-family: 'Bangers'; 12 | font-style: normal; 13 | font-weight: 400; 14 | src: url(../fonts/bangers.eot); 15 | src: local('Bangers'), local('Bangers-Regular'), url(../fonts/bangers.eot) format('embedded-opentype'), url(../fonts/bangers.woff) format('woff'); 16 | } 17 | -------------------------------------------------------------------------------- /app/src/main/assets/www/less/ie.less: -------------------------------------------------------------------------------- 1 | header,nav,section,article,aside,footer,hgroup 2 | { 3 | display: block; 4 | } 5 | 6 | a img { 7 | border: none; 8 | } 9 | 10 | .ie8-background { 11 | filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#20FFFFFF',endColorstr='#20FFFFFF'); 12 | background: transparent; 13 | zoom: 1; 14 | } -------------------------------------------------------------------------------- /app/src/main/assets/www/less/index.htm: -------------------------------------------------------------------------------- 1 | 4 | -------------------------------------------------------------------------------- /app/src/main/assets/www/less/mixins.less: -------------------------------------------------------------------------------- 1 | 2 | .animation(@animation) { 3 | -webkit-animation: @animation; 4 | -moz-animation: @animation; 5 | -o-animation: @animation; 6 | -ms-animation: @animation; 7 | animation: @animation; 8 | } 9 | 10 | .transition(@transition,@transition2) { 11 | -moz-transition: @transition, @transition2; 12 | -ms-transition: @transition, @transition2; 13 | -o-transition: @transition, @transition2; 14 | -webkit-transition: @transition, @transition2; 15 | transition: @transition, @transition2; 16 | } 17 | .transition(@transition) { 18 | -moz-transition: @transition; 19 | -ms-transition: @transition; 20 | -o-transition: @transition; 21 | -webkit-transition: @transition; 22 | transition: @transition; 23 | } 24 | 25 | 26 | .transform(@transformation) { 27 | -moz-transform: @transformation; 28 | -ms-transform: @transformation; 29 | -o-transform: @transformation; 30 | -webkit-transform: @transformation; 31 | transform: @transformation; 32 | } 33 | 34 | .border-radius(@radius: 5px) { 35 | -webkit-border-radius: @radius; 36 | -moz-border-radius: @radius; 37 | border-radius: @radius; 38 | } 39 | 40 | .box-shadow(@shadow: 0 1px 3px rgba(0,0,0,.25)) { 41 | -webkit-box-shadow: @shadow; 42 | -moz-box-shadow: @shadow; 43 | box-shadow: @shadow; 44 | } 45 | 46 | .disableselection() { 47 | -webkit-touch-callout: none; 48 | -webkit-user-select: none; 49 | -moz-user-select: none; 50 | -ms-user-select: none; 51 | user-select: none; 52 | } -------------------------------------------------------------------------------- /app/src/main/assets/www/less/styles.less: -------------------------------------------------------------------------------- 1 | @import "fonts"; 2 | @import "mixins"; 3 | @import "base"; 4 | @import "vlc"; 5 | @import "accordion"; 6 | @import "ie"; -------------------------------------------------------------------------------- /app/src/main/assets/www/less/vlc.less: -------------------------------------------------------------------------------- 1 | @vlcWidth: 640px; 2 | @vlcHeight: 480px; 3 | 4 | 5 | @-moz-keyframes move { 6 | 0% { 7 | margin-left: 0px; 8 | } 9 | 100% { 10 | margin-left: 190px; 11 | } 12 | } 13 | 14 | @-o-keyframes move { 15 | 0% { 16 | margin-left: 0px; 17 | } 18 | 100% { 19 | margin-left: 190px; 20 | } 21 | } 22 | 23 | @-ms-keyframes move { 24 | 0% { 25 | margin-left: 0px; 26 | } 27 | 100% { 28 | margin-left: 190px; 29 | } 30 | } 31 | 32 | @-webkit-keyframes move { 33 | 0% { 34 | margin-left: 0px; 35 | } 36 | 100% { 37 | margin-left: 190px; 38 | } 39 | } 40 | 41 | #vlc-container { 42 | background: black; 43 | width: @vlcWidth; 44 | height: @vlcHeight; 45 | float: left; 46 | margin-bottom: 20px; 47 | .box-shadow(2px 2px 5px rgba(0,0,0,0.7)); 48 | position: relative; 49 | 50 | #upper-layer { 51 | display: table; 52 | position: absolute; 53 | background: url("../images/eye.png") center no-repeat; 54 | top: 0px; 55 | left: 0px; 56 | width: @vlcWidth; 57 | height: @vlcHeight; 58 | z-index:10; 59 | overflow: hidden; 60 | 61 | h1 { 62 | font-size: 20px; 63 | letter-spacing: 8px; 64 | } 65 | 66 | #wrapper { 67 | display: table-cell; 68 | vertical-align: middle; 69 | 70 | p { 71 | padding: 0px 90px 0px 90px; 72 | text-align: center; 73 | } 74 | } 75 | 76 | #mask { 77 | opacity: 0.9; 78 | .animation(move 2s infinite alternate ease-in-out); 79 | position: absolute; 80 | z-index:100; 81 | width: 460px; 82 | height: 55px; 83 | top: 0; 84 | bottom: 0; 85 | left: 0; 86 | right: 0; 87 | margin: auto; 88 | 89 | background: -moz-linear-gradient(left, rgba(0,0,0,1) 0%, rgba(0,0,0,1) 35%, rgba(0,0,0,0) 50%, rgba(0,0,0,1) 65%, rgba(0,0,0,1) 100%); /* FF3.6+ */ 90 | background: -webkit-gradient(linear, left top, right top, color-stop(0%,rgba(0,0,0,1)), color-stop(35%,rgba(0,0,0,1)), color-stop(50%,rgba(0,0,0,0)), color-stop(65%,rgba(0,0,0,1)), color-stop(100%,rgba(0,0,0,1))); 91 | background: -webkit-linear-gradient(left, rgba(0,0,0,1) 0%,rgba(0,0,0,1) 35%,rgba(0,0,0,0) 50%,rgba(0,0,0,1) 65%,rgba(0,0,0,1) 100%); /* Chrome10+,Safari5.1+ */ 92 | background: -o-linear-gradient(left, rgba(0,0,0,1) 0%,rgba(0,0,0,1) 35%,rgba(0,0,0,0) 50%,rgba(0,0,0,1) 65%,rgba(0,0,0,1) 100%); /* Opera 11.10+ */ 93 | background: -ms-linear-gradient(left, rgba(0,0,0,1) 0%,rgba(0,0,0,1) 35%,rgba(0,0,0,0) 50%,rgba(0,0,0,1) 65%,rgba(0,0,0,1) 100%); /* IE10+ */ 94 | background: linear-gradient(to right, rgba(0,0,0,1) 0%,rgba(0,0,0,1) 35%,rgba(0,0,0,0) 50%,rgba(0,0,0,1) 65%,rgba(0,0,0,1) 100%); /* W3C */ 95 | //filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#000000', endColorstr='#000000',GradientType=1 ); /* IE6-9 */ 96 | 97 | } 98 | 99 | } 100 | 101 | #vlc { 102 | visibility: hidden; 103 | } 104 | 105 | #fullscreen { 106 | position: absolute; 107 | z-index: 0; 108 | bottom: -25px; 109 | left: 20px; 110 | padding: 5px 20px 4px 20px; 111 | background: rgba(7, 63, 131, 0.2); 112 | } 113 | 114 | } 115 | -------------------------------------------------------------------------------- /app/src/main/assets/www/tests/test1.htm: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 29 | 30 | 31 | 32 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | -------------------------------------------------------------------------------- /app/src/main/java/net/majorkernelpanic/http/ModInternationalization.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2011-2012 GUIGUI Simon, fyhertz@gmail.com 3 | * 4 | * This file is part of Spydroid (http://code.google.com/p/spydroid-ipcamera/) 5 | * 6 | * Spydroid is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This source code is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this source code; if not, write to the Free Software 18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 19 | */ 20 | 21 | package net.majorkernelpanic.http; 22 | 23 | import android.util.Log; 24 | 25 | import org.apache.http.HttpException; 26 | import org.apache.http.HttpRequest; 27 | import org.apache.http.HttpResponse; 28 | import org.apache.http.HttpStatus; 29 | import org.apache.http.MethodNotSupportedException; 30 | import org.apache.http.entity.ContentProducer; 31 | import org.apache.http.entity.EntityTemplate; 32 | import org.apache.http.protocol.HttpContext; 33 | import org.apache.http.protocol.HttpRequestHandler; 34 | 35 | import java.io.IOException; 36 | import java.io.OutputStream; 37 | import java.io.OutputStreamWriter; 38 | import java.lang.reflect.Field; 39 | import java.util.Locale; 40 | 41 | /** 42 | * The purpose of this module is to make internationalization of the interface that 43 | * your app is going to serve easier by using the standard workflow used in Android. 44 | *

45 | * You just have to add strings in string.xml (or some other file containing string resources) 46 | * and you will then be able to access those on the client side. 47 | */ 48 | public class ModInternationalization implements HttpRequestHandler { 49 | private static final String TAG = "ModInternationalization"; 50 | 51 | /** 52 | * Client side file name. 53 | */ 54 | public static final String PATTERN = "/strings.json"; 55 | 56 | /** 57 | * Prefix for strings. 58 | */ 59 | public static final String PREFIX = "web_"; 60 | 61 | private String mJSON = "{}"; 62 | 63 | public ModInternationalization(TinyHttpServer server) { 64 | super(); 65 | 66 | StringBuilder builder = new StringBuilder(); 67 | 68 | try { 69 | // Retrieves R.string 70 | Class String = Class.forName(server.mContext.getPackageName() + ".R$string"); 71 | Field[] fields = String.getFields(); 72 | 73 | // Constructs a JSON with all members starting with PREFIX 74 | builder.append("{\""); 75 | for (int i = 0; i < fields.length; i++) { 76 | if (fields[i].getName().startsWith(PREFIX)) { 77 | builder.append(fields[i].getName()); 78 | builder.append("\":\""); 79 | builder.append((String) server.getString(fields[i].getInt(null))); 80 | builder.append("\",\""); 81 | } 82 | } 83 | 84 | if (builder.length() > 2) { 85 | builder.setLength(builder.length() - 2); 86 | } else { 87 | builder.setLength(builder.length() - 1); 88 | } 89 | builder.append("}"); 90 | 91 | mJSON = builder.toString(); 92 | 93 | } catch (Exception e) { 94 | Log.e(TAG, "Little problem with ModInternationalization !"); 95 | e.printStackTrace(); 96 | } 97 | } 98 | 99 | public void handle( 100 | final HttpRequest request, 101 | final HttpResponse response, 102 | final HttpContext context) throws HttpException, IOException { 103 | final String method = request.getRequestLine().getMethod().toUpperCase(Locale.ENGLISH); 104 | if (!method.equals("GET") && !method.equals("HEAD")) { 105 | throw new MethodNotSupportedException(method + " method not supported"); 106 | } 107 | final EntityTemplate body = new EntityTemplate(new ContentProducer() { 108 | public void writeTo(final OutputStream outstream) throws IOException { 109 | OutputStreamWriter writer = new OutputStreamWriter(outstream, "UTF-8"); 110 | writer.write(mJSON); 111 | writer.flush(); 112 | } 113 | }); 114 | response.setStatusCode(HttpStatus.SC_OK); 115 | body.setContentType("text/json; charset=UTF-8"); 116 | response.setEntity(body); 117 | } 118 | } 119 | -------------------------------------------------------------------------------- /app/src/main/java/net/majorkernelpanic/onvif/DeviceBackBean.java: -------------------------------------------------------------------------------- 1 | package net.majorkernelpanic.onvif; 2 | 3 | public class DeviceBackBean { 4 | private String userName; 5 | 6 | private String psw; 7 | private String ipAddress; 8 | private String serviceUrl; 9 | private String uuid; 10 | private String mediaUrl; 11 | private String ptzUrl; 12 | private String imageUrl; 13 | private String eventUrl; 14 | 15 | private String videoEncodeFormat; 16 | 17 | private String sourceWidth = "800"; 18 | private String sourceHeight = "400"; 19 | private String encodeWidth = "480"; 20 | private String encodeHeight = "320"; 21 | 22 | private String frameRateLimit = "25"; 23 | private String bitrateLimit = "10000"; 24 | // the default port of which using to perform SOAP web service 25 | private String port = "8080"; 26 | // the default port of which using to RTSP streaming action 27 | private String rtspPort = "8086"; 28 | private String mediaTimeout = "PT30S"; 29 | 30 | public DeviceBackBean() { 31 | } 32 | 33 | public String getUserName() { 34 | return userName; 35 | } 36 | 37 | public void setUserName(String userName) { 38 | this.userName = userName; 39 | } 40 | 41 | public String getPsw() { 42 | return psw; 43 | } 44 | 45 | public void setPsw(String psw) { 46 | this.psw = psw; 47 | } 48 | 49 | public String getIpAddress() { 50 | return ipAddress; 51 | } 52 | 53 | public void setIpAddress(String ipAddress) { 54 | this.ipAddress = ipAddress; 55 | } 56 | 57 | public String getServiceUrl() { 58 | return serviceUrl; 59 | } 60 | 61 | public void setServiceUrl(String serviceUrl) { 62 | this.serviceUrl = serviceUrl; 63 | } 64 | 65 | public String getUuid() { 66 | return uuid; 67 | } 68 | 69 | public void setUuid(String uuid) { 70 | this.uuid = uuid; 71 | } 72 | 73 | public String getMediaUrl() { 74 | return mediaUrl; 75 | } 76 | 77 | public void setMediaUrl(String mediaUrl) { 78 | this.mediaUrl = mediaUrl; 79 | } 80 | 81 | public String getPtzUrl() { 82 | return ptzUrl; 83 | } 84 | 85 | public void setPtzUrl(String ptzUrl) { 86 | this.ptzUrl = ptzUrl; 87 | } 88 | 89 | public String getImageUrl() { 90 | return imageUrl; 91 | } 92 | 93 | public void setImageUrl(String imageUrl) { 94 | this.imageUrl = imageUrl; 95 | } 96 | 97 | public String getEventUrl() { 98 | return eventUrl; 99 | } 100 | 101 | public void setEventUrl(String eventUrl) { 102 | this.eventUrl = eventUrl; 103 | } 104 | 105 | public String getVideoEncodeFormat() { 106 | return videoEncodeFormat; 107 | } 108 | 109 | public void setVideoEncodeFormat(String videoEncodeFormat) { 110 | this.videoEncodeFormat = videoEncodeFormat; 111 | } 112 | 113 | public String getMediaTimeout() { 114 | return mediaTimeout; 115 | } 116 | 117 | public void setMediaTimeout(String mediaTimeout) { 118 | this.mediaTimeout = mediaTimeout; 119 | } 120 | 121 | public String getRtspPort() { 122 | return rtspPort; 123 | } 124 | 125 | public void setRtspPort(String rtspPort) { 126 | this.rtspPort = rtspPort; 127 | } 128 | 129 | public String getPort() { 130 | return port; 131 | } 132 | 133 | public void setPort(String port) { 134 | this.port = port; 135 | } 136 | 137 | public String getBitrateLimit() { 138 | return bitrateLimit; 139 | } 140 | 141 | public void setBitrateLimit(String bitrateLimit) { 142 | this.bitrateLimit = bitrateLimit; 143 | } 144 | 145 | public String getFrameRateLimit() { 146 | return frameRateLimit; 147 | } 148 | 149 | public void setFrameRateLimit(String frameRateLimit) { 150 | this.frameRateLimit = frameRateLimit; 151 | } 152 | 153 | public String getEncodeHeight() { 154 | return encodeHeight; 155 | } 156 | 157 | public void setEncodeHeight(String encodeHeight) { 158 | this.encodeHeight = encodeHeight; 159 | } 160 | 161 | public String getEncodeWidth() { 162 | return encodeWidth; 163 | } 164 | 165 | public void setEncodeWidth(String encodeWidth) { 166 | this.encodeWidth = encodeWidth; 167 | } 168 | 169 | public String getSourceHeight() { 170 | return sourceHeight; 171 | } 172 | 173 | public void setSourceHeight(String sourceHeight) { 174 | this.sourceHeight = sourceHeight; 175 | } 176 | 177 | public String getSourceWidth() { 178 | return sourceWidth; 179 | } 180 | 181 | public void setSourceWidth(String sourceWidth) { 182 | this.sourceWidth = sourceWidth; 183 | } 184 | 185 | } 186 | -------------------------------------------------------------------------------- /app/src/main/java/net/majorkernelpanic/onvif/DeviceStaticInfo.java: -------------------------------------------------------------------------------- 1 | package net.majorkernelpanic.onvif; 2 | 3 | public interface DeviceStaticInfo { 4 | String USER_NAME = "ky_lab"; 5 | String USER_PSW = "123456"; 6 | String GET_MEDIA = "/onvif/Media"; 7 | String GET_PTZ = "/onvif/PTZ"; 8 | String GET_ANALYTICS = "/onvif/Analytics"; 9 | String GET_DEVICE_SERVICES = "/onvif/device_services"; 10 | String GET_EVENTS = "/onvif/Events"; 11 | String GET_IMAGING = "/onvif/Imaging"; 12 | /** 13 | * 获取推流视频的地址的URI 14 | */ 15 | String GET_STREAM_URI = "onvif/GetStreamUri"; 16 | } 17 | -------------------------------------------------------------------------------- /app/src/main/java/net/majorkernelpanic/onvif/ONVIFDevDiscoveryReqHeader.java: -------------------------------------------------------------------------------- 1 | package net.majorkernelpanic.onvif; 2 | 3 | public class ONVIFDevDiscoveryReqHeader { 4 | 5 | private String messageId; 6 | private String action; 7 | 8 | public ONVIFDevDiscoveryReqHeader() { 9 | } 10 | 11 | public String getMessageId() { 12 | return messageId; 13 | } 14 | 15 | public void setMessageId(String messageId) { 16 | this.messageId = messageId; 17 | } 18 | 19 | public String getAction() { 20 | return action; 21 | } 22 | 23 | public void setAction(String action) { 24 | this.action = action; 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /app/src/main/java/net/majorkernelpanic/onvif/ONVIFPacketHandler.java: -------------------------------------------------------------------------------- 1 | package net.majorkernelpanic.onvif; 2 | 3 | import android.util.Log; 4 | 5 | import org.xml.sax.Attributes; 6 | import org.xml.sax.SAXException; 7 | import org.xml.sax.helpers.DefaultHandler; 8 | 9 | import javax.xml.parsers.SAXParser; 10 | 11 | 12 | /** 13 | * 解析我们接收到的ONVIF数据包 14 | * 包的格式本身是xml格式的(这是SOAP协议要求的) 15 | * 如果ONVIF协议继续更新的话,希望更新成FlatBuffer协议,比xml要快到很多,同时数据 16 | * 也精简很多. 17 | *

18 | * {@link SAXParser}会自动的将输入流绑定到当前的{@link DefaultHandler}当中。 19 | * 因此我们不需要处理数据源。 20 | * 输入源在某种程度上对我们是透明的. 21 | */ 22 | public class ONVIFPacketHandler extends DefaultHandler { 23 | private static final String TAG = "ONVIFPacketHandler"; 24 | 25 | private static final String LOCAL_MSG_ID = "a:MessageID"; 26 | private static final String LOCAL_ACTION = "a:Action"; 27 | 28 | private boolean isMsgID = false; 29 | private boolean isAction = false; 30 | 31 | private ONVIFDevDiscoveryReqHeader reqHeader; 32 | 33 | public ONVIFPacketHandler() { 34 | reqHeader = new ONVIFDevDiscoveryReqHeader(); 35 | } 36 | 37 | @Override 38 | public void startDocument() throws SAXException { 39 | Log.d(TAG, "start parsing the document"); 40 | 41 | } 42 | 43 | @Override 44 | public void startElement(String uri, String localName, String qName, Attributes attributes) throws SAXException { 45 | Log.d(TAG, "element : " + String.format("uri = %s, localName = %s, qName = %s", uri, localName, qName)); 46 | switch (qName) { 47 | case LOCAL_MSG_ID: 48 | isMsgID = true; 49 | break; 50 | case LOCAL_ACTION: 51 | isAction = true; 52 | break; 53 | } 54 | } 55 | 56 | @Override 57 | public void characters(char[] ch, int start, int length) throws SAXException { 58 | if (isMsgID) { 59 | String messageId = new String(ch, start, length); 60 | reqHeader.setMessageId(messageId.trim()); 61 | Log.d(TAG, "the message ID we get are : " + messageId); 62 | isMsgID = false; 63 | } else if (isAction) { 64 | String action = new String(ch, start, length); 65 | reqHeader.setAction(action.trim()); 66 | Log.d(TAG, "the action we get are : " + action); 67 | isAction = false; 68 | } 69 | } 70 | 71 | @Override 72 | public void endElement(String uri, String localName, String qName) throws SAXException { 73 | Log.d(TAG, String.format("end element of uri = %s, localName = %s, qName = %s", uri, localName, qName)); 74 | } 75 | 76 | @Override 77 | public void endDocument() throws SAXException { 78 | Log.d(TAG, "End of parsing documents"); 79 | } 80 | 81 | public ONVIFDevDiscoveryReqHeader getReqHeader() { 82 | return reqHeader; 83 | } 84 | } 85 | -------------------------------------------------------------------------------- /app/src/main/java/net/majorkernelpanic/spydroid/api/CustomRtspServer.java: -------------------------------------------------------------------------------- 1 | package net.majorkernelpanic.spydroid.api; 2 | 3 | import net.majorkernelpanic.streaming.rtsp.RtspServer; 4 | 5 | public class CustomRtspServer extends RtspServer { 6 | public CustomRtspServer() { 7 | super(); 8 | // 最原始程序实现当中,默认是关闭RTSP server的, 9 | // 如果打开RTSP server之后,我们就可以直接通过vlc来查看rtsp视频流了 10 | // 我们这里将RTSP再设置为默认打开. 11 | mEnabled = true; 12 | } 13 | } 14 | 15 | -------------------------------------------------------------------------------- /app/src/main/java/net/majorkernelpanic/spydroid/ui/AboutFragment.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2011-2013 GUIGUI Simon, fyhertz@gmail.com 3 | * 4 | * This file is part of Spydroid (http://code.google.com/p/spydroid-ipcamera/) 5 | * 6 | * Spydroid is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This source code is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this source code; if not, write to the Free Software 18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 19 | */ 20 | 21 | package net.majorkernelpanic.spydroid.ui; 22 | 23 | import net.majorkernelpanic.spydroid.R; 24 | import net.majorkernelpanic.spydroid.SpydroidApplication; 25 | 26 | import android.content.Intent; 27 | import android.net.Uri; 28 | import android.os.Bundle; 29 | import android.support.v4.app.Fragment; 30 | import android.view.LayoutInflater; 31 | import android.view.View; 32 | import android.view.View.OnClickListener; 33 | import android.view.ViewGroup; 34 | import android.widget.Button; 35 | 36 | public class AboutFragment extends Fragment { 37 | 38 | private Button mButtonVisit; 39 | private Button mButtonRate; 40 | private Button mButtonLike; 41 | 42 | public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { 43 | View rootView = inflater.inflate(R.layout.about, container, false); 44 | 45 | mButtonVisit = (Button) rootView.findViewById(R.id.visit); 46 | mButtonRate = (Button) rootView.findViewById(R.id.rate); 47 | mButtonLike = (Button) rootView.findViewById(R.id.like); 48 | 49 | mButtonVisit.setOnClickListener(new OnClickListener() { 50 | @Override 51 | public void onClick(View v) { 52 | Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("https://code.google.com/p/spydroid-ipcamera/")); 53 | intent.addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY | Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET); 54 | startActivity(intent); 55 | } 56 | }); 57 | 58 | mButtonRate.setOnClickListener(new OnClickListener() { 59 | @Override 60 | public void onClick(View v) { 61 | String appPackageName = SpydroidApplication.getInstance().getApplicationContext().getPackageName(); 62 | Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id=" + appPackageName)); 63 | intent.addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY | Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET); 64 | startActivity(intent); 65 | } 66 | }); 67 | 68 | mButtonLike.setOnClickListener(new OnClickListener() { 69 | @Override 70 | public void onClick(View v) { 71 | Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("http://www.facebook.com/spydroidipcamera")); 72 | intent.addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY | Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET); 73 | startActivity(intent); 74 | } 75 | }); 76 | 77 | return rootView; 78 | } 79 | 80 | } 81 | -------------------------------------------------------------------------------- /app/src/main/java/net/majorkernelpanic/spydroid/ui/PreviewFragment.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2011-2013 GUIGUI Simon, fyhertz@gmail.com 3 | * 4 | * This file is part of Spydroid (http://code.google.com/p/spydroid-ipcamera/) 5 | * 6 | * Spydroid is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This source code is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this source code; if not, write to the Free Software 18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 19 | */ 20 | 21 | package net.majorkernelpanic.spydroid.ui; 22 | 23 | import net.majorkernelpanic.http.TinyHttpServer; 24 | import net.majorkernelpanic.spydroid.R; 25 | import net.majorkernelpanic.spydroid.api.CustomHttpServer; 26 | import net.majorkernelpanic.spydroid.api.CustomRtspServer; 27 | import net.majorkernelpanic.streaming.SessionBuilder; 28 | import net.majorkernelpanic.streaming.gl.SurfaceView; 29 | import net.majorkernelpanic.streaming.rtsp.RtspServer; 30 | import android.content.ComponentName; 31 | import android.content.Context; 32 | import android.content.Intent; 33 | import android.content.ServiceConnection; 34 | import android.os.Bundle; 35 | import android.os.IBinder; 36 | import android.support.v4.app.Fragment; 37 | import android.view.LayoutInflater; 38 | import android.view.SurfaceHolder; 39 | import android.view.View; 40 | import android.view.ViewGroup; 41 | import android.widget.TextView; 42 | 43 | public class PreviewFragment extends Fragment { 44 | 45 | public final static String TAG = "PreviewFragment"; 46 | 47 | private SurfaceView mSurfaceView; 48 | private TextView mTextView; 49 | private CustomHttpServer mHttpServer; 50 | private RtspServer mRtspServer; 51 | 52 | @Override 53 | public void onCreate(Bundle savedInstanceState) { 54 | super.onCreate(savedInstanceState); 55 | } 56 | 57 | @Override 58 | public void onPause() { 59 | super.onPause(); 60 | getActivity().unbindService(mHttpServiceConnection); 61 | getActivity().unbindService(mRtspServiceConnection); 62 | } 63 | 64 | @Override 65 | public void onResume() { 66 | super.onResume(); 67 | getActivity().bindService(new Intent(getActivity(),CustomHttpServer.class), mHttpServiceConnection, Context.BIND_AUTO_CREATE); 68 | getActivity().bindService(new Intent(getActivity(),CustomRtspServer.class), mRtspServiceConnection, Context.BIND_AUTO_CREATE); 69 | } 70 | 71 | @Override 72 | public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { 73 | View rootView = inflater.inflate(R.layout.preview,container,false); 74 | 75 | mTextView = (TextView)rootView.findViewById(R.id.tooltip); 76 | 77 | if (((SpydroidActivity)getActivity()).device == ((SpydroidActivity)getActivity()).TABLET) { 78 | 79 | mSurfaceView = (SurfaceView)rootView.findViewById(R.id.tablet_camera_view); 80 | SessionBuilder.getInstance().setSurfaceView(mSurfaceView); 81 | 82 | } 83 | 84 | return rootView; 85 | } 86 | 87 | public void update() { 88 | getActivity().runOnUiThread(new Runnable() { 89 | @Override 90 | public void run() { 91 | if (mTextView != null) { 92 | if ((mRtspServer != null && mRtspServer.isStreaming()) || (mHttpServer != null && mHttpServer.isStreaming())) 93 | mTextView.setVisibility(View.INVISIBLE); 94 | else 95 | mTextView.setVisibility(View.VISIBLE); 96 | } 97 | } 98 | }); 99 | } 100 | 101 | private final ServiceConnection mRtspServiceConnection = new ServiceConnection() { 102 | @Override 103 | public void onServiceConnected(ComponentName name, IBinder service) { 104 | mRtspServer = (RtspServer) ((RtspServer.LocalBinder)service).getService(); 105 | update(); 106 | } 107 | @Override 108 | public void onServiceDisconnected(ComponentName name) {} 109 | }; 110 | 111 | private final ServiceConnection mHttpServiceConnection = new ServiceConnection() { 112 | @Override 113 | public void onServiceConnected(ComponentName name, IBinder service) { 114 | mHttpServer = (CustomHttpServer) ((TinyHttpServer.LocalBinder)service).getService(); 115 | update(); 116 | } 117 | @Override 118 | public void onServiceDisconnected(ComponentName name) {} 119 | }; 120 | 121 | } 122 | -------------------------------------------------------------------------------- /app/src/main/java/net/majorkernelpanic/spydroid/ui/TabletFragment.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2011-2013 GUIGUI Simon, fyhertz@gmail.com 3 | * 4 | * This file is part of Spydroid (http://code.google.com/p/spydroid-ipcamera/) 5 | * 6 | * Spydroid is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This source code is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this source code; if not, write to the Free Software 18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 19 | */ 20 | 21 | package net.majorkernelpanic.spydroid.ui; 22 | 23 | import net.majorkernelpanic.spydroid.R; 24 | import android.os.Bundle; 25 | import android.support.v4.app.Fragment; 26 | import android.view.LayoutInflater; 27 | import android.view.View; 28 | import android.view.ViewGroup; 29 | 30 | public class TabletFragment extends Fragment { 31 | 32 | @Override 33 | public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { 34 | View rootView = inflater.inflate(R.layout.tablet,container,false); 35 | return rootView ; 36 | } 37 | 38 | @Override 39 | public void onResume() { 40 | super.onResume(); 41 | } 42 | 43 | } 44 | -------------------------------------------------------------------------------- /app/src/main/java/net/majorkernelpanic/streaming/Stream.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2011-2014 GUIGUI Simon, fyhertz@gmail.com 3 | * 4 | * This file is part of libstreaming (https://github.com/fyhertz/libstreaming) 5 | * 6 | * Spydroid is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This source code is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this source code; if not, write to the Free Software 18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 19 | */ 20 | 21 | package net.majorkernelpanic.streaming; 22 | 23 | import java.io.IOException; 24 | import java.net.InetAddress; 25 | 26 | /** 27 | * An interface that represents a Stream. 28 | */ 29 | public interface Stream { 30 | 31 | /** 32 | * Configures the stream. You need to call this before calling {@link #getSessionDescription()} 33 | * to apply your configuration of the stream. 34 | */ 35 | void configure() throws IllegalStateException, IOException; 36 | 37 | /** 38 | * Starts the stream. 39 | * This method can only be called after {@link Stream#configure()}. 40 | */ 41 | void start() throws IllegalStateException, IOException; 42 | 43 | /** 44 | * Stops the stream. 45 | */ 46 | void stop(); 47 | 48 | /** 49 | * Sets the Time To Live of packets sent over the network. 50 | * 51 | * @param ttl The time to live 52 | * @throws IOException 53 | */ 54 | void setTimeToLive(int ttl) throws IOException; 55 | 56 | /** 57 | * Sets the destination ip address of the stream. 58 | * 59 | * @param dest The destination address of the stream 60 | */ 61 | void setDestinationAddress(InetAddress dest); 62 | 63 | /** 64 | * Sets the destination ports of the stream. 65 | * If an odd number is supplied for the destination port then the next 66 | * lower even number will be used for RTP and it will be used for RTCP. 67 | * If an even number is supplied, it will be used for RTP and the next odd 68 | * number will be used for RTCP. 69 | * 70 | * @param dport The destination port 71 | */ 72 | void setDestinationPorts(int dport); 73 | 74 | /** 75 | * Sets the destination ports of the stream. 76 | * 77 | * @param rtpPort Destination port that will be used for RTP 78 | * @param rtcpPort Destination port that will be used for RTCP 79 | */ 80 | void setDestinationPorts(int rtpPort, int rtcpPort); 81 | 82 | /** 83 | * Returns a pair of source ports, the first one is the 84 | * one used for RTP and the second one is used for RTCP. 85 | **/ 86 | int[] getLocalPorts(); 87 | 88 | /** 89 | * Returns a pair of destination ports, the first one is the 90 | * one used for RTP and the second one is used for RTCP. 91 | **/ 92 | int[] getDestinationPorts(); 93 | 94 | 95 | /** 96 | * Returns the SSRC of the underlying {@link net.majorkernelpanic.streaming.rtp.RtpSocket}. 97 | * 98 | * @return the SSRC of the stream. 99 | */ 100 | int getSSRC(); 101 | 102 | /** 103 | * Returns an approximation of the bit rate consumed by the stream in bit per seconde. 104 | */ 105 | long getBitrate(); 106 | 107 | /** 108 | * Returns a description of the stream using SDP. 109 | * This method can only be called after {@link Stream#configure()}. 110 | * 111 | * @throws IllegalStateException Thrown when {@link Stream#configure()} wa not called. 112 | */ 113 | String getSessionDescription() throws IllegalStateException; 114 | 115 | boolean isStreaming(); 116 | 117 | } 118 | -------------------------------------------------------------------------------- /app/src/main/java/net/majorkernelpanic/streaming/audio/AMRNBStream.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2011-2014 GUIGUI Simon, fyhertz@gmail.com 3 | * 4 | * This file is part of libstreaming (https://github.com/fyhertz/libstreaming) 5 | * 6 | * Spydroid is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This source code is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this source code; if not, write to the Free Software 18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 19 | */ 20 | 21 | package net.majorkernelpanic.streaming.audio; 22 | 23 | import java.io.IOException; 24 | import java.lang.reflect.Field; 25 | 26 | import net.majorkernelpanic.streaming.SessionBuilder; 27 | import net.majorkernelpanic.streaming.rtp.AMRNBPacketizer; 28 | import android.media.MediaRecorder; 29 | import android.service.textservice.SpellCheckerService.Session; 30 | 31 | /** 32 | * A class for streaming AAC from the camera of an android device using RTP. 33 | * You should use a {@link Session} instantiated with {@link SessionBuilder} instead of using this class directly. 34 | * Call {@link #setDestinationAddress(InetAddress)}, {@link #setDestinationPorts(int)} and {@link #setAudioQuality(AudioQuality)} 35 | * to configure the stream. You can then call {@link #start()} to start the RTP stream. 36 | * Call {@link #stop()} to stop the stream. 37 | */ 38 | public class AMRNBStream extends AudioStream { 39 | 40 | public AMRNBStream() { 41 | super(); 42 | 43 | mPacketizer = new AMRNBPacketizer(); 44 | 45 | setAudioSource(MediaRecorder.AudioSource.CAMCORDER); 46 | 47 | try { 48 | // RAW_AMR was deprecated in API level 16. 49 | Field deprecatedName = MediaRecorder.OutputFormat.class.getField("RAW_AMR"); 50 | setOutputFormat(deprecatedName.getInt(null)); 51 | } catch (Exception e) { 52 | setOutputFormat(MediaRecorder.OutputFormat.AMR_NB); 53 | } 54 | 55 | setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB); 56 | 57 | } 58 | 59 | /** 60 | * Starts the stream. 61 | */ 62 | public synchronized void start() throws IllegalStateException, IOException { 63 | configure(); 64 | if (!mStreaming) { 65 | super.start(); 66 | } 67 | } 68 | 69 | public synchronized void configure() throws IllegalStateException, IOException { 70 | super.configure(); 71 | mMode = MODE_MEDIARECORDER_API; 72 | mQuality = mRequestedQuality.clone(); 73 | } 74 | 75 | /** 76 | * Returns a description of the stream using SDP. It can then be included in an SDP file. 77 | */ 78 | public String getSessionDescription() { 79 | return "m=audio "+String.valueOf(getDestinationPorts()[0])+" RTP/AVP 96\r\n" + 80 | "a=rtpmap:96 AMR/8000\r\n" + 81 | "a=fmtp:96 octet-align=1;\r\n"; 82 | } 83 | 84 | @Override 85 | protected void encodeWithMediaCodec() throws IOException { 86 | super.encodeWithMediaRecorder(); 87 | } 88 | 89 | } 90 | -------------------------------------------------------------------------------- /app/src/main/java/net/majorkernelpanic/streaming/audio/AudioQuality.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2011-2014 GUIGUI Simon, fyhertz@gmail.com 3 | * 4 | * This file is part of libstreaming (https://github.com/fyhertz/libstreaming) 5 | * 6 | * Spydroid is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This source code is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this source code; if not, write to the Free Software 18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 19 | */ 20 | 21 | package net.majorkernelpanic.streaming.audio; 22 | 23 | /** 24 | * A class that represents the quality of an audio stream. 25 | */ 26 | public class AudioQuality { 27 | 28 | /** Default audio stream quality. */ 29 | public final static AudioQuality DEFAULT_AUDIO_QUALITY = new AudioQuality(8000,32000); 30 | 31 | /** Represents a quality for a video stream. */ 32 | public AudioQuality() {} 33 | 34 | /** 35 | * Represents a quality for an audio stream. 36 | * @param samplingRate The sampling rate 37 | * @param bitRate The bitrate in bit per seconds 38 | */ 39 | public AudioQuality(int samplingRate, int bitRate) { 40 | this.samplingRate = samplingRate; 41 | this.bitRate = bitRate; 42 | } 43 | 44 | public int samplingRate = 0; 45 | public int bitRate = 0; 46 | 47 | public boolean equals(AudioQuality quality) { 48 | if (quality==null) return false; 49 | return (quality.samplingRate == this.samplingRate & 50 | quality.bitRate == this.bitRate); 51 | } 52 | 53 | public AudioQuality clone() { 54 | return new AudioQuality(samplingRate, bitRate); 55 | } 56 | 57 | public static AudioQuality parseQuality(String str) { 58 | AudioQuality quality = DEFAULT_AUDIO_QUALITY.clone(); 59 | if (str != null) { 60 | String[] config = str.split("-"); 61 | try { 62 | quality.bitRate = Integer.parseInt(config[0])*1000; // conversion to bit/s 63 | quality.samplingRate = Integer.parseInt(config[1]); 64 | } 65 | catch (IndexOutOfBoundsException ignore) {} 66 | } 67 | return quality; 68 | } 69 | 70 | } 71 | -------------------------------------------------------------------------------- /app/src/main/java/net/majorkernelpanic/streaming/audio/AudioStream.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2011-2014 GUIGUI Simon, fyhertz@gmail.com 3 | * 4 | * This file is part of libstreaming (https://github.com/fyhertz/libstreaming) 5 | * 6 | * Spydroid is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This source code is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this source code; if not, write to the Free Software 18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 19 | */ 20 | 21 | package net.majorkernelpanic.streaming.audio; 22 | 23 | import java.io.IOException; 24 | 25 | import net.majorkernelpanic.streaming.MediaStream; 26 | import android.media.MediaRecorder; 27 | import android.util.Log; 28 | 29 | /** 30 | * Don't use this class directly. 31 | */ 32 | public abstract class AudioStream extends MediaStream { 33 | 34 | protected int mAudioSource; 35 | protected int mOutputFormat; 36 | protected int mAudioEncoder; 37 | protected AudioQuality mRequestedQuality = AudioQuality.DEFAULT_AUDIO_QUALITY.clone(); 38 | protected AudioQuality mQuality = mRequestedQuality.clone(); 39 | 40 | public AudioStream() { 41 | setAudioSource(MediaRecorder.AudioSource.CAMCORDER); 42 | } 43 | 44 | public void setAudioSource(int audioSource) { 45 | mAudioSource = audioSource; 46 | } 47 | 48 | public void setAudioQuality(AudioQuality quality) { 49 | mRequestedQuality = quality; 50 | } 51 | 52 | /** 53 | * Returns the quality of the stream. 54 | */ 55 | public AudioQuality getAudioQuality() { 56 | return mQuality; 57 | } 58 | 59 | protected void setAudioEncoder(int audioEncoder) { 60 | mAudioEncoder = audioEncoder; 61 | } 62 | 63 | protected void setOutputFormat(int outputFormat) { 64 | mOutputFormat = outputFormat; 65 | } 66 | 67 | @Override 68 | protected void encodeWithMediaRecorder() throws IOException { 69 | 70 | // We need a local socket to forward data output by the camera to the packetizer 71 | createSockets(); 72 | 73 | Log.v(TAG,"Requested audio with "+mQuality.bitRate/1000+"kbps"+" at "+mQuality.samplingRate/1000+"kHz"); 74 | 75 | mMediaRecorder = new MediaRecorder(); 76 | mMediaRecorder.setAudioSource(mAudioSource); 77 | mMediaRecorder.setOutputFormat(mOutputFormat); 78 | mMediaRecorder.setAudioEncoder(mAudioEncoder); 79 | mMediaRecorder.setAudioChannels(1); 80 | mMediaRecorder.setAudioSamplingRate(mQuality.samplingRate); 81 | mMediaRecorder.setAudioEncodingBitRate(mQuality.bitRate); 82 | 83 | // We write the ouput of the camera in a local socket instead of a file ! 84 | // This one little trick makes streaming feasible quiet simply: data from the camera 85 | // can then be manipulated at the other end of the socket 86 | mMediaRecorder.setOutputFile(mSender.getFileDescriptor()); 87 | 88 | mMediaRecorder.prepare(); 89 | mMediaRecorder.start(); 90 | 91 | try { 92 | // mReceiver.getInputStream contains the data from the camera 93 | // the mPacketizer encapsulates this stream in an RTP stream and send it over the network 94 | mPacketizer.setDestination(mDestination, mRtpPort, mRtcpPort); 95 | mPacketizer.setInputStream(mReceiver.getInputStream()); 96 | mPacketizer.start(); 97 | mStreaming = true; 98 | } catch (IOException e) { 99 | stop(); 100 | throw new IOException("Something happened with the local sockets :/ Start failed !"); 101 | } 102 | 103 | } 104 | 105 | } 106 | -------------------------------------------------------------------------------- /app/src/main/java/net/majorkernelpanic/streaming/exceptions/CameraInUseException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2011-2014 GUIGUI Simon, fyhertz@gmail.com 3 | * 4 | * This file is part of libstreaming (https://github.com/fyhertz/libstreaming) 5 | * 6 | * Spydroid is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This source code is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this source code; if not, write to the Free Software 18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 19 | */ 20 | 21 | package net.majorkernelpanic.streaming.exceptions; 22 | 23 | public class CameraInUseException extends RuntimeException { 24 | 25 | public CameraInUseException(String message) { 26 | super(message); 27 | } 28 | 29 | private static final long serialVersionUID = -1866132102949435675L; 30 | } 31 | -------------------------------------------------------------------------------- /app/src/main/java/net/majorkernelpanic/streaming/exceptions/ConfNotSupportedException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2011-2014 GUIGUI Simon, fyhertz@gmail.com 3 | * 4 | * This file is part of libstreaming (https://github.com/fyhertz/libstreaming) 5 | * 6 | * Spydroid is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This source code is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this source code; if not, write to the Free Software 18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 19 | */ 20 | 21 | package net.majorkernelpanic.streaming.exceptions; 22 | 23 | public class ConfNotSupportedException extends RuntimeException { 24 | 25 | public ConfNotSupportedException(String message) { 26 | super(message); 27 | } 28 | 29 | private static final long serialVersionUID = 5876298277802827615L; 30 | } 31 | -------------------------------------------------------------------------------- /app/src/main/java/net/majorkernelpanic/streaming/exceptions/InvalidSurfaceException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2011-2014 GUIGUI Simon, fyhertz@gmail.com 3 | * 4 | * This file is part of libstreaming (https://github.com/fyhertz/libstreaming) 5 | * 6 | * Spydroid is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This source code is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this source code; if not, write to the Free Software 18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 19 | */ 20 | 21 | package net.majorkernelpanic.streaming.exceptions; 22 | 23 | public class InvalidSurfaceException extends RuntimeException { 24 | 25 | private static final long serialVersionUID = -7238661340093544496L; 26 | 27 | public InvalidSurfaceException(String message) { 28 | super(message); 29 | } 30 | 31 | } 32 | -------------------------------------------------------------------------------- /app/src/main/java/net/majorkernelpanic/streaming/exceptions/StorageUnavailableException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2011-2014 GUIGUI Simon, fyhertz@gmail.com 3 | * 4 | * This file is part of libstreaming (https://github.com/fyhertz/libstreaming) 5 | * 6 | * Spydroid is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This source code is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this source code; if not, write to the Free Software 18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 19 | */ 20 | 21 | package net.majorkernelpanic.streaming.exceptions; 22 | 23 | import java.io.IOException; 24 | 25 | public class StorageUnavailableException extends IOException { 26 | 27 | public StorageUnavailableException(String message) { 28 | super(message); 29 | } 30 | 31 | private static final long serialVersionUID = -7537890350373995089L; 32 | } 33 | -------------------------------------------------------------------------------- /app/src/main/java/net/majorkernelpanic/streaming/gl/SurfaceView.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2011-2014 GUIGUI Simon, fyhertz@gmail.com 3 | * 4 | * This file is part of libstreaming (https://github.com/fyhertz/libstreaming) 5 | * 6 | * Spydroid is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This source code is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this source code; if not, write to the Free Software 18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 19 | */ 20 | 21 | package net.majorkernelpanic.streaming.gl; 22 | 23 | import java.util.concurrent.Semaphore; 24 | 25 | import android.content.Context; 26 | import android.graphics.SurfaceTexture; 27 | import android.graphics.SurfaceTexture.OnFrameAvailableListener; 28 | import android.util.AttributeSet; 29 | import android.util.Log; 30 | import android.view.Surface; 31 | import android.view.SurfaceHolder; 32 | 33 | public class SurfaceView extends android.view.SurfaceView implements Runnable, OnFrameAvailableListener, SurfaceHolder.Callback { 34 | 35 | public final static String TAG = "GLSurfaceView"; 36 | 37 | private Thread mThread = null; 38 | private boolean mFrameAvailable = false; 39 | private boolean mRunning = true; 40 | 41 | private SurfaceManager mViewSurfaceManager = null; 42 | private SurfaceManager mCodecSurfaceManager = null; 43 | private TextureManager mTextureManager = null; 44 | 45 | private Semaphore mLock = new Semaphore(0); 46 | private Object mSyncObject = new Object(); 47 | 48 | public SurfaceView(Context context, AttributeSet attrs) { 49 | super(context, attrs); 50 | getHolder().addCallback(this); 51 | } 52 | 53 | public SurfaceTexture getSurfaceTexture() { 54 | return mTextureManager.getSurfaceTexture(); 55 | } 56 | 57 | public void addMediaCodecSurface(Surface surface) { 58 | synchronized (mSyncObject) { 59 | mCodecSurfaceManager = new SurfaceManager(surface,mViewSurfaceManager); 60 | } 61 | } 62 | 63 | public void removeMediaCodecSurface() { 64 | synchronized (mSyncObject) { 65 | if (mCodecSurfaceManager != null) { 66 | mCodecSurfaceManager.release(); 67 | mCodecSurfaceManager = null; 68 | } 69 | } 70 | } 71 | 72 | public void startGLThread() { 73 | Log.d(TAG,"Thread started."); 74 | if (mTextureManager == null) { 75 | mTextureManager = new TextureManager(); 76 | } 77 | if (mTextureManager.getSurfaceTexture() == null) { 78 | mThread = new Thread(SurfaceView.this); 79 | mRunning = true; 80 | mThread.start(); 81 | mLock.acquireUninterruptibly(); 82 | } 83 | } 84 | 85 | @Override 86 | public void run() { 87 | 88 | mViewSurfaceManager = new SurfaceManager(getHolder().getSurface()); 89 | mViewSurfaceManager.makeCurrent(); 90 | mTextureManager.createTexture().setOnFrameAvailableListener(this); 91 | 92 | mLock.release(); 93 | 94 | try { 95 | long ts = 0, oldts = 0; 96 | while (mRunning) { 97 | synchronized (mSyncObject) { 98 | mSyncObject.wait(2500); 99 | if (mFrameAvailable) { 100 | mFrameAvailable = false; 101 | 102 | mViewSurfaceManager.makeCurrent(); 103 | mTextureManager.updateFrame(); 104 | mTextureManager.drawFrame(); 105 | mViewSurfaceManager.swapBuffer(); 106 | 107 | if (mCodecSurfaceManager != null) { 108 | mCodecSurfaceManager.makeCurrent(); 109 | mTextureManager.drawFrame(); 110 | oldts = ts; 111 | ts = mTextureManager.getSurfaceTexture().getTimestamp(); 112 | //Log.d(TAG,"FPS: "+(1000000000/(ts-oldts))); 113 | mCodecSurfaceManager.setPresentationTime(ts); 114 | mCodecSurfaceManager.swapBuffer(); 115 | } 116 | 117 | } else { 118 | Log.e(TAG,"No frame received !"); 119 | } 120 | } 121 | } 122 | } catch (InterruptedException ignore) { 123 | } finally { 124 | mViewSurfaceManager.release(); 125 | mTextureManager.release(); 126 | } 127 | } 128 | 129 | @Override 130 | public void onFrameAvailable(SurfaceTexture surfaceTexture) { 131 | synchronized (mSyncObject) { 132 | mFrameAvailable = true; 133 | mSyncObject.notifyAll(); 134 | } 135 | } 136 | 137 | @Override 138 | public void surfaceChanged(SurfaceHolder holder, int format, int width, 139 | int height) { 140 | } 141 | 142 | @Override 143 | public void surfaceCreated(SurfaceHolder holder) { 144 | } 145 | 146 | @Override 147 | public void surfaceDestroyed(SurfaceHolder holder) { 148 | if (mThread != null) { 149 | mThread.interrupt(); 150 | } 151 | mRunning = false; 152 | } 153 | 154 | } 155 | -------------------------------------------------------------------------------- /app/src/main/java/net/majorkernelpanic/streaming/hw/NV21Convertor.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2011-2014 GUIGUI Simon, fyhertz@gmail.com 3 | * 4 | * This file is part of Spydroid (http://code.google.com/p/spydroid-ipcamera/) 5 | * 6 | * Spydroid is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This source code is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this source code; if not, write to the Free Software 18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 19 | */ 20 | 21 | package net.majorkernelpanic.streaming.hw; 22 | 23 | import java.nio.ByteBuffer; 24 | 25 | import android.media.MediaCodecInfo; 26 | 27 | /** 28 | * Converts from NV21 to YUV420 semi planar or planar. 29 | */ 30 | public class NV21Convertor { 31 | 32 | private int mSliceHeight, mHeight; 33 | private int mStride, mWidth; 34 | private int mSize; 35 | private boolean mPlanar, mPanesReversed = false; 36 | private int mYPadding; 37 | private byte[] mBuffer; 38 | ByteBuffer mCopy; 39 | 40 | public void setSize(int width, int height) { 41 | mHeight = height; 42 | mWidth = width; 43 | mSliceHeight = height; 44 | mStride = width; 45 | mSize = mWidth*mHeight; 46 | } 47 | 48 | public void setStride(int width) { 49 | mStride = width; 50 | } 51 | 52 | public void setSliceHeigth(int height) { 53 | mSliceHeight = height; 54 | } 55 | 56 | public void setPlanar(boolean planar) { 57 | mPlanar = planar; 58 | } 59 | 60 | public void setYPadding(int padding) { 61 | mYPadding = padding; 62 | } 63 | 64 | public int getBufferSize() { 65 | return 3*mSize/2; 66 | } 67 | 68 | public void setEncoderColorFormat(int colorFormat) { 69 | switch (colorFormat) { 70 | case MediaCodecInfo.CodecCapabilities.COLOR_FormatYUV420SemiPlanar: 71 | case MediaCodecInfo.CodecCapabilities.COLOR_FormatYUV420PackedSemiPlanar: 72 | case MediaCodecInfo.CodecCapabilities.COLOR_TI_FormatYUV420PackedSemiPlanar: 73 | setPlanar(false); 74 | break; 75 | case MediaCodecInfo.CodecCapabilities.COLOR_FormatYUV420Planar: 76 | case MediaCodecInfo.CodecCapabilities.COLOR_FormatYUV420PackedPlanar: 77 | setPlanar(true); 78 | break; 79 | } 80 | } 81 | 82 | public void setColorPanesReversed(boolean b) { 83 | mPanesReversed = b; 84 | } 85 | 86 | public int getStride() { 87 | return mStride; 88 | } 89 | 90 | public int getSliceHeigth() { 91 | return mSliceHeight; 92 | } 93 | 94 | public int getYPadding() { 95 | return mYPadding; 96 | } 97 | 98 | 99 | public boolean getPlanar() { 100 | return mPlanar; 101 | } 102 | 103 | public boolean getUVPanesReversed() { 104 | return mPanesReversed; 105 | } 106 | 107 | public void convert(byte[] data, ByteBuffer buffer) { 108 | byte[] result = convert(data); 109 | buffer.put(result, 0, result.length); 110 | } 111 | 112 | public byte[] convert(byte[] data) { 113 | 114 | // A buffer large enough for every case 115 | if (mBuffer==null || mBuffer.length != 3*mSliceHeight*mStride/2+mYPadding) { 116 | mBuffer = new byte[3*mSliceHeight*mStride/2+mYPadding]; 117 | } 118 | 119 | if (!mPlanar) { 120 | if (mSliceHeight==mHeight && mStride==mWidth) { 121 | // Swaps U and V 122 | if (!mPanesReversed) { 123 | for (int i = mSize; i < mSize+mSize/2; i += 2) { 124 | mBuffer[0] = data[i+1]; 125 | data[i+1] = data[i]; 126 | data[i] = mBuffer[0]; 127 | } 128 | } 129 | if (mYPadding>0) { 130 | System.arraycopy(data, 0, mBuffer, 0, mSize); 131 | System.arraycopy(data, mSize, mBuffer, mSize+mYPadding, mSize/2); 132 | return mBuffer; 133 | } 134 | return data; 135 | } 136 | } else { 137 | if (mSliceHeight==mHeight && mStride==mWidth) { 138 | // De-interleave U and V 139 | if (!mPanesReversed) { 140 | for (int i = 0; i < mSize/4; i+=1) { 141 | mBuffer[i] = data[mSize+2*i+1]; 142 | mBuffer[mSize/4+i] = data[mSize+2*i]; 143 | } 144 | } else { 145 | for (int i = 0; i < mSize/4; i+=1) { 146 | mBuffer[i] = data[mSize+2*i]; 147 | mBuffer[mSize/4+i] = data[mSize+2*i+1]; 148 | } 149 | } 150 | if (mYPadding == 0) { 151 | System.arraycopy(mBuffer, 0, data, mSize, mSize/2); 152 | } else { 153 | System.arraycopy(data, 0, mBuffer, 0, mSize); 154 | System.arraycopy(mBuffer, 0, mBuffer, mSize+mYPadding, mSize/2); 155 | return mBuffer; 156 | } 157 | return data; 158 | } 159 | } 160 | 161 | return data; 162 | } 163 | 164 | } 165 | -------------------------------------------------------------------------------- /app/src/main/java/net/majorkernelpanic/streaming/mp4/MP4Config.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2011-2014 GUIGUI Simon, fyhertz@gmail.com 3 | * 4 | * This file is part of libstreaming (https://github.com/fyhertz/libstreaming) 5 | * 6 | * Spydroid is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This source code is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this source code; if not, write to the Free Software 18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 19 | */ 20 | 21 | package net.majorkernelpanic.streaming.mp4; 22 | import java.io.FileNotFoundException; 23 | import java.io.IOException; 24 | 25 | import android.util.Base64; 26 | import android.util.Log; 27 | 28 | /** 29 | * Finds SPS & PPS parameters in mp4 file. 30 | */ 31 | public class MP4Config { 32 | 33 | public final static String TAG = "MP4Config"; 34 | 35 | private MP4Parser mp4Parser; 36 | private String mProfilLevel, mPPS, mSPS; 37 | 38 | public MP4Config(String profil, String sps, String pps) { 39 | mProfilLevel = profil; 40 | mPPS = pps; 41 | mSPS = sps; 42 | } 43 | 44 | public MP4Config(String sps, String pps) { 45 | mPPS = pps; 46 | mSPS = sps; 47 | mProfilLevel = MP4Parser.toHexString(Base64.decode(sps, Base64.NO_WRAP),1,3); 48 | } 49 | 50 | public MP4Config(byte[] sps, byte[] pps) { 51 | mPPS = Base64.encodeToString(pps, 0, pps.length, Base64.NO_WRAP); 52 | mSPS = Base64.encodeToString(sps, 0, sps.length, Base64.NO_WRAP); 53 | mProfilLevel = MP4Parser.toHexString(sps,1,3); 54 | } 55 | 56 | /** 57 | * Finds sps & pps parameters inside a .mp4. 58 | * @param path Path to the file to analyze 59 | * @throws IOException 60 | * @throws FileNotFoundException 61 | */ 62 | public MP4Config (String path) throws IOException, FileNotFoundException { 63 | 64 | StsdBox stsdBox; 65 | 66 | // We open the mp4 file 67 | mp4Parser = new MP4Parser(path); 68 | 69 | // We parse it 70 | try { 71 | mp4Parser.parse(); 72 | } catch (IOException ignore) { 73 | // Maybe enough of the file has been parsed and we can get the stsd box 74 | } 75 | 76 | // We find the stsdBox 77 | stsdBox = mp4Parser.getStsdBox(); 78 | mPPS = stsdBox.getB64PPS(); 79 | mSPS = stsdBox.getB64SPS(); 80 | mProfilLevel = stsdBox.getProfileLevel(); 81 | 82 | // We're done ! 83 | mp4Parser.close(); 84 | 85 | } 86 | 87 | public String getProfileLevel() { 88 | return mProfilLevel; 89 | } 90 | 91 | public String getB64PPS() { 92 | Log.d(TAG, "PPS: "+mPPS); 93 | return mPPS; 94 | } 95 | 96 | public String getB64SPS() { 97 | Log.d(TAG, "SPS: "+mSPS); 98 | return mSPS; 99 | } 100 | 101 | } -------------------------------------------------------------------------------- /app/src/main/java/net/majorkernelpanic/streaming/rtcp/SenderReport.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2011-2014 GUIGUI Simon, fyhertz@gmail.com 3 | * 4 | * This file is part of libstreaming (https://github.com/fyhertz/libstreaming) 5 | * 6 | * Spydroid is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This source code is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this source code; if not, write to the Free Software 18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 19 | */ 20 | 21 | package net.majorkernelpanic.streaming.rtcp; 22 | 23 | import java.io.IOException; 24 | import java.net.DatagramPacket; 25 | import java.net.InetAddress; 26 | import java.net.MulticastSocket; 27 | import java.nio.channels.IllegalSelectorException; 28 | 29 | import android.os.SystemClock; 30 | import android.util.Log; 31 | 32 | /** 33 | * Implementation of Sender Report RTCP packets. 34 | */ 35 | public class SenderReport { 36 | 37 | public static final int MTU = 1500; 38 | 39 | private MulticastSocket usock; 40 | private DatagramPacket upack; 41 | 42 | private byte[] buffer = new byte[MTU]; 43 | private int ssrc, port = -1; 44 | private int octetCount = 0, packetCount = 0; 45 | private long interval, delta, now, oldnow; 46 | 47 | public SenderReport(int ssrc) throws IOException { 48 | super(); 49 | this.ssrc = ssrc; 50 | } 51 | 52 | public SenderReport() { 53 | 54 | /* Version(2) Padding(0) */ 55 | /* ^ ^ PT = 0 */ 56 | /* | | ^ */ 57 | /* | -------- | */ 58 | /* | |--------------------- */ 59 | /* | || */ 60 | /* | || */ 61 | buffer[0] = (byte) Integer.parseInt("10000000",2); 62 | 63 | /* Packet Type PT */ 64 | buffer[1] = (byte) 200; 65 | 66 | /* Byte 2,3 -> Length */ 67 | setLong(28/4-1, 2, 4); 68 | 69 | /* Byte 4,5,6,7 -> SSRC */ 70 | /* Byte 8,9,10,11 -> NTP timestamp hb */ 71 | /* Byte 12,13,14,15 -> NTP timestamp lb */ 72 | /* Byte 16,17,18,19 -> RTP timestamp */ 73 | /* Byte 20,21,22,23 -> packet count */ 74 | /* Byte 24,25,26,27 -> octet count */ 75 | 76 | try { 77 | usock = new MulticastSocket(); 78 | } catch (IOException e) { 79 | throw new RuntimeException(e.getMessage()); 80 | } 81 | upack = new DatagramPacket(buffer, 1); 82 | 83 | // By default we sent one report every 5 secconde 84 | interval = 3000; 85 | 86 | } 87 | 88 | public void close() { 89 | usock.close(); 90 | } 91 | 92 | /** 93 | * Sets the temporal interval between two RTCP Sender Reports. 94 | * Default interval is set to 5 secondes. 95 | * Set 0 to disable RTCP. 96 | * @param interval The interval in milliseconds 97 | */ 98 | public void setInterval(long interval) { 99 | this.interval = interval; 100 | } 101 | 102 | /** 103 | * Updates the number of packets sent, and the total amount of data sent. 104 | * @param length The length of the packet 105 | * @throws IOException 106 | **/ 107 | public void update(int length, long ntpts, long rtpts) throws IOException { 108 | packetCount += 1; 109 | octetCount += length; 110 | setLong(packetCount, 20, 24); 111 | setLong(octetCount, 24, 28); 112 | 113 | now = SystemClock.elapsedRealtime(); 114 | delta += oldnow != 0 ? now-oldnow : 0; 115 | oldnow = now; 116 | if (interval>0) { 117 | if (delta>=interval) { 118 | // We send a Sender Report 119 | send(ntpts,rtpts); 120 | delta = 0; 121 | } 122 | } 123 | 124 | } 125 | 126 | public void setSSRC(int ssrc) { 127 | this.ssrc = ssrc; 128 | setLong(ssrc,4,8); 129 | packetCount = 0; 130 | octetCount = 0; 131 | setLong(packetCount, 20, 24); 132 | setLong(octetCount, 24, 28); 133 | } 134 | 135 | public void setDestination(InetAddress dest, int dport) { 136 | port = dport; 137 | upack.setPort(dport); 138 | upack.setAddress(dest); 139 | } 140 | 141 | public int getPort() { 142 | return port; 143 | } 144 | 145 | public int getLocalPort() { 146 | return usock.getLocalPort(); 147 | } 148 | 149 | public int getSSRC() { 150 | return ssrc; 151 | } 152 | 153 | /** 154 | * Resets the reports (total number of bytes sent, number of packets sent, etc.) 155 | */ 156 | public void reset() { 157 | packetCount = 0; 158 | octetCount = 0; 159 | setLong(packetCount, 20, 24); 160 | setLong(octetCount, 24, 28); 161 | delta = now = oldnow = 0; 162 | } 163 | 164 | private void setLong(long n, int begin, int end) { 165 | for (end--; end >= begin; end--) { 166 | buffer[end] = (byte) (n % 256); 167 | n >>= 8; 168 | } 169 | } 170 | 171 | /** Sends the RTCP packet over the network. */ 172 | private void send(long ntpts, long rtpts) throws IOException { 173 | long hb = ntpts/1000000000; 174 | long lb = ( ( ntpts - hb*1000000000 ) * 4294967296L )/1000000000; 175 | setLong(hb, 8, 12); 176 | setLong(lb, 12, 16); 177 | setLong(rtpts, 16, 20); 178 | upack.setLength(28); 179 | usock.send(upack); 180 | } 181 | 182 | 183 | } 184 | -------------------------------------------------------------------------------- /app/src/main/java/net/majorkernelpanic/streaming/rtp/AACLATMPacketizer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2011-2014 GUIGUI Simon, fyhertz@gmail.com 3 | * 4 | * This file is part of libstreaming (https://github.com/fyhertz/libstreaming) 5 | * 6 | * Spydroid is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This source code is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this source code; if not, write to the Free Software 18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 19 | */ 20 | 21 | package net.majorkernelpanic.streaming.rtp; 22 | 23 | import java.io.IOException; 24 | 25 | import android.annotation.SuppressLint; 26 | import android.media.MediaCodec.BufferInfo; 27 | import android.os.SystemClock; 28 | import android.util.Log; 29 | 30 | /** 31 | * RFC 3640. 32 | * 33 | * Encapsulates AAC Access Units in RTP packets as specified in the RFC 3640. 34 | * This packetizer is used by the AACStream class in conjunction with the 35 | * MediaCodec API introduced in Android 4.1 (API Level 16). 36 | * 37 | */ 38 | @SuppressLint("NewApi") 39 | public class AACLATMPacketizer extends AbstractPacketizer implements Runnable { 40 | 41 | private final static String TAG = "AACLATMPacketizer"; 42 | 43 | private Thread t; 44 | 45 | public AACLATMPacketizer() { 46 | super(); 47 | socket.setCacheSize(0); 48 | } 49 | 50 | public void start() { 51 | if (t==null) { 52 | t = new Thread(this); 53 | t.start(); 54 | } 55 | } 56 | 57 | public void stop() { 58 | if (t != null) { 59 | try { 60 | is.close(); 61 | } catch (IOException ignore) {} 62 | t.interrupt(); 63 | try { 64 | t.join(); 65 | } catch (InterruptedException e) {} 66 | t = null; 67 | } 68 | } 69 | 70 | public void setSamplingRate(int samplingRate) { 71 | socket.setClockFrequency(samplingRate); 72 | } 73 | 74 | @SuppressLint("NewApi") 75 | public void run() { 76 | 77 | Log.d(TAG,"AAC LATM packetizer started !"); 78 | 79 | int length = 0; 80 | long oldts; 81 | BufferInfo bufferInfo; 82 | 83 | try { 84 | while (!Thread.interrupted()) { 85 | buffer = socket.requestBuffer(); 86 | length = is.read(buffer, rtphl+4, MAXPACKETSIZE-(rtphl+4)); 87 | 88 | if (length>0) { 89 | 90 | bufferInfo = ((MediaCodecInputStream)is).getLastBufferInfo(); 91 | //Log.d(TAG,"length: "+length+" ts: "+bufferInfo.presentationTimeUs); 92 | oldts = ts; 93 | ts = bufferInfo.presentationTimeUs*1000; 94 | 95 | // Seems to happen sometimes 96 | if (oldts>ts) { 97 | socket.commitBuffer(); 98 | continue; 99 | } 100 | 101 | socket.markNextPacket(); 102 | socket.updateTimestamp(ts); 103 | 104 | // AU-headers-length field: contains the size in bits of a AU-header 105 | // 13+3 = 16 bits -> 13bits for AU-size and 3bits for AU-Index / AU-Index-delta 106 | // 13 bits will be enough because ADTS uses 13 bits for frame length 107 | buffer[rtphl] = 0; 108 | buffer[rtphl+1] = 0x10; 109 | 110 | // AU-size 111 | buffer[rtphl+2] = (byte) (length>>5); 112 | buffer[rtphl+3] = (byte) (length<<3); 113 | 114 | // AU-Index 115 | buffer[rtphl+3] &= 0xF8; 116 | buffer[rtphl+3] |= 0x00; 117 | 118 | send(rtphl+length+4); 119 | 120 | } else { 121 | socket.commitBuffer(); 122 | } 123 | 124 | } 125 | } catch (IOException e) { 126 | } catch (ArrayIndexOutOfBoundsException e) { 127 | Log.e(TAG,"ArrayIndexOutOfBoundsException: "+(e.getMessage()!=null?e.getMessage():"unknown error")); 128 | e.printStackTrace(); 129 | } catch (InterruptedException ignore) {} 130 | 131 | Log.d(TAG,"AAC LATM packetizer stopped !"); 132 | 133 | } 134 | 135 | } 136 | -------------------------------------------------------------------------------- /app/src/main/java/net/majorkernelpanic/streaming/rtp/AMRNBPacketizer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2011-2014 GUIGUI Simon, fyhertz@gmail.com 3 | * 4 | * This file is part of libstreaming (https://github.com/fyhertz/libstreaming) 5 | * 6 | * Spydroid is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This source code is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this source code; if not, write to the Free Software 18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 19 | */ 20 | 21 | package net.majorkernelpanic.streaming.rtp; 22 | 23 | import java.io.IOException; 24 | 25 | import android.util.Log; 26 | 27 | /** 28 | * 29 | * RFC 3267. 30 | * 31 | * AMR Streaming over RTP. 32 | * 33 | * Must be fed with an InputStream containing raw amr nb 34 | * Stream must begin with a 6 bytes long header: "#!AMR\n", it will be skipped 35 | * 36 | */ 37 | public class AMRNBPacketizer extends AbstractPacketizer implements Runnable { 38 | 39 | public final static String TAG = "AMRNBPacketizer"; 40 | 41 | private final int AMR_HEADER_LENGTH = 6; // "#!AMR\n" 42 | private static final int AMR_FRAME_HEADER_LENGTH = 1; // Each frame has a short header 43 | private static final int[] sFrameBits = {95, 103, 118, 134, 148, 159, 204, 244}; 44 | private int samplingRate = 8000; 45 | 46 | private Thread t; 47 | 48 | public AMRNBPacketizer() { 49 | super(); 50 | socket.setClockFrequency(samplingRate); 51 | } 52 | 53 | public void start() { 54 | if (t==null) { 55 | t = new Thread(this); 56 | t.start(); 57 | } 58 | } 59 | 60 | public void stop() { 61 | if (t != null) { 62 | try { 63 | is.close(); 64 | } catch (IOException ignore) {} 65 | t.interrupt(); 66 | try { 67 | t.join(); 68 | } catch (InterruptedException e) {} 69 | t = null; 70 | } 71 | } 72 | 73 | public void run() { 74 | 75 | int frameLength, frameType; 76 | long now = System.nanoTime(), oldtime = now; 77 | byte[] header = new byte[AMR_HEADER_LENGTH]; 78 | 79 | try { 80 | 81 | // Skip raw amr header 82 | fill(header,0,AMR_HEADER_LENGTH); 83 | 84 | if (header[5] != '\n') { 85 | Log.e(TAG,"Bad header ! AMR not correcty supported by the phone !"); 86 | return; 87 | } 88 | 89 | while (!Thread.interrupted()) { 90 | 91 | buffer = socket.requestBuffer(); 92 | buffer[rtphl] = (byte) 0xF0; 93 | 94 | // First we read the frame header 95 | fill(buffer, rtphl+1,AMR_FRAME_HEADER_LENGTH); 96 | 97 | // Then we calculate the frame payload length 98 | frameType = (Math.abs(buffer[rtphl + 1]) >> 3) & 0x0f; 99 | frameLength = (sFrameBits[frameType]+7)/8; 100 | 101 | // And we read the payload 102 | fill(buffer, rtphl+2,frameLength); 103 | 104 | //Log.d(TAG,"Frame length: "+frameLength+" frameType: "+frameType); 105 | 106 | // RFC 3267 Page 14: "For AMR, the sampling frequency is 8 kHz" 107 | // FIXME: Is this really always the case ?? 108 | ts += 160L*1000000000L/samplingRate; //stats.average(); 109 | socket.updateTimestamp(ts); 110 | socket.markNextPacket(); 111 | 112 | //Log.d(TAG,"expected: "+ expected + " measured: "+measured); 113 | 114 | send(rtphl+1+AMR_FRAME_HEADER_LENGTH+frameLength); 115 | 116 | } 117 | 118 | } catch (IOException e) { 119 | } catch (InterruptedException e) {} 120 | 121 | Log.d(TAG,"AMR packetizer stopped !"); 122 | 123 | } 124 | 125 | private int fill(byte[] buffer, int offset,int length) throws IOException { 126 | int sum = 0, len; 127 | while (sumperiod) { 139 | elapsed = 0; 140 | long now = System.nanoTime(); 141 | if (!initoffset || (now - start < 0)) { 142 | start = now; 143 | duration = 0; 144 | initoffset = true; 145 | } 146 | // Prevents drifting issues by comparing the real duration of the 147 | // stream with the sum of all temporal lengths of RTP packets. 148 | value += (now - start) - duration; 149 | //Log.d(TAG, "sum1: "+duration/1000000+" sum2: "+(now-start)/1000000+" drift: "+((now-start)-duration)/1000000+" v: "+value/1000000); 150 | } 151 | if (c<5) { 152 | // We ignore the first 20 measured values because they may not be accurate 153 | c++; 154 | m = value; 155 | } else { 156 | m = (m*q+value)/(q+1); 157 | if (q>2; 99 | //Log.d(TAG,"j: "+j+" buffer: "+printBuffer(rtphl, rtphl+5)+" tr: "+tr); 100 | if (firstFragment) { 101 | // This is the first fragment of the frame -> header is set to 0x0400 102 | buffer[rtphl] = 4; 103 | firstFragment = false; 104 | } else { 105 | buffer[rtphl] = 0; 106 | } 107 | if (j>0) { 108 | // We have found the end of the frame 109 | stats.push(duration); 110 | ts+= stats.average(); duration = 0; 111 | //Log.d(TAG,"End of frame ! duration: "+stats.average()); 112 | // The last fragment of a frame has to be marked 113 | socket.markNextPacket(); 114 | send(j); 115 | nextBuffer = socket.requestBuffer(); 116 | System.arraycopy(buffer,j+2,nextBuffer,rtphl+2,MAXPACKETSIZE-j-2); 117 | buffer = nextBuffer; 118 | j = MAXPACKETSIZE-j-2; 119 | firstFragment = true; 120 | } else { 121 | // We have not found the beginning of another frame 122 | // The whole packet is a fragment of a frame 123 | send(MAXPACKETSIZE); 124 | } 125 | } 126 | } catch (IOException e) { 127 | } catch (InterruptedException e) {} 128 | 129 | Log.d(TAG,"H263 Packetizer stopped !"); 130 | 131 | } 132 | 133 | private int fill(int offset,int length) throws IOException { 134 | 135 | int sum = 0, len; 136 | 137 | while (sum=0 ){ 76 | //Log.d(TAG,"Index: "+mIndex+" Time: "+mBufferInfo.presentationTimeUs+" size: "+mBufferInfo.size); 77 | mBuffer = mBuffers[mIndex]; 78 | mBuffer.position(0); 79 | break; 80 | } else if (mIndex == MediaCodec.INFO_OUTPUT_BUFFERS_CHANGED) { 81 | mBuffers = mMediaCodec.getOutputBuffers(); 82 | } else if (mIndex == MediaCodec.INFO_OUTPUT_FORMAT_CHANGED) { 83 | mMediaFormat = mMediaCodec.getOutputFormat(); 84 | Log.i(TAG,mMediaFormat.toString()); 85 | } else if (mIndex == MediaCodec.INFO_TRY_AGAIN_LATER) { 86 | Log.v(TAG,"No buffer available..."); 87 | //return 0; 88 | } else { 89 | Log.e(TAG,"Message: "+mIndex); 90 | //return 0; 91 | } 92 | } 93 | } 94 | 95 | if (mClosed) throw new IOException("This InputStream was closed"); 96 | 97 | min = length < mBufferInfo.size - mBuffer.position() ? length : mBufferInfo.size - mBuffer.position(); 98 | mBuffer.get(buffer, offset, min); 99 | if (mBuffer.position()>=mBufferInfo.size) { 100 | mMediaCodec.releaseOutputBuffer(mIndex, false); 101 | mBuffer = null; 102 | } 103 | 104 | } catch (RuntimeException e) { 105 | e.printStackTrace(); 106 | } 107 | 108 | return min; 109 | } 110 | 111 | public int available() { 112 | if (mBuffer != null) 113 | return mBufferInfo.size - mBuffer.position(); 114 | else 115 | return 0; 116 | } 117 | 118 | public BufferInfo getLastBufferInfo() { 119 | return mBufferInfo; 120 | } 121 | 122 | } 123 | -------------------------------------------------------------------------------- /app/src/main/java/net/majorkernelpanic/streaming/video/H263Stream.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2011-2014 GUIGUI Simon, fyhertz@gmail.com 3 | * 4 | * This file is part of libstreaming (https://github.com/fyhertz/libstreaming) 5 | * 6 | * Spydroid is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This source code is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this source code; if not, write to the Free Software 18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 19 | */ 20 | 21 | package net.majorkernelpanic.streaming.video; 22 | 23 | import java.io.IOException; 24 | 25 | import net.majorkernelpanic.streaming.SessionBuilder; 26 | import net.majorkernelpanic.streaming.rtp.H263Packetizer; 27 | import android.graphics.ImageFormat; 28 | import android.hardware.Camera.CameraInfo; 29 | import android.media.MediaRecorder; 30 | import android.service.textservice.SpellCheckerService.Session; 31 | 32 | /** 33 | * A class for streaming H.263 from the camera of an android device using RTP. 34 | * You should use a {@link Session} instantiated with {@link SessionBuilder} instead of using this class directly. 35 | * Call {@link #setDestinationAddress(InetAddress)}, {@link #setDestinationPorts(int)} and {@link #setVideoQuality(VideoQuality)} 36 | * to configure the stream. You can then call {@link #start()} to start the RTP stream. 37 | * Call {@link #stop()} to stop the stream. 38 | */ 39 | public class H263Stream extends VideoStream { 40 | 41 | /** 42 | * Constructs the H.263 stream. 43 | * Uses CAMERA_FACING_BACK by default. 44 | * @throws IOException 45 | */ 46 | public H263Stream() throws IOException { 47 | this(CameraInfo.CAMERA_FACING_BACK); 48 | } 49 | 50 | /** 51 | * Constructs the H.263 stream. 52 | * @param cameraId Can be either CameraInfo.CAMERA_FACING_BACK or CameraInfo.CAMERA_FACING_FRONT 53 | * @throws IOException 54 | */ 55 | public H263Stream(int cameraId) { 56 | super(cameraId); 57 | mCameraImageFormat = ImageFormat.NV21; 58 | mVideoEncoder = MediaRecorder.VideoEncoder.H263; 59 | mPacketizer = new H263Packetizer(); 60 | } 61 | 62 | /** 63 | * Starts the stream. 64 | */ 65 | public synchronized void start() throws IllegalStateException, IOException { 66 | configure(); 67 | if (!mStreaming) { 68 | super.start(); 69 | } 70 | } 71 | 72 | public synchronized void configure() throws IllegalStateException, IOException { 73 | super.configure(); 74 | mMode = MODE_MEDIARECORDER_API; 75 | mQuality = mRequestedQuality.clone(); 76 | } 77 | 78 | /** 79 | * Returns a description of the stream using SDP. It can then be included in an SDP file. 80 | */ 81 | public String getSessionDescription() { 82 | return "m=video "+String.valueOf(getDestinationPorts()[0])+" RTP/AVP 96\r\n" + 83 | "a=rtpmap:96 H263-1998/90000\r\n"; 84 | } 85 | 86 | } 87 | -------------------------------------------------------------------------------- /app/src/main/res/anim/pulse.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 13 | 14 | -------------------------------------------------------------------------------- /app/src/main/res/drawable-hdpi/background.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/extinguish/onvif-camera/47445b42823d3b96670413ead36a37505d0e8b7d/app/src/main/res/drawable-hdpi/background.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-hdpi/check.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/extinguish/onvif-camera/47445b42823d3b96670413ead36a37505d0e8b7d/app/src/main/res/drawable-hdpi/check.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-hdpi/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/extinguish/onvif-camera/47445b42823d3b96670413ead36a37505d0e8b7d/app/src/main/res/drawable-hdpi/icon.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-hdpi/quit.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/extinguish/onvif-camera/47445b42823d3b96670413ead36a37505d0e8b7d/app/src/main/res/drawable-hdpi/quit.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-hdpi/settings.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/extinguish/onvif-camera/47445b42823d3b96670413ead36a37505d0e8b7d/app/src/main/res/drawable-hdpi/settings.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-ldpi/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/extinguish/onvif-camera/47445b42823d3b96670413ead36a37505d0e8b7d/app/src/main/res/drawable-ldpi/icon.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-ldpi/quit.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/extinguish/onvif-camera/47445b42823d3b96670413ead36a37505d0e8b7d/app/src/main/res/drawable-ldpi/quit.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-ldpi/settings.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/extinguish/onvif-camera/47445b42823d3b96670413ead36a37505d0e8b7d/app/src/main/res/drawable-ldpi/settings.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-mdpi/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/extinguish/onvif-camera/47445b42823d3b96670413ead36a37505d0e8b7d/app/src/main/res/drawable-mdpi/icon.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-mdpi/quit.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/extinguish/onvif-camera/47445b42823d3b96670413ead36a37505d0e8b7d/app/src/main/res/drawable-mdpi/quit.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-mdpi/settings.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/extinguish/onvif-camera/47445b42823d3b96670413ead36a37505d0e8b7d/app/src/main/res/drawable-mdpi/settings.png -------------------------------------------------------------------------------- /app/src/main/res/drawable/preview.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 8 | 11 | 12 | 17 | 18 | 19 | 22 | 23 | -------------------------------------------------------------------------------- /app/src/main/res/layout-sw600dp/preview.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 14 | 15 | 28 | 29 | -------------------------------------------------------------------------------- /app/src/main/res/layout-sw600dp/spydroid.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | 13 | 21 | 22 | -------------------------------------------------------------------------------- /app/src/main/res/layout-sw600dp/tablet.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 10 | 15 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /app/src/main/res/layout/about.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 10 | 11 | 19 | 20 | 25 | 26 | 32 | 33 | 39 | 40 | 41 | 42 |