Introduction to windowsmediasdk

Source: Internet
Author: User

I. Windows Media SDK

Microsoft Windows Media technology is a powerful solution for stream transmission of multimedia content through the company's intranets and Internet. The platform supports Web site and web page development to transmit audio, video, and script commands with continuous data streams. The stream transmission multimedia capability allows users to download and play content over the network, reducing the waiting time and storage requirements for users' computers. At the same time, unlimited length of demonstration (such as live broadcast) is possible.
Windows Media technology supports various networks and protocols. Media format description arrangement, organization and synchronization of multimedia data transmission file formats, and optimized for network transmission and client playback. The media format not only specifies the format of the record file, but also specifies the format for live streaming. Run Microsoft? Windows Media? The Service server supports unicast and multicast. Microsoft? Windows Media? The software development kit (SDK) contains six main components, as shown in the table:
Table main components of the Windows Media SDK

Windows Media Services SDK
Manage unicast and Multicast Services

Windows Media Encoder SDK
Supports automatic interface for setting and controlling Windows Media Encoder

Windows Media Player SDK
Supports indows Media & Player ActiveX controls to provide multimedia capabilities to com-based documents (web pages ).

Windows Media metafiles
Allows you to create a metadata file playback list, including ad insertion, seamless banner and stream switching.

Windows Media Format SDK
Supports reading, writing, and editing windows media files.

Windows Media Rights Manager SDK
Supports protecting Windows Media files

Windows Media SDK
Microsoft Windows Media Service (SDK) includes a wide range of technologies, some of which meet website development needs, and others are for Internet Service Providers (ISVs ). The Windows Media Service SDK includes the following components.
Windows Media Unicast control:
A set of Microsoft ActiveX controls that control settings, monitoring, and management of the properties of the Windows Media Unicast service.
Windows Media station control:
Control settings, monitoring, and management of the properties of the Windows Media multicast service.
Windows Media Service authorization API:
Com compatible API, used to develop authorizedProgramPackage.
Windows Media Service Event Notification and authorization API:
Com-compatible APIs, used to develop programs authorized to the server.
Windows Media File Transfer control:
An ActiveX Control for receiving multicast files.

2.1 Windows Media Unicast Control
The Windows Media Unicast service is included in the nsunimgr. ocx file and includes two controls: Windows Media Unicast Management (Admin) and Windows Media Unicast tracking (traceview ). The former is used to set and manage servers, and the latter is used to monitor server events. To use the Windows Media Unicast Service Control, you must register the nsunimgr. ocx and nsoobj. DLL files on your computer.
The Admin Control is an ActiveX control used to manage unicast Windows Media Servers. In addition to exposing properties, methods, and events, it also manages a group of objects that provide different services. For example, the client object represents the Client Connected to the server, and the clients object represents the set of client objects. The Admin Control has the following functions:
Set and query server attributes, such as the maximum set bandwidth and the maximum number of connected users.
Monitors customer activities, including connection, disconnection, and play clip titles.
Monitors the entire system activity, including the server status, management functions, and server restrictions.
Filter the event types received by the control.
The runtime attribute exposed by the Admin Control is unavailable during application design. You can set or return the attribute value until the connect method is successfully completed.
Traceview provides an easy-to-use interface for monitoring unicast activities of the Windows Media Service. Its graphic user interface is used to display the list of events activated by running the Windows Media Service, including the event description, date and time triggered by the event.
Install and register the Windows Media Unicast control and related files in the SDK installer. Like other ActiveX controls, you can directly use them on HTML pages, VB, and VC ++ applications. You can use the traceview control to perform the following functions:
Pause and resume event monitoring.
Clear Event Log display.
Select the monitored event type, including server, client, admin, and alert events.
To activate the traceview control embedded in the application, you must call its setserver Method for initialization. It connects the traceview control to the server so that it can start to receive and display events.
2.2 Windows Media station control
Windows Media station control is an ActiveX? Control, allowing the Administrator to set the broadcast multicast station, start or stop the stream. The station control can perform the following tasks:
Create, delete, and manage sites.
Create, delete, and manage a stream.
Creating, deleting, and managing create, delete, and manage clients.
Create, delete, and manage host addresses
Create, delete, and manage the Windows Media station control objects.
The station defines the sending mechanism for the stream. For example, a website contains the site name, the target multicast address, and the site format. The website does not contain media content, but describes how to send the content. Each site can connect one or more customers. Can customers be Windows Media? Encoder or another Windows Media station control, can it be connected to the Windows Media Server through the media stream broadcast publishing (msbd) protocol? Player example. The site is related to the host address. The server Nic uses this address to broadcast content. Windows Media station controls objects to manage the following objects:
Channels collection objects, including many channel objects.
Channel object to manage channelformats management objects.
Channelformats collection objects, including many channelformat objects.
Channelformat object to manage streamdescriptors collection objects.
Streamdescriptors collection objects, including many streamdescriptor objects.
A streamdescriptor object that describes stream features.
A streams collection object that contains many stream objects.
Stream object, which defines the media stream content.
A clients collection object that contains many client objects.
Client object, which defines the administrator user.
Hostaddresses collection objects, including many address objects.
Address object, which defines the multicast address.
To use the Windows Media station control (nschmgr. ocx), you must install the Windows Media Service or copy the nschmgr. ocx control to your computer and register it with the regsvr32 application.
Create On-Demand Multicast

2.3 Windows Media Service authentication API
The Windows Media Service authentication API is designed to provide the component for creating user authentication plug-ins. When a user sends a request to a server with authentication features, the server authenticates the user identity. Generally, the user name and password are verified based on various authentication protocols. The Windows Media Service authenticator is a com-based object. Each authenticated person implements one authentication. Although you can register multiple validators in a system, you can only use one authenticator at a time.
The Windows Media Service requires the COM component to support the multi-threaded (coinit_multithreaded) model. When creating an Authentication Component, you must avoid using the single-threaded (coinit_apartmenthreaded) model. The former provides better performance and flexibility, but the concurrent model lacks the thread security features.
The security protocol used to exchange authentication information. Different validators can have the same type, but verify users based on different databases. Therefore, the type only describes how information is exchanged, rather than how information is verified. Windows Media Server and media? The player supports two built-in authentication protocols:
HTTP-BASIC
Microsoft Windows nt lan Manager (NTLM)
HTTP-BASIC exchanges information in text format, including the user name and password. This protocol is an ideal protocol for Internet applications. For NTLM authentication, the server uses an encrypted request/response solution to authenticate users, which is more suitable for intranet applications.
The following describes how to use the authentication API:
1. Initialization
First, the server queries the Registry to find the authentication plug-in component. For example, if a successful message is returned, the server retrieves the plug-in component class ID (CLSID) and provides examples of the plug-in object. Then, the server initializes the case object. The context content includes the attributes that describe certain features of the server, such:
Server Name and alias.
Server version number.
The initialize method provides an opportunity for the authenticator to perform the preparatory authentication tasks, such as establishing a user account connection and allocating system resources to the authenticator.
2. Authentication Type
After the authentication plug-in object is initialized, the server calls the getauthenticationtype method to retrieve the authentication type. Players must be aware of this type, and currently Windows Media players only support HTTP-BASIC and NTLM.
3. User Authentication objects
The authentication object is managed by the authenticated object, which implements the inssauthenticator interface. Check and verify the user information each time the user connects. Each time a user connects to the server, a different Authentication object is created. The server calls the createuserauthentication method to create a user authentication object.
4. Authentication Operation Mode
The server notifies the Windows Media Player that user authentication is required each time the user requests to open the title. The server requests user name and password and transmits the data to the authenticator for verification. The Authenticator compares the incoming verification information sent from the server to the corresponding user database, notifying the server that the verification is complete or further communication is required. Windows Media Player prompts the user to enter the user name and password verification information and sends it to the server. The server passes the information to the authenticator for verification. The Authenticator checks the information in the database and notifies the server of the result. Based on the results, the server allows or denies user access to the content.
5. After Authentication
After the user identity is determined, the server copies the pointer to the nss_user_authentication attribute of the user context. The authentication result and user name can be retrieved through the inssuserauthentication interface.
6. register an authenticated user
When installing the Windows Media Service component, add a key value similar to the following in the computer registry:
[HKEY_LOCAL_MACHINE \ SOFTWARE \ Microsoft \ netshow \ servers \
\ Default \ Authentication]
[HKEY_LOCAL_MACHINE \ SOFTWARE \ Microsoft \ netshow \ servers \
\ Default \ Authentication \ sample Authentication Module]
"CLSID" = "{16da4310-2955-11d1-9e98-006097d2d7cf }"
"Description" = "sample authentication module"
"Author" = "Developer name"
"Copyright" = "? Developer 1998"
"Enabled" = DWORD: 00000001

Section 3 Windows Media Encoder SDK
Windows Media? Encoder is mainly used to encode media content into Windows Media? Format stream or file. A media stream or file contains audio, video, or script data. The Media Encoder exposes methods and attributes using the idispatch interface.
First, you must specify the guid for the Media Encoder:
Static const guid clsid_iasfrtencoder =
{0x7deba670, 0x68ab, 0x11d0, {0x98, 0xeb, 0x00, 0xaa, 0x00, 0xbb, 0xb5, 0x2c }};
Next, use the connecttoenc function to connect to an example of the Media Encoder. For example, if the connection is successful, the function returns a valid pointer pirexunknown, pointing to the iuknown interface. Then use QueryInterface to obtain the idispatch interface:
Stdmethodimp cmyclass: connecttoenc (idispatch ** pidispatch)
{
Hresult hr;
Iunknown * pirexunknown = NULL;

If (null = pidispatch)
Return e_invalidarg;

HR = getactiveobject (clsid_iasfrtencoder, null, & pirexunknown );

If (succeeded (HR ))
HR = pirexunknown-> QueryInterface (iid_idispatch, (lpvoid *) pidispatch );

If (pirexunknown)
Pirexunknown-> release ();

Return hr;
}
The startnewenc function uses the cocreateinstance function to create a New Media Encoder example:
Stdmethodimp cmyclass: startnewenc (idispatch ** pidispatch)
{
Hresult hr;
Iunknown * pirexunknown = NULL;

If (null = pidispatch)
Return e_invalidarg;

HR = cocreateinstance (clsid_iasfrtencoder,
Null,
Clsctx_server,
Iid_idispatch,
(Lpvoid *) pidispatch );

Return hr;
}
Once the Media Encoder is installed, you can use the pidispatch pointer to stimulate the encoder method and manipulate its attributes. Now you can start coding:
Dim encoder as object
Set encoder = Createobject ("ASF. realtimeencoder ")
Encoder. loadasd ("C: \ sampleconfig. ASD ")
Encoder. Start
The stop encoding method is as follows:
Encoder. Stop
Set encoder = nothing
Record the content to the. ASF FileCodeAs follows:
Encoder. recordmaxsize = 5000 '5 MB file maximum size
Encoder. recordfilename = "C: \ sample. ASF"
Encoder. recordstart
Use the following method to stop a record:
Encoder. recordstop

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.