Skip to content

Commit

Permalink
add comments for documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
burak-58 committed Dec 8, 2023
1 parent b0071c5 commit 66645c7
Show file tree
Hide file tree
Showing 8 changed files with 180 additions and 140 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@
import android.os.Handler;
import android.util.Log;

/**
* Default implementation of {@link IWebRTCListener} for conference applications
* You may extend this class and override methods that you need
*/
public class DefaultConferenceWebRTCListener extends DefaultWebRTCListener {
private final String roomId;
private final String streamId;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@
import java.nio.ByteBuffer;
import java.nio.charset.StandardCharsets;

/**
* Default implementation of {@link IDataChannelObserver}
* You may extend this class and override methods that you need
*/
public class DefaultDataChannelObserver implements IDataChannelObserver {
@Override
public void onBufferedAmountChange(long previousAmount, String dataChannelLabel) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@
import de.tavendo.autobahn.WebSocket;
import io.antmedia.webrtcandroidframework.core.StreamInfo;

/**
* Default implementation of {@link IWebRTCListener}
* You may extend this class and override methods that you need
*/
public class DefaultWebRTCListener implements IWebRTCListener {
protected IWebRTCClient webRTCClient;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

import org.webrtc.DataChannel;

/**
* This interface is used to observe the data channel events
* You can use this interface to observe the data channel events or you can extend {@link DefaultDataChannelObserver}
*/
public interface IDataChannelObserver {

/** The data channel's bufferedAmount has changed. */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@
*/

public interface IWebRTCClient {

/**
* This enum is used to specify the stream source
*/
enum StreamSource
{
SCREEN,
Expand All @@ -19,178 +23,201 @@ enum StreamSource
CUSTOM
}

/**
* This method is used to initialize the WebRTCClient and configure it
*/
static WebRTCClientBuilder builder() {
return new WebRTCClientBuilder();
}

/**
* Switches the cameras
* This is used to strart a WebRTC publish stream
* @param streamId: any name
*/
void switchCamera();
void publish(String streamId);


/**
* toggle microphone
* @return
* This is used to strart a WebRTC publish stream
* @param streamId: id for the stream to publish
* @param token: token to authenticate
* @param videoCallEnabled: true if it's a video call
* @param audioCallEnabled: true if it's an audio call
* @param subscriberId: id of the subscriber
* @param subscriberCode: code of the subscriber
* @param streamName: name of the stream
* @param mainTrackId: id of the main track
*/
boolean toggleMic();
void publish(String streamId, String token, boolean videoCallEnabled, boolean audioCallEnabled,
String subscriberId, String subscriberCode, String streamName, String mainTrackId);


/**
* Stops the video source
* This is used to play a WebRTC stream
* @param streamId: id for the stream to play
*/
void stopVideoSource();
void play(String streamId);

/**
* Starts or restarts the video source
* This is used to play a multitrack WebRTC stream
* @param streamId: id for the stream to play
* @param tracks: subtracks to play in multitrack stream
*/
void startVideoSource();
void play(String streamId, String[] tracks);

/**
* Swapeed the fullscreen renderer and pip renderer
* @param b
* This is used to play a WebRTC stream with all parameters
* @param streamId: id for the stream to play
* @param token: token to authenticate
* @param tracks: subtracks to play in multitrack stream
* @param subscriberId: id of the subscriber
* @param subscriberCode: code of the subscriber
* @param viewerInfo: viewer info, any string is accepted
*/
void setSwappedFeeds(boolean b);
void play(String streamId, String token, String[] tracks, String subscriberId, String subscriberCode, String viewerInfo);

/**
* Get the error
* @return error or null if not
* This is used to join a peer to peer call
* @param streamId: id for the call
*/
String getError();
void join(String streamId);

/**
* Return if data channel is enabled and open
* @return true if data channel is available
* false if it's not opened either by mobile or server side
* This is used to join a conference room
* @param roomId: id for the conference room
* @param streamId: id for the participant
*/
boolean isDataChannelEnabled();
void joinToConferenceRoom(String roomId, String streamId);

/**
* This is used to get stream info list
* This is used to leave from a conference room
* @param roomId: id for the conference room
*/
void getStreamInfoList(String streamId);
void leaveFromConference(String roomId);

/**
* This is used to play the specified resolution
* @param height
* This is used to stop a stream publishing, playing or peer to peer call
* @param streamId id for the stream
*/
void forceStreamQuality(String streamId, int height);

//FIXME: add comment
void onCameraSwitch();
void onCaptureFormatChange(int width, int height, int framerate);
boolean onToggleMic();

static WebRTCClientBuilder builder() {
return new WebRTCClientBuilder();
}
void stop(String streamId);

/**
* This is used to strart a WebRTC publish stream
* @param streamId: any name
* This is used to send data via data channel
* @param streamId: id for the stream
* @param buffer: data to send
*/
void publish(String streamId);

void sendMessageViaDataChannel(String streamId, DataChannel.Buffer buffer);

/**
* This is used to strart a WebRTC publish stream
* @param streamId: any name
* @param token: token for stream
* TODO: add comment
* This is used to change video source on the fly
* @param newSource: may be front camera, rear camera, screen or custom source which provides video frames
*/
void publish(String streamId, String token, boolean videoCallEnabled, boolean audioCallEnabled,
String subscriberId, String subscriberCode, String streamName, String mainTrackId);

void changeVideoSource(StreamSource newSource);

/**
* This is used to play a WebRTC stream
* @param streamId
* This is used to play the specified resolution
* @param streamId: id for the stream
* @param height: desired height to play
*/
void play(String streamId);
void forceStreamQuality(String streamId, int height);

/**
* This is used to play a multitrack WebRTC stream
* @param streamId
* enable/disable video stream
* @param enabled true for enable, false for disable
*/
void play(String streamId, String[] tracks);
void setVideoEnabled(boolean enabled);

/**
* This is used to play a WebRTC stream with all parameters
* @param streamId
* enable/disable audio stream
* @param enabled true for enable, false for disable
*/
void play(String streamId, String token, String[] tracks, String subscriberId, String subscriberCode, String viewerInfo);
void setAudioEnabled(boolean enabled);

/**
* enable/disable played track stream from the server
* @param streamId id for the main track
* @param selecetedTrack id for the subtrack
* @param enabled true for enable, false for disable
*/
void enableTrack(String streamId, String selecetedTrack, boolean enabled);

/**
* Called to set the renderer for a video track
* @param renderer: renderer for the video track
* @param videoTrack: video track to set
*/
void setRendererForVideoTrack(SurfaceViewRenderer renderer, VideoTrack videoTrack);

/**
* This is used to get streaming status for a stream id
* @param streamId
* @return
* Called to swap the local renderer with the first remote renderer
* @param isSwappedFeeds: true if it's swapped
*/
boolean isStreaming(String streamId);
void setSwappedFeeds(boolean isSwappedFeeds);

/**
* This is used to join a conference room
* @param roomId
* @param streamId
* @return
* Switches the front and rear camera
*/
void joinToConferenceRoom(String roomId, String streamId);
void switchCamera();

/**
* This is used to leave from a conference room
* @param roomId
* Return if data channel is enabled and open
* @return true if data channel is available
* false if it's not opened either by mobile or server side
*/
void leaveFromConference(String roomId);
boolean isDataChannelEnabled();

/**
* This is used to send data via data channel
* @param streamId
* @param buffer
* This is used to get streaming status for a stream id
* @param streamId: id for the stream
* @return true if it's streaming at the moment
*/
void sendMessageViaDataChannel(String streamId, DataChannel.Buffer buffer);
boolean isStreaming(String streamId);

/**
* This is used to stop a stream
* @param streamId
* This is used to get room info from server
* @param roomId: id for the room
* @param streamId: id for the calling participant
*/
void stop(String streamId);
void getRoomInfo(String roomId, String streamId);

/**
* This is used to join a peer to peer stream
* @param streamId
* This is used to get stream info list for a stream from server
* @param streamId: id for the stream
*/
void join(String streamId);
void getStreamInfoList(String streamId);

/**
* This is used to get reconnecting status
* @return true if it's reconnecting
*/
boolean isReconnectionInProgress();

/**
* This is used to get room info
* @param roomId
* @param streamId
* Get the error
* @return error or null if not
*/
void getRoomInfo(String roomId, String streamId);
String getError();

/**
* This is used to change video source on the fly
* @param newSource
* Get the current configuration for the client
* @return current configuration
*/
void changeVideoSource(StreamSource newSource);


WebRTCClientConfig getConfig();

/**
* Get the current video capturer, used for custom video feed
* @return current video capturer
*/
VideoCapturer getVideoCapturer();

/**
* Get the current audio input, used for custom audio feed
* @return current audio input
*/
CustomWebRtcAudioRecord getAudioInput();

void setVideoEnabled(boolean b);

void setAudioEnabled(boolean b);

void enableTrack(String streamId, String selecetedTrack, boolean enabled);

/**
* Called to requesr the subtracks for a main track from server
*/
void getTrackList(String streamId, String token);

void setRendererForVideoTrack(SurfaceViewRenderer renderer, VideoTrack videoTrack);

}
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,14 @@

/**
* Created by karinca on 23.10.2017.
* This interface is used to listen WebRTCClient (or SDK) events
* You may implement this interface or extend {@link DefaultWebRTCListener} class
* If you want to create a conference application, you may extend {@link DefaultConferenceWebRTCListener} class
*/

public interface IWebRTCListener {

/**
/**
* It's called when websocket connection has been disconnected
*/
void onDisconnected();
Expand Down Expand Up @@ -108,8 +111,6 @@ public interface IWebRTCListener {
*/
void onReconnectionAttempt(String streamId);



/**
* It's called when joiened the room
*
Expand Down
Loading

0 comments on commit 66645c7

Please sign in to comment.