public final class

SCMediaFacade

extends Object
java.lang.Object
   ↳ com.c2call.sdk.pub.facade.SCMediaFacade

Class Overview

This class provides some convinient methods to control the audio and video during calls.

Summary

Public Methods
void addCameraObserver(Observer observer)
Adds an observer that gets notified if the camera status changed
boolean addFlagLeftOfView(TextView view, SCCountry country, int defaultResId)
void addPreviewCallback(Camera.PreviewCallback callback)
Adds a listener that will be called if a new video frame is available
void deleteCameraObserver(Observer observer)
Deletes the given observer
void disableVideoQualityManager(boolean disable)
Disable/Enable the automatic video quality managemnt based on device's performance and bandwidth
void enableExperimentalAudio(boolean value)
Enables the experimental Audio Engine
void enableFaceDetection(boolean enable)
Enable/Disable facedetection during video calls.
CamOrientation getCamOrientation()
Gets an orientation info object of the current active camera.
SCResolutionList getCamResolutions()
Get a list of possible reolutions for the current camera during video calls.
static String getLocalImagePath(Context context, Uri intentUri)
static String getLocalVideoPath(Context context, Uri intentUri)
String getMediaPath(SCDownloadType type, String filename)
Get the local path where the specified media file is stored.
int getNumberOfPreviewCallbacks()
Returns the number of attached camera preview callbacks
Dimension getPreviewDimen()
File getProfileMediaFile(String userid, String filename)
Bitmap getUserPicture(SCFriendData user, boolean largeImage, int defaultPictureResource, int timeoutSeconds)
Convinience method to load a user picture for a given user.
IVideoSlave getVideoSlave()
Gets the IVideoSlave of a running call, if any.
final static SCMediaFacade instance()
Gets the singleton instance.
boolean isCameraActive()
Checks if a camera service is currently active and running.
boolean isMicrophoneMuted()
Returns whether the microphone is currenly muted.
boolean pauseCamera()
Pauses a running camera service, if any.
void removePreviewCallback(Camera.PreviewCallback callback)
Removes th egiven callack.
boolean resumeCamera()
Resumes a previously paused camera service
void setCustomFaceDetector(SCFaceDetectionHandler<?> faceDetector, boolean force)
Sets a custom face detection handler.
boolean setFaceDetectionListener(Object listener)
Set a facedetection listener which is called during video calls if one or more faces where detected.
void setMuteMicrophone(boolean mute)
Mutes the microphone during calls.
void setVideoMaxQuantizer(int maxQuantizer)
Sets the maximum quantizer for video calls.
void setVideoResolutionIdx(int resIdx)
Sets the video resolution idx.
void setVideoTargetBitrate(int bitrate)
Set the target bitrate during video calls.
void setVideoTargetFramerate(int fps)
Sets the target frame rate during video calls.
boolean startCamera(Camera.PreviewCallback callback, int id, int width, int height, int fps)
Starts the camera service with given parameters.
void startRinging()
Plays and repeats a ringing sound until stopRinging() is called
void startScreenCaptureForView(View view, String filePath, String fileName)
This method requires an Enterprise account and Android API level 18+.
void startScreenSharingForView(View view)
This method requires an Enterprise account.
boolean stopCamera()
Stops a running camera service, if anny.
void stopRinging()
Stops the ringing sound started by a previous call of startRinging()
void stopScreenCaptureForView()
This method requires an Enterprise account and Android API level 18+.
void stopScreenSharing()
This method requires an Enterprise account.
int updateCamToDeviceRotation(int deviceRotation)
Forces the Camera Framework to update the camera rotation state relative to the device's rotation.
[Expand]
Inherited Methods
From class java.lang.Object

Public Methods

public void addCameraObserver (Observer observer)

Adds an observer that gets notified if the camera status changed

Parameters
observer the observer to add

public boolean addFlagLeftOfView (TextView view, SCCountry country, int defaultResId)

public void addPreviewCallback (Camera.PreviewCallback callback)

Adds a listener that will be called if a new video frame is available

Parameters
callback the callback to add.

public void deleteCameraObserver (Observer observer)

Deletes the given observer

Parameters
observer the observer to delete

public void disableVideoQualityManager (boolean disable)

Disable/Enable the automatic video quality managemnt based on device's performance and bandwidth

Parameters
disable true to disable the quality management.

public void enableExperimentalAudio (boolean value)

Enables the experimental Audio Engine

public void enableFaceDetection (boolean enable)

Enable/Disable facedetection during video calls. If enalbed then the FaceDetectionListener set by setFaceDetectionListener(Object) is called during video calls.

public CamOrientation getCamOrientation ()

Gets an orientation info object of the current active camera.

Returns
  • a orientation info object

public SCResolutionList getCamResolutions ()

Get a list of possible reolutions for the current camera during video calls.

Returns
  • a list of possible resolutions.

public static String getLocalImagePath (Context context, Uri intentUri)

Throws
FileNotFoundException

public static String getLocalVideoPath (Context context, Uri intentUri)

public String getMediaPath (SCDownloadType type, String filename)

Get the local path where the specified media file is stored.

Parameters
type the media type of the file
filename the file name

public int getNumberOfPreviewCallbacks ()

Returns the number of attached camera preview callbacks

Returns
  • the number of attached camera preview callbacks

public Dimension getPreviewDimen ()

public File getProfileMediaFile (String userid, String filename)

public Bitmap getUserPicture (SCFriendData user, boolean largeImage, int defaultPictureResource, int timeoutSeconds)

Convinience method to load a user picture for a given user. Must not be called from main-thread.

Parameters
user The user to load the picture for.
largeImage if this is true the then the large image is loaded. Otherwise this method will return only a smaller thumb
defaultPictureResource The resource id of the default picture to return if know user image is found. Can be 0.
timeoutSeconds The timeout in seconds for the connection to the remote image. If this exceeds then 'null' is returned.
Returns
  • The usar image as Bitmap, or null if no image was found or the given timout exceeds.

public IVideoSlave getVideoSlave ()

Gets the IVideoSlave of a running call, if any.

Returns
  • The current video slave of a running call or null if no such call is found.

public static final SCMediaFacade instance ()

Gets the singleton instance.

Returns
  • the singleton instance.

public boolean isCameraActive ()

Checks if a camera service is currently active and running.

Returns
  • true if a camera service as active

public boolean isMicrophoneMuted ()

Returns whether the microphone is currenly muted.

Returns
  • true if the micrpohne is muted

public boolean pauseCamera ()

Pauses a running camera service, if any.

Returns
  • true if a running camera service was successfully paused.
See Also

public void removePreviewCallback (Camera.PreviewCallback callback)

Removes th egiven callack.

Parameters
callback the callback to remove.

public boolean resumeCamera ()

Resumes a previously paused camera service

Returns
  • tru if a paused camera service was successfully resumed
See Also

public void setCustomFaceDetector (SCFaceDetectionHandler<?> faceDetector, boolean force)

Sets a custom face detection handler. This should be used if the device doesn't support the inbuild face detection.

Parameters
faceDetector the custom face detectior
force If true then this detector will be used even if a native one is available, too. Otherwise the native face detector will be preferred.

public boolean setFaceDetectionListener (Object listener)

Set a facedetection listener which is called during video calls if one or more faces where detected. This method requires Android API level 14+.

Parameters
listener the face detection listener, must be of type Camera.FaceDetectionListener (API level 14+)
Returns
  • true if the listener was successfully set.

public void setMuteMicrophone (boolean mute)

Mutes the microphone during calls.

Parameters
mute true to mute the microphone

public void setVideoMaxQuantizer (int maxQuantizer)

Sets the maximum quantizer for video calls. The values must be between 3 and 63 (inclusive). A lower value will result in better quality but highe CPU usage and higher bitrate. (default is 54)

Parameters
maxQuantizer the maximum quantizer. Must be between 3 and 63 (inclusive)

public void setVideoResolutionIdx (int resIdx)

Sets the video resolution idx. The index corresponds to Camera.Parameters.getSupportedPreviewSizes().

Parameters
resIdx the idx of the new resolution.

public void setVideoTargetBitrate (int bitrate)

Set the target bitrate during video calls. Note that it is not always possible to reach the given Bitrate.

Parameters
bitrate the target bitrate in kilobits.

public void setVideoTargetFramerate (int fps)

Sets the target frame rate during video calls.

Parameters
fps the framerate in frames per second.

public boolean startCamera (Camera.PreviewCallback callback, int id, int width, int height, int fps)

Starts the camera service with given parameters. There will be no video perview visible, instead every new frame will be pushed to the given callback (in its native raw format). This method my block the calling thread for several seconds, so its not recommended to call it on the main thread.

Parameters
callback new video frames will be pushed to this callback
id the ID of the camera to open.
width the width of the video frames. Width and height must be supported by the camera
height the height of the video frames. Width and height must be supported by the camera
fps the framerate per seconds. Must be supported by the camera
Returns
  • true, if the camera was successfully started.

public void startRinging ()

Plays and repeats a ringing sound until stopRinging() is called

public void startScreenCaptureForView (View view, String filePath, String fileName)

This method requires an Enterprise account and Android API level 18+. In difference to screen sharing, startScreenCaptureForView can run independently from a video calling session and can just capture any screen into a video. The video format will me MP4. [WARNING] Due to color space limitations on several devices, the final video will have a dimension where the width and height is a multiple of 16. If the given view does not fullfill this restriction then this method will adjust the size accordingly.

Parameters
view The view to be captured. The context of the view must be an Activity.
filePath The path where the viedo will be stored (must already exist!).
fileName The file name of the video. This will always be suffixed with ".mp4" if needed.

public void startScreenSharingForView (View view)

This method requires an Enterprise account. During an active video call or group video call, any view can be used in order to be shared in the current video calling session. The view will be captured and injected into the video calling stream. Calling stopScreenSharing() will end the screen sharing session and start to send the camera image again.

Parameters
view the view to share

public boolean stopCamera ()

Stops a running camera service, if anny. Possible PreviewCallbacks and FaceDetectionListeners will be detached.

public void stopRinging ()

Stops the ringing sound started by a previous call of startRinging()

public void stopScreenCaptureForView ()

This method requires an Enterprise account and Android API level 18+. Stop the screen capure stared by startScreenCaptureForView(View, String, String)

public void stopScreenSharing ()

This method requires an Enterprise account. Stop the screen sharing started by startScreenSharingForView(View)

public int updateCamToDeviceRotation (int deviceRotation)

Forces the Camera Framework to update the camera rotation state relative to the device's rotation. This rotation will be used to rotate the cam preview and the video stream during video calls.

Parameters
deviceRotation the device rotation that will be used to calculate the actual cam rotation
Returns
  • the updated rotation that will be used.