2016-03-30 24 views
0

Istemci olarak Android için bir H264 DVR kamera akışı benim staj projesi için android için bir uygulama geliştiriyorum.Ben sadece Wifi kullandığınızda ben iç IP kullanarak DVR bağlayabilirsiniz Ben harici IP adresini kullanırsanız, logCat ile 192.xxx.xxx.xxx ben sadece logcat olsun WiFi veya 3G kullanarak, 60.xxx.xxx.xxx, aNCAK harici IP kullanarak 3g üzerinde android rtsp

04-04 14:30:14.680 1629-1629/? V/DefaultOmaSettingHelper: setSettingHeader: with uri=rtsp://192.xxx.xxx.xxx:554/user=xxx&password=xxx&channel=1&stream=0.sdp? 
04-04 14:30:14.682 827-1630/? V/SettingsProvider: call(system:MTK-RTSP-CACHE-SIZE) for 0 
04-04 14:30:14.682 827-1630/? D/SettingsProvider: lookupValue table system cache contains Key MTK-RTSP-CACHE-SIZE , value = Bundle[{value=null}] 
04-04 14:30:14.682 827-1674/? V/SettingsProvider: call(system:mtk_rtsp_min_udp_port) for 0 
04-04 14:30:14.682 827-1674/? D/SettingsProvider: lookupValue table system cache contains Key mtk_rtsp_min_udp_port , value = Bundle[{value=1024}] 
04-04 14:30:14.682 827-1699/? V/SettingsProvider: call(system:mtk_rtsp_max_udp_port) for 0 
04-04 14:30:14.683 827-1699/? D/SettingsProvider: lookupValue table system cache contains Key mtk_rtsp_max_udp_port , value = Bundle[{value=65535}] 
04-04 14:30:14.683 827-870/? V/SettingsProvider: call(system:mtk_rtsp_proxy_enabled) for 0 
04-04 14:30:14.683 827-870/? D/SettingsProvider: lookupValue table system cache contains Key mtk_rtsp_proxy_enabled , value = Bundle[{value=null}] 
04-04 14:30:14.684 1629-1629/? V/DefaultOmaSettingHelper: setOmaSettingHeader: params:minUdpPort=1024minUdpPort=1024maxUdpPort=65535rtspProxyEnable=0rtspProxyHost=nullrtspProxyPort=-1httpProxyEnable=0httpProxyHost=nullhttpProxyPort=-1httpBufferSize=10rtspBufferSize=4 
04-04 14:30:14.686 277-277/? I/MediaPlayerService: [setDataSource] setDataSource(rtsp://192.xxx.xxx.xxx:554/user=xxx&password=xxx&channel=1&stream=0.sdp?) 
04-04 14:30:14.689 277-277/? D/DrmMtkUtil/DrmUtil: checkDcf ----> path [rtsp://192.xxx.xxx.xxx:554/user=xxx&password=xxx&channel=1&stream=0.sdp?] 
04-04 14:30:14.689 277-277/? V/DrmMtkUtil/DrmUtil: checkExistence ----> [rtsp://192.xxx.xxx.xxx:554/user=xxx&password=xxx&channel=1&stream=0.sdp?] 
04-04 14:30:14.690 277-277/? I/NuPlayer: Is RTSP Streaming 
04-04 14:30:14.690 277-277/? D/RTSPSource: init+, RTSP uri headers from AP: 
04-04 14:30:14.690 277-277/? D/RTSPSource:  Authorization: Basic YWRtaW46 
04-04 14:30:14.690 277-277/? D/RTSPSource:  MAX-UDP-PORT: 65535 
04-04 14:30:14.691 277-277/? D/RTSPSource:  MIN-UDP-PORT: 1024 
04-04 14:30:14.691 277-277/? D/RTSPSource:  MTK-HTTP-CACHE-SIZE: 10 
04-04 14:30:14.691 277-277/? D/RTSPSource:  MTK-RTSP-CACHE-SIZE: 4 
04-04 14:30:14.691 277-277/? D/RTSPSource: removeSpecificHeaders MTK-RTSP-CACHE-SIZE 
04-04 14:30:14.691 277-277/? D/RTSPSource: special headers: MTK-RTSP-CACHE-SIZE = 4 
04-04 14:30:14.691 277-277/? I/RTSPSource: RTSP cache size = 4000000us 
04-04 14:30:14.692 277-277/? I/MediaPlayerService: [setDataSource] setDataSource(rtsp://192.xxx.xxx.xxx:554/user=xxx&password=xxx&channel=1&stream=0.sdp?) done 
04-04 14:30:14.697 277-2204/? D/MyHandler: RTSP Max UDP Port: 65535 
04-04 14:30:14.697 277-2204/? D/MyHandler: RTSP Min UDP Port: 1024 
04-04 14:30:14.705 277-2207/? I/ARTSPConnection: set nodelay return 0 
04-04 14:30:14.705 277-2207/? I/ARTSPConnection: connecting 192.168.0.18, 192.xxx.xxx.xxx:554 now 
04-04 14:30:14.706 277-2207/? I/ARTSPConnection: connection EINPROGRESS 
04-04 14:30:14.741 277-2207/? I/ARTSPConnection: status: RTSP/1.0 200 OK 
04-04 14:30:14.741 277-2207/? I/ARTSPConnection: line: 'Content-Type: application/sdp' 
04-04 14:30:14.742 277-2207/? I/ARTSPConnection: line: 'Server: H264DVR 1.0' 
04-04 14:30:14.742 277-2207/? I/ARTSPConnection: line: 'Cseq: 1' 
04-04 14:30:14.742 277-2207/? I/ARTSPConnection: line: 'Content-Base: rtsp://192.xxx.xxx.xxx:554/user=xxx&password=xxx&channel=1&stream=0./' 
04-04 14:30:14.742 277-2207/? I/ARTSPConnection: line: 'Cache-Control: private' 
04-04 14:30:14.742 277-2207/? I/ARTSPConnection: line: 'x-Accept-Retransmit: our-retransmit' 
04-04 14:30:14.742 277-2207/? I/ARTSPConnection: line: 'x-Accept-Dynamic-Rate: 1' 
04-04 14:30:14.742 277-2207/? I/ARTSPConnection: line: 'Content-Length: 356' 
04-04 14:30:14.743 277-2209/? I/ASessionDescription: s=RTSP Session 
04-04 14:30:14.743 277-2209/? I/MyHandler: base url rtsp://192.xxx.xxx.xxx:554/user=xxx&password=xxx&channel=1&stream=0./ 
04-04 14:30:14.754 277-2207/? I/ARTSPConnection: status: RTSP/1.0 200 OK 
04-04 14:30:14.755 277-2207/? I/ARTSPConnection: line: 'Server: H264DVR 1.0' 
04-04 14:30:14.755 277-2207/? I/ARTSPConnection: line: 'Cseq: 2' 
04-04 14:30:14.755 277-2207/? I/ARTSPConnection: line: 'Session: 193306800;timeout=60' 
04-04 14:30:14.755 277-2207/? I/ARTSPConnection: line: 'Transport: RTP/AVP;unicast;mode=PLAY;source=192.xxx.xxx.xxx;client_port=46234-46235;server_port=40000-40001;ssrc=0' 
04-04 14:30:14.755 277-2207/? I/ARTSPConnection: line: 'Cache-Control: private' 
04-04 14:30:14.755 277-2207/? I/ARTSPConnection: line: 'x-Dynamic-Rate: 1' 
04-04 14:30:14.759 277-2205/? I/RTSPSource: rtsp s=RTSP Session 
04-04 14:30:14.759 277-2205/? I/RTSPSource: convertMetaDataToMessage OK 
04-04 14:30:15.015 277-2207/? I/ARTSPConnection: status: RTSP/1.0 200 OK 
04-04 14:30:15.015 277-2207/? I/ARTSPConnection: line: 'Server: H264DVR 1.0' 
04-04 14:30:15.015 277-2207/? I/ARTSPConnection: line: 'Cseq: 3' 
04-04 14:30:15.017 277-2215/? I/ACodec: mSupportsPartialFrames 1 err 0 
04-04 14:30:15.018 277-2207/? I/ARTSPConnection: line: 'Range: npt=now-' 
04-04 14:30:15.018 277-2207/? I/ARTSPConnection: line: 'Session: 193306800' 
04-04 14:30:15.020 277-2213/? I/NuPlayerDecoder: mSupportsPartialFrames 1 

diyerek

04-04 14:24:32.677 31474-31474/? V/DefaultOmaSettingHelper: setSettingHeader: with uri=rtsp://60.xxx.xxx.xxx:2218/user=xxx&password=xxx&channel=1&stream=0.sdp? 
04-04 14:24:32.678 827-1089/? V/SettingsProvider: call(system:MTK-RTSP-CACHE-SIZE) for 0 
04-04 14:24:32.678 827-1089/? D/SettingsProvider: lookupValue table system cache contains Key MTK-RTSP-CACHE-SIZE , value = Bundle[{value=null}] 
04-04 14:24:32.679 827-847/? V/SettingsProvider: call(system:mtk_rtsp_min_udp_port) for 0 
04-04 14:24:32.679 827-847/? D/SettingsProvider: lookupValue table system cache contains Key mtk_rtsp_min_udp_port , value = Bundle[{value=1024}] 
04-04 14:24:32.679 827-1002/? V/SettingsProvider: call(system:mtk_rtsp_max_udp_port) for 0 
04-04 14:24:32.679 827-1002/? D/SettingsProvider: lookupValue table system cache contains Key mtk_rtsp_max_udp_port , value = Bundle[{value=65535}] 
04-04 14:24:32.680 827-1674/? V/SettingsProvider: call(system:mtk_rtsp_proxy_enabled) for 0 
04-04 14:24:32.680 827-1674/? D/SettingsProvider: lookupValue table system cache contains Key mtk_rtsp_proxy_enabled , value = Bundle[{value=null}] 
04-04 14:24:32.681 31474-31474/? V/DefaultOmaSettingHelper: setOmaSettingHeader: params:minUdpPort=1024minUdpPort=1024maxUdpPort=65535rtspProxyEnable=0rtspProxyHost=nullrtspProxyPort=-1httpProxyEnable=0httpProxyHost=nullhttpProxyPort=-1httpBufferSize=10rtspBufferSize=4 
04-04 14:24:32.683 277-13212/? I/MediaPlayerService: [setDataSource] setDataSource(rtsp://60.xxx.xxx.xxx:2218/user=xxx&password=xxx&channel=1&stream=0.sdp?) 
04-04 14:24:32.683 277-13212/? D/DrmMtkUtil/DrmUtil: checkDcf ----> path [rtsp://60.xxx.xxx.xxx:2218/user=xxx&password=xxx&channel=1&stream=0.sdp?] 
04-04 14:24:32.683 277-13212/? V/DrmMtkUtil/DrmUtil: checkExistence ----> [rtsp://60.xxx.xxxx.xxx:2218/user=xxx&password=xx&channel=1&stream=0.sdp?] 
04-04 14:24:32.684 277-13212/? I/NuPlayer: Is RTSP Streaming 
04-04 14:24:32.684 277-13212/? D/RTSPSource: init+, RTSP uri headers from AP: 
04-04 14:24:32.684 277-13212/? D/RTSPSource:  Authorization: Basic YWRtaW46 
04-04 14:24:32.684 277-13212/? D/RTSPSource:  MAX-UDP-PORT: 65535 
04-04 14:24:32.684 277-13212/? D/RTSPSource:  MIN-UDP-PORT: 1024 
04-04 14:24:32.684 277-13212/? D/RTSPSource:  MTK-HTTP-CACHE-SIZE: 10 
04-04 14:24:32.684 277-13212/? D/RTSPSource:  MTK-RTSP-CACHE-SIZE: 4 
04-04 14:24:32.684 277-13212/? D/RTSPSource: removeSpecificHeaders MTK-RTSP-CACHE-SIZE 
04-04 14:24:32.684 277-13212/? D/RTSPSource: special headers: MTK-RTSP-CACHE-SIZE = 4 
04-04 14:24:32.684 277-13212/? I/RTSPSource: RTSP cache size = 4000000us 
04-04 14:24:32.686 277-13212/? I/MediaPlayerService: [setDataSource] setDataSource(rtsp://60.xxx.xxx.xxx:2218/user=xxx&password=xxx&channel=1&stream=0.sdp?) done 
04-04 14:24:32.692 277-32374/? D/MyHandler: RTSP Max UDP Port: 65535 
04-04 14:24:32.692 277-32374/? D/MyHandler: RTSP Min UDP Port: 1024 
04-04 14:24:32.696 277-32377/? I/ARTSPConnection: set nodelay return 0 
04-04 14:24:32.696 277-32377/? I/ARTSPConnection: connecting 60.xxx.xxx.xxx, 60.xxx.xxx.xxx:2218 now 
04-04 14:24:32.697 277-32377/? I/ARTSPConnection: connection EINPROGRESS 

Bu yüzden herkes benim sorunumun ne olduğunu söyleyebilir mi? Soket, paket, girdi/çıktı, arabellek/yazar veya herhangi bir şey kullanmalı mıyım? Onlara

PS gerçek bir aygıt üzerinde test nasıl kullanılacağını öğrenmek böylece kira akışı etkinliği

public class liveActivity extends Activity{ 

final static String USERNAME = "xxx"; 
final static String PASSWORD = "xxx"; 
public static String domainName = "60.xxx.xxx.xxx"; 
public static int PORT = 2018; 
public static final String URL = "rtsp://192.xxx.xxx.xxx:554/user=" + USERNAME + "&password=" + PASSWORD + "&channel=1&stream=0.sdp?"; 
public static final String URL2 = "rtsp://" + domainName + ":" + PORT + "/user=" + USERNAME + "&password=" + PASSWORD + "&channel=1&stream=0.sdp?"; 

private MediaPlayer mPlayer1; 
private MediaPlayer mPlayer2; 
SurfaceHolder.Callback mCallback1; 
SurfaceHolder.Callback mCallback2; 

@Override 
protected void onCreate(Bundle savedInstanceState) { 
    super.onCreate(savedInstanceState); 
    setContentView(R.layout.activity_live); 

    try{ 

    }catch (Exception e){ 
     e.printStackTrace(); 
    } 

    mPlayer1 = new MediaPlayer(); 
    mPlayer2 = new MediaPlayer(); 

    mCallback1 = new SurfaceHolder.Callback() { 
     @Override 
     public void surfaceCreated(SurfaceHolder surfaceHolder) { 

      try { 

       mPlayer1.setDisplay(surfaceHolder); 
       Context context = getApplicationContext(); 
       Map<String, String> headers = getRtspHeaders(); 
       Uri source = Uri.parse(URL2); 
       mPlayer1.setDataSource(context, source, headers); 
       mPlayer1.setOnPreparedListener(new MediaPlayer.OnPreparedListener() { 
        @Override 
        public void onPrepared(MediaPlayer mediaPlayer) { 
         mPlayer1.start(); 
        } 
       }); 
       mPlayer1.prepareAsync(); 
      } catch (IOException e) { 
       e.printStackTrace(); 
      } 
     } 

     @Override 
     public void surfaceChanged(SurfaceHolder surfaceHolder, int i, int i2, int i3) { 

     } 

     @Override 
     public void surfaceDestroyed(SurfaceHolder surfaceHolder) { 

      mPlayer1.release(); 
     } 
    }; 

    final SurfaceView surfaceView1 = 
      (SurfaceView) findViewById(R.id.surfaceView1); 
    // Configure the Surface View. 
    surfaceView1.setKeepScreenOn(true); 
    // Configure the Surface Holder and register the callback. 
    SurfaceHolder holder1 = surfaceView1.getHolder(); 
    holder1.addCallback(mCallback1); 
    holder1.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS); 

    /*final SurfaceView surfaceView2 = 
      (SurfaceView) findViewById(R.id.surfaceView2); 
    // Configure the Surface View. 
    surfaceView2.setKeepScreenOn(true); 
    // Configure the Surface Holder and register the callback. 
    SurfaceHolder holder2 = surfaceView2.getHolder(); 
    holder2.addCallback(mCallback2); 
    holder2.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);*/ 

} 


private Map<String, String> getRtspHeaders() { 
    Map<String, String> headers = new HashMap<String, String>(); 
    String basicAuthValue = getBasicAuthValue(USERNAME, PASSWORD); 
    headers.put("Authorization", basicAuthValue); 
    return headers; 
} 

private String getBasicAuthValue(String user, String password) { 
    String credentials = user + ":" + password; 
    int flags = Base64.URL_SAFE | Base64.NO_WRAP; 
    byte[] bytes = credentials.getBytes(); 
    return "Basic " + Base64.encodeToString(bytes, flags); 
} 

} 
için

edit (Elephone P8000 Android 5.0) Bana

Kaynak Kod bazı örnekler vermek

Not: "xxx" güvenlik amacıyla hazırlanmıştır.

cevap

0

Mümkün olduğu kadar emin olmak zor e-bilgi ve kodu görme, ancak en olası problem, sağlayıcınızın bu tür bağlantıyı ağ üzerinden engellemesidir - bazı operatörler bant genişliğini korumak için 'uplink' akış trafiğini engeller ya da bir VoIP gibi düşünebilirler. hizmetlerinden biri ile rekabet etmek.

WiFi'de çalışmasının sebebi, hem Android cihazınızın hem de Fotoğraf Makinesinin, aralarında hiç güvenlik duvarı vb. Olmadan aynı ağda bulunmasıdır.

+0

Cevabınız için teşekkür ederiz Mick, NAT ile ilgili bir problemden şüphelenmiştim ya da NAT ile ilgili bir soruna benziyordum, ancak başka bir şeyin neden kaynaklanıp kaynaklanmayacağını bilmek isterdim. Sorgumu düzenledim ve tüm kodun kaynak kodunu ekledim. Basit bir kod ama bunun yerine bazı destek sınıflarını kullanırsam bir fark yaratır mı? –

+0

Kod formunuzla ilgili herhangi bir sorunu hızlı bir tarama göremiyorum. Başka bir akış oynatıcısını kameranıza URL aracılığıyla bağlamayı ve bunun da sorunları olup olmadığını kontrol etmenizi öneririz. Bu, Google Play'de ücretsiz olarak kullanılabilirse: https://play.google.com/store/apps/details?id=org .rtspplr.app & hl = tr – Mick

+0

Ne yazık ki çalışıyorum DVR ile çalışan tek uygulama MEye, ama cehennem kodu çıkardı ve benim anlamak için çok yüksek düzeyde oldu.Neyse yardım için teşekkürler –

İlgili konular