B4A Library libStreaming v1.3

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

  • libStreamingV1.3.0.zip
    139.9 KB · Views: 949
  • StreamingEx.zip
    8.4 KB · Views: 902
  • java_srcv1.3.zip
    112.8 KB · Views: 765
Last edited:

KZero

Active Member
Licensed User
Longtime User
Hi Don, i have a problem with your wrap.
When i connect to my RTSP server, it writes this messages:

2020/04/17 17:38:58 [RTSP client 192.168.8.100:40380] connected
2020/04/17 17:38:58 [RTSP client 192.168.8.100:40380] ANNOUNCE
2020/04/17 17:38:58 [RTSP client 192.168.8.100:40380] SETUP
2020/04/17 17:38:58 [RTSP client 192.168.8.100:40380] ERR: transport header does not contain mode=record
2020/04/17 17:38:58 [RTSP client 192.168.8.100:40380] disconnected

How can i set the trasport header with mode=record ?

Thank you!
Roberto
just try another RTSP server

I have been using this library for years, and it's been very stable till now.
 

KZero

Active Member
Licensed User
Longtime User
can you suggest me an RTSP server to use? May be wowza ?
yes it's working with wowza and Adobe media server but both are expensive, there is many other free RTSP servers such as Red5 and Nimble Streamer
 

RobertoBmb

Member
Licensed User
I think the original libStreaming project on GitHub was discontinued quite some time ago.
For your information, I will be releasing a library shortly which supports initially only RTMP but I will probably add RTSP to it as well.
When released, I will announce it here in the forum.

dear Moster67, i am testing wowza stream cloud with ffmpeg but it only works with RTMP,
so i would like to try your library with RTMP. Some news ?
 

mohammad be

Member
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)) :)

Hello
Good time
I want to use your library, but I have a few questions
1- Do I need a virtual server?
2- Can I make a voice call?
3- Did you implement a newer version?
 

DonManfred

Expert
Licensed User
Longtime User
1) Yes
2) No
3) Definetively NO as i do not have the source anymore.
 
Top