B4A Library libStreaming v1.3

DonManfred

Expert
Licensed User
This is a wrap for this github project. Especially the Client part (Stream the camera to a streamingserver)

Streaming
Author:
DonManfred (wrapper)
Version: 1.3
  • AudioQuality
    Methods:
    • Initialize (samplingRate As Int, bitRate As Int)
      Represents a quality for an audio stream.
      samplingRate: The sampling rate
      bitRate: The bitrate in bit per seconds
    • IsInitialized As Boolean
  • RtspClient
    Methods:
    • Initialize (EventName As String)
    • IsInitialized As Boolean
    • isStreaming As Boolean
    • release
    • setCredentials (username As String, password As String) As RtspClientWrapper
      If authentication is enabled on the server, you need to call this with a valid login/password pair.
      Only implements Digest Access Authentication according to RFC 2069.
      username: The login
      password: The password
    • setServerAddress (host As String, port As Int) As RtspClientWrapper
      Sets the destination address of the RTSP server.
      host: The destination address
      port: The destination port
    • setSession (session As Session) As RtspClientWrapper
      The {@link Session} that will be used to stream to the server.
      If not called before {@link #startStream()}, a it will be created.
      Return type: @return:
    • setStreamPath (path As String) As RtspClientWrapper
      The path to which the stream will be sent to.
      path: The path
    • setTransportMode (mode As Int) As RtspClientWrapper
      Call this with {@link #TRANSPORT_TCP} or {@value #TRANSPORT_UDP} to choose the
      transport protocol that will be used to send RTP/RTCP packets.
      Not ready yet !
    • startStream
      Connects to the RTSP server to publish the stream, and the effectively starts streaming.
      You need to call {@link #setServerAddress(String, int)} and optionally {@link #setSession(Session)}
      and {@link #setCredentials(String, String)} before calling this.
      Should be called of the main thread !
    • stopStream
      Stops the stream, and informs the RTSP server.
    Properties:
    • Session As Session [read only]
  • SessionBuilder
    Events:
    • onBitrateUpdate (bitrate As Long)
    • onPreviewStarted ( As )
    • onSessionStarted ( As )
    • onSessionStopped ( As )
    • onSessionconfigured ( As )
    • onSesstionError (reason As Int, StreamType As Int, message As String, info As String)
    Methods:
    • Initialize (EventName As String) As SessionBuilderWrapper
    • IsInitialized As Boolean
    • build As Session
      Creates a new {@link Session}.
      Return type: @return:The new Session
    • clone As SessionBuilder
      Returns a new {@link SessionBuilder} with the same configuration.
    • setAudioEncoder (encoder As Int) As SessionBuilderWrapper
      Sets the audio encoder.
    • setAudioQuality (quality As AudioQuality) As SessionBuilderWrapper
      Sets the audio quality.
    • setCamera (camera As Int) As SessionBuilderWrapper
    • setDestination (destination As String) As SessionBuilderWrapper
      Sets the destination of the session.
    • setFlashEnabled (enabled As Boolean) As SessionBuilderWrapper
    • setOrigin (origin As String) As SessionBuilderWrapper
      Sets the origin of the session. It appears in the SDP of the session.
    • setPreviewOrientation (orientation As Int) As SessionBuilderWrapper
      Sets the orientation of the preview.
      orientation: The orientation of the preview
    • setSurfaceView (surfaceView As SurfaceView) As SessionBuilderWrapper
      Sets the SurfaceView required to preview the video stream.
    • setTimeToLive (ttl As Int) As SessionBuilderWrapper
    • setVideoEncoder (encoder As Int) As SessionBuilderWrapper
      Sets the default video encoder.
    • setVideoQuality (quality As VideoQuality) As SessionBuilderWrapper
      Sets the video stream quality.
    Properties:
    • AudioEncoder As Int [read only]
      Returns the audio encoder set with {@link #setAudioEncoder(int)}.
    • AudioQuality As AudioQuality [read only]
      Returns the AudioQuality set with {@link #setAudioQuality(AudioQuality)}.
    • Camera As Int [read only]
      Returns the id of the {@link android.hardware.Camera} set with {@link #setCamera(int)}.
    • Context As Context [read only]
      Returns the context set with {@link #setContext(Context)}
    • Destination As String [read only]
      Returns the destination ip address set with {@link #setDestination(String)}.
    • FlashState As Boolean [read only]
      Returns the flash state set with {@link #setFlashEnabled(boolean)}.
    • Origin As String [read only]
      Returns the origin ip address set with {@link #setOrigin(String)}.
    • SurfaceView As SurfaceView [read only]
      Returns the SurfaceView set with {@link #setSurfaceView(SurfaceView)}.
    • TimeToLive As Int [read only]
      Returns the time to live set with {@link #setTimeToLive(int)}.
    • VideoEncoder As Int [read only]
      Returns the video encoder set with {@link #setVideoEncoder(int)}.
    • VideoQuality As VideoQuality [read only]
      Returns the VideoQuality set with {@link #setVideoQuality(VideoQuality)}.
  • SurfaceView
    Fields:
    • ba As BA
    Methods:
    • BringToFront
    • DesignerCreateView (base As PanelWrapper, lw As LabelWrapper, props As Map)
    • Initialize (EventName As String)
    • Invalidate
    • Invalidate2 (arg0 As Rect)
    • Invalidate3 (arg0 As Int, arg1 As Int, arg2 As Int, arg3 As Int)
    • IsInitialized As Boolean
    • RemoveView
    • RequestFocus As Boolean
    • SendToBack
    • SetBackgroundImage (arg0 As Bitmap)
    • SetColorAnimated (arg0 As Int, arg1 As Int, arg2 As Int)
    • SetLayout (arg0 As Int, arg1 As Int, arg2 As Int, arg3 As Int)
    • SetLayoutAnimated (arg0 As Int, arg1 As Int, arg2 As Int, arg3 As Int, arg4 As Int)
    • SetVisibleAnimated (arg0 As Int, arg1 As Boolean)
    • addMediaCodecSurface (surface As Surface)
    • removeMediaCodecSurface
    • requestAspectRatio (aspectRatio As Double)
      Requests a certain aspect ratio for the preview. You don't have to call this yourself,
      the {@link VideoStream} will do it when it's needed.
    • run
    • startGLThread
    Properties:
    • AspectRatioMode As Int [write only]
    • Background As Drawable
    • Color As Int [write only]
    • Enabled As Boolean
    • Height As Int
    • Left As Int
    • Parent As Object [read only]
    • SurfaceTexture As SurfaceTexture [read only]
    • Tag As Object
    • Top As Int
    • Visible As Boolean
    • Width As Int
  • VideoQuality
    Methods:
    • Initialize (resX As Int, resY As Int, framerate As Int, bitrate As Int)
      Represents a quality for a video stream.
      resX: The horizontal resolution
      resY: The vertical resolution
      framerate: The framerate in frame per seconds
      bitrate: The bitrate in bit per seconds
    • IsInitialized As Boolean

B4X:
Sub Globals
    'These global variables will be redeclared each time the activity is created.
    'These variables can only be accessed from this module.
    Dim sBuilder As SessionBuilder
    Private Surface As SurfaceView
    Dim client As RtspClient
    Private btnStart As Button
    Private btnStop As Button
    Dim AQuality As AudioQuality
    Dim VQuality As VideoQuality
End Sub

Sub Activity_Create(FirstTime As Boolean)
    'Do not forget to load the layout file created with the visual designer. For example:
    Activity.LoadLayout("Layout1")
    'session.Initialize("").
    AQuality.Initialize(16000,32000)
    VQuality.Initialize(176,144,20,500000)

    sBuilder.Initialize("rtsp").setOrigin("/videochat").setSurfaceView(Surface).setCamera(1).setTimeToLive(64).setDestination("ipofstreamingserver").setVideoEncoder(1).setVideoQuality(VQuality).setPreviewOrientation(90)    .setAudioEncoder(3)



    client.Initialize("rtspclient")
    client.setSession(sBuilder.build).setServerAddress("ipadress",1900).setStreamPath("/videochat/test") '.setCredentials("username","password")


End Sub
This library is Donationware. You can download the library, you can test the library. But if you want to USE the library in your App you need to Donate for it.
Please click here to donate (You can donate any amount you want to donate for the library (or my work building the wrapper)) :)
 

Attachments

Last edited:

moster67

Expert
Licensed User
I really look forwarding to test this. It's an important wrapper for the B4A arsenal of libraries. I will post back test results as soon as I find a moment to test.
Thank you Don!
 

moster67

Expert
Licensed User
I have been trying the library but I am unable to watch the stream on the wowza-server. From the logs (and also unfiltered logs) everything seems to be OK. I can connect, authentication takes place and is successful and transmission of data to the server seems to be working: This is output from filtered logs:

Connecting to RTSP server...
rtsp_onSessionConfigured()
ANNOUNCE rtsp://xxx.exwebcast.com:1935/mike/test RTSP/1.0
ANNOUNCE rtsp://xxx.exwebcast.com:1935/mike/test RTSP/1.0
rtsp_onBitrateUpdate(0)
rtsp_onSessionStarted()
rtsp_onBitrateUpdate(604997)
rtsp_onBitrateUpdate(559077)
rtsp_onBitrateUpdate(586060)
rtsp_onBitrateUpdate(583884)
rtsp_onBitrateUpdate(540535)
rtsp_onBitrateUpdate(496027)
rtsp_onBitrateUpdate(515047)
rtsp_onBitrateUpdate(500897)
rtsp_onBitrateUpdate(503200)
rtsp_onBitrateUpdate(501284)
rtsp_onBitrateUpdate(494422)
rtsp_onBitrateUpdate(487272)
rtsp_onBitrateUpdate(492902)
rtsp_onBitrateUpdate(478485)
Don, do you remember if when the transmission of video-data to the server is taking place, did you also see "rtsp_onBitrateUpdate(xx) in the logs? Does that mean the phone is streaming video to the server?

On the server-side, (using a browser and online video-player) the rtpm-url and the name of the stream is recognized but when clicking on play nothing is displayed and I can only see a waiting-logo as if it is buffering.

I know the server is working - I tried it with wowza's own app, GoCoder, and everything works fine.

I noted there is an option to enable TCP instead of UDP - setTransportMode(RtspClient.TRANSPORT_TCP) - but I will probably need to enable it in the sources and re-wrap your library. I will try that.
(just saw it's already in the wrapper)

Maybe you have other ideas or suggestions to look out for since you have already tried it.

Thanks.
 
Last edited:

moster67

Expert
Licensed User
:D
I got it working by changing TransportMode into TCP instead of UDP (setting setTransportMode(1) ). Maybe a firewall issue?
Now let me see if we can fine-tune the stream...
Thank you once again Don. A well-deserved donation will be made shortly!
 

DonManfred

Expert
Licensed User

coslad

Well-Known Member
Licensed User
Good morning, so with this library finally is it possible to create a Video call between two android device?
 

DonManfred

Expert
Licensed User
so with this library finally is it possible to create a Video call between two android device?
Not at this time of development as the server-part is not wrapped as yet. But the base is done. I did not found the mood to wrap the server-side till now.
But it should be possible when the server-side is wrapped too i guess.
 

MarcoRome

Expert
Licensed User
Hi Don as i promise you have my donation ( 8RU656463X7488011 )
I have a few problem.
When start i listen streaming ( Voice ) but dont see nothing ( this about 2 pc ).
Yesterday we made some tests with Monster ( same code, so same apk ) . With his chosen device works (Nexus 4) with my (I tried it with Samsung Note 3 / Samsumg Tablet / Huawey) no.
Any idea ?
Thank you
 

MarcoRome

Expert
Licensed User
Hi Don as i promise you have my donation ( 8RU656463X7488011 )
I have a few problem.
When start i listen streaming ( Voice ) but dont see nothing ( this about 2 pc ).
Yesterday we made some tests with Monster ( same code, so same apk ) . With his chosen device works (Nexus 4) with my (I tried it with Samsung Note 3 / Samsumg Tablet / Huawey) no.
Any idea ?
Thank you
RESOLVED.... With big contribute Moster and Don.
Work very very well.
Great Library Don.
 

coslad

Well-Known Member
Licensed User
Hi

i would like to play with your library , but where can i find a streamingserver to test the example you posted ?
 

coslad

Well-Known Member
Licensed User
Can you share the way you do to test the library , any online free streaming server or any pc software ?
Thanks
 
Top