OMCS development manual (02) -- Multimedia connector OMCS development manual (00) -- Overview OMCS development manual (01) -- Multimedia Device Manager

Source: Internet
Author: User
Document directory
  • 2. Status Information
  • 1. microphone connector
  • 2. Camera Connector
  • 3. Remote Desktop Connector
  • 4. electronic whiteboard Connector

OMCS development manual (01) -- Multimedia Device Manager IMultimediaManager, which describes how to use the multimedia Device Manager from the perspective of the Owner. This article is from the perspective of Guest, describes another type of OMCS component/control: multimedia connector. The multimedia connector is used to connect to multimedia devices provided by any online OMCS client. All connectors are displayed in the form of Windows controls or components, and the imultimediaconneinterface is implemented.

1. imultimediaconneinterface

The multimedia connector interface is defined as follows:

Public interface IMultimediaConnector {/// <summary> /// UserID of the device owner. /// </Summary> string OwnerID {get;} // <summary> // is the target device connected? /// </Summary> bool Connected {get ;}/// <summary> // if the Owner is not online when you call BeginConnect to connect the device of the Owner, the maximum waiting time for the other party to go online. If the owner is not connected after this time, the BeginConnect result is still TargetUserOffline. /// Unit: seconds. The default value is 0. /// </Summary> int WaitOwnerOnlineSpanInSecs {get; set ;}/// <summary> /// type of the target multimedia device. /// </Summary> MultimediaDeviceType {get ;}/// <summary> /// try to connect to the target multimedia device. If the multimedia device is not authorized, the multimedia manager is not initialized, or the current connector is working, or the target multimedia device has been connected, or the last connection attempt has not ended, an exception is thrown. /// </Summary> /// <param name = "destUserID"> UserID of the target user </param> void BeginConnect (string destUserID );
/// <Summary> /// this event is triggered when the attempt to connect to the target multimedia device (initiated by BeginConnect) ends. The event parameter describes the connection result. /// </Summary> event CbGeneric <ConnectResult> ConnectEnded; // <summary> // This event is triggered when the connection to the target multimedia device is disconnected. /// </Summary> event CbGeneric <ConnectorDisconnectedType> Disconnected; // <summary> /// disconnect the target user's multimedia device and release the channel. /// </Summary> void Disconnect ();}
1. Connection

When a connector object is used, the corresponding control/component is first dragged to the form, and then its BeginConnect method is called to try to connect to the target user's multimedia device. When the connection ends, the ConnectEnded event is triggered whether the connection is successful or fails. We can know whether the connection is successful or failed based on the ConnectEnded event parameter ConnectResult. The ConnectResult enumeration is defined as follows:

Public enum ConnectResult {Succeed, /// <summary> /// wait for the reply to time out /// </summary> Timeout, /// <summary> /// the target user is not online /// </summary> TargetUserOffline, /// <summary> /// rejected by the other Party /// </summary> Denied, /// <summary> /// the device does not exist or has an error. /// </summary> DeviceInvalid, /// <summary> // The Device Manager of the Owner has not been initialized. // </summary> MultimediaManagerNotInitialized, /// <summary> /// exception // </summary> ExceptionOccured ,}

Note: If the multimedia device is not authorized, the multimedia manager is not initialized, the current connector is working, or the target multimedia device is connected, the BeginConnect method throws an exception.

If the Owner of the target device to be connected is not online, the WaitOwnerOnlineSpanInSecs attribute allows us to wait for a while. In some cases, this may be useful. We can imagine that a multimedia application system developed based on OMCS has other business logic besides the multimedia provided by OMCS. That is to say, in addition to the OMCS server, there will also be application servers that process business logic. As shown in the figure in the OMCS development manual (00)-Overview:

In this case, the client has two connections, one pointing to the OMCS server and the other pointing to the application server. Generally, the client should connect to the OMCS server after successfully logging on to the application server. In this case, there may be a time gap-that is, the application server has been successfully connected, and the OMCS server has not been connected. If another Guest accesses the multimedia device of the current client at this time, the TargetUserOffline result is returned and the connection fails. If you set the WaitOwnerOnlineSpanInSecs value of the connector to greater than 0, the connector will be continuously polling during this period, waiting for the Owner to connect to the OMCS server. When the Owner goes online, connect to its multimedia device. Of course, if the Owner has not connected to the OMCS server within the WaitOwnerOnlineSpanInSecs time due to some exceptions, the connector still returns the TargetUserOffline result at the end of the waiting time.

2. Status Information

The MultimediaDeviceType attribute indicates the type of the target multimedia device to be connected to by the current connector.

The Connected attribute reflects the connection status between the current connector and the multimedia device.

If the connection is successful, the OwnerID attribute indicates the user's multimedia device that is currently connected.

3. Disconnect

We can call the Disconnect method to actively Disconnect from the target multimedia device. Of course, in addition to actively disconnecting, there are several other methods that can also lead to the disconnection from the connector to the target device. The Disconnected event is triggered as long as the connection between the connector and the target multimedia device is Disconnected. The ConnectorDisconnectedType parameter of the event indicates the reason for the disconnection.

Public enum ConnectorDisconnectedType {/// <summary> /// Guest (connector) dropped. /// </Summary> GuestOffline = 0, /// <summary> /// the Owner (device) is offline. /// </Summary> OwnerOffline, /// <summary> /// Guest (connector) Actively disconnects to the device. /// </Summary> GuestActiveDisconnect, /// <summary> // The Owner (device) Actively disconnects the Guest (connector) to the device. /// </Summary> OwnerActiveDisconnect}

There are four reasons for multimedia connector disconnection: Guest disconnection, Owner disconnection, Guest active disconnection, and Owner active disconnection.

When we call the Disconnect method on a normally working connector instance, the parameter that triggers the Disconnected event is ConnectorDisconnectedType. GuestActiveDisconnect.

Remember that IMultimediaManager has an overloaded DisconnectGuest method when introducing OMCS development manual (01)-multimedia Device Manager. If the Owner calls this DisconnectGuest method, the connection instance corresponding to Guest will be disconnected to the target device, and the reason for the disconnection is ConnectorDisconnectedType. ownerActiveDisconnect.

Ii. Four multimedia connectors

OMCS provides four types of multimedia connectors: MicrophoneConnector (microphone connector), CameraConnector/DynamicCameraConnector (CAMERA connector), toptopconnector/DynamicDesktopConnector (Remote Desktop connector), and whiteboardconne( electronic whiteboard connector ). All these connectors implement the IMultimediaConnector interface. Therefore, all functions defined by imultimediaconneare available.

We can add these connector components/controls to the toolbox: Right-click the blank area of the VS toolbox, shortcut menu => select items, on the pop-up "select toolbox items" form, click Browse to select OMCS. dll file, and then click "OK.

1. microphone connector

MicrophoneConnector is a component without UI elements. Of course, it does not need UI display.

2. Camera Connector

OMCS provides two camera connectors: CameraConnector and dynamiccameraconne. The difference between them is that cameraconneis a UI control that directly displays the video collected by the target camera on the current UI; dynamiccameraconneis a component (without a UI ), you can use the SetViewer method to dynamically set the UI on which the image is to be drawn.

/// <Summary> /// set the control for displaying the video. You must call this method in the UI thread. /// </Summary> /// <param name = "newPanel"> controls used to draw videos. It can be null. </Param> public void SetViewer (Control newPanel)

As we often see in the video chat full screen display function, you can use dynamiccameraconne. when you click the full screen button, set the surface to be drawn by dynamiccameraconneto the Top) the surface of the form.

In addition, CameraConnector and dynamiccameraconneprovide the following features:

  Color PanelColor {get;set;}  bool AutoSynchronizeVideoToAudio {get;set;}  int MaxIdleSpan4BlackScreen {get;set;}  Bitmap GetCurrentImage();

PanelColor: used to set the background color of the drawn control. This background color is displayed when no video image is displayed. The default value is black.

MaxIdleSpan4BlackScreen: displays the background color set by PanelColor when a new video frame is not received continuously. The default value is 5 seconds. This situation often occurs when the network is slow, resulting in a large video frame latency.

GetCurrentImage: This method saves the currently displayed video frame as a bitmap. This method can be used to implement the photo taking function.

AutoSynchronizeVideoToAudio: if the current client is connected to the camera and microphone of the same Owner, whether CameraConnector/dynamiccameraconneautomatically synchronizes the audio when playing the video. The default value is true. It can be dynamically modified at runtime.

Generally, when the network is very smooth, Video Frames and audio frames are played immediately after being received, which is synchronized. However, when the network is jittery, The OMCS automatically enables the jitters Buffer ), in this way, the audio is a little slower than the video playback speed (which may be several milliseconds or dozens of milliseconds, depending on the network jitter), resulting in the inconsistency between the sound and the screen. If you set AutoSynchronizeVideoToAudio to true, OMCS controls the playback of video frames so that they are consistent with the audio.

3. Remote Desktop Connector

Like camera connectors, OMCS also provides two remote desktop connectors: desktopconneand dynamicdesktopconne. They are also different from the two camera connectors. It has the following extended features:

  Color PanelColor {get;set;}  bool WatchingOnly {get;set;}

The meaning of PanelColor is the same as that of the camera connector.

The WatchingOnly attribute is used to control whether the Remote Desktop can be operated by guest. Set it to true to implement remote assistance functions similar to QQ.

4. electronic whiteboard Connector

First of all, it should be emphasized that the electronic whiteboard device has an important difference with several other devices: the Owner's identity is more like a sign for the electronic whiteboard than the first three devices, is the holder of the actual device. Like a building, there are many rooms, and the Owner ID is only the house number of the room. If multiple guest instances are connected to the same Owner's whiteboard, multiple guest instances enter the same room, you can collaborate on the same whiteboard (these guest see exactly the same content. When a guest modifies the content of the whiteboard, other guest can see this change at the same time ). Based on this, the Owner's Disconnection will not lead to the disconnection of the Guest whiteboard connector. That is to say, the value of the ConnectorDisconnectedType parameter of the whiteboardconnedisconnected event will never be OwnerOffline. However, when the whiteboard connector is connected to the owner, the Owner must be online, which is consistent with several other connectors.

The Extended features of whiteboardconneare as follows:

  bool WatchingOnly {get;set;}  bool AutoReconnect {get;set;}  void InsertImage(Image img);

The WatchingOnly attribute is used to control whether the guest can be painted on the whiteboard or only watched. In today's popular electronic classrooms, only teachers can operate electronic whiteboards, while students can only watch electronic whiteboards.

AutoReconnect is a feature unique to the electronic whiteboard connector to support automatic reconnection of broken lines. After the reconnection is successful, The Whiteboard will download the latest content from the server and display it to ensure the real-time performance of the whiteboard.

In addition to pressing Ctrl + V, we can also call the InsertImage method programmatically to insert images into the whiteboard. For example, We can insert the image returned by the GetCurrentImage method of cameraconneto the whiteboard.

The electronic whiteboard provided by OMCS supports the following features:

Shape 

(1) line segments, arrow lines, and double arrow lines

(2) horizontal elbow connector and vertical elbow connector

(3) rectangle, triangle, and elliptic (circle)

(4) Text

(5) Free Curve

(6) Insert an image

Operation 

(1) horizontal and vertical alignment

(2) Copying objects

(3) drag to change the shape and modify the object attributes (line width, color, fill color, Font, and actual line)

(4) cascade settings

(5) Save the whiteboard content as a bitmap

 

The above describes the APIs and usage of multimedia connectors in detail. The next article will introduce the last core object of OMCS: OMCS server. Thank you.

 

Read more articles in the OMCS development manual.

Certificate -----------------------------------------------------------------------------------------------------------------------------------------------

Download the free version of OMCS and demo source code

For any questions about OMCS, please contact us:

Tel: 027-87638960

Q: 168757008

Mail: master@oraycn.com

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.