Windows Media Encoder 7.1 SDK

This documentation describes the Microsoft® Windows Media™ Encoder 7.1 Software Development Kit (SDK). The Windows Media Encoder SDK is one of the main components of the Microsoft® Windows Media™ SDK. Other components include the Microsoft® Windows Media™ Services SDK, the Microsoft® Windows Media™ Format SDK, the Microsoft® Windows Media™ Rights Manager SDK, and the Microsoft® Windows Media™ Player SDK.

The Windows Media Encoder SDK is designed for anyone who wants to develop a Windows Media™ Encoder application by using a powerful automation-based Application Programming Interface (API). With this SDK, a developer using C++, Microsoft® Visual Basic®, or a scripting language can capture multimedia content and encode it into a Windows Media file or stream. For instance, you can use this Automation API to:

  • Broadcast live content. A news organization can use the Automation API to schedule the automatic capture and broadcast of live content. Local transportation departments can stream live pictures of road conditions at multiple trouble spots, alerting drivers to traffic congestion, and advising them of alternate routes.
  • Batch-process content. A media production organization that must process a high volume of large files can create a batch process that uses the Automation API to repeatedly capture and encode streams, one after the other. Further, a corporation can use the Automation API to manage its streaming media services with its favorite scripting language and Windows® Script Host. Windows Script Host is a language-independent host that can be used to run any script engine on the Microsoft® Windows® 95 or later, Windows NT®, or Windows® 2000-based operating systems.
  • Create a custom encoder user interface. An Internet service provider (ISP) can build a user interface that implements the functionality of the Automation API to capture, encode, and broadcast media streams. Alternatively, you can use the predefined user interfaces within the automation API for the same purpose.
  • Remotely administer Windows Media Encoder. You can use the Automation API to run, trouble shoot and administer Windows Media Encoder from a remote computer.

This SDK documentation provides an overview of general encoding topics, a programming guide, and a full reference section documenting the exposed interfaces, enumerated types, and constants. Developers are also encouraged to refer to the source code of the included samples.

This document includes the following sections.

Section | Description
About the Windows Media Encoder SDK | Introduces the Windows Media Encoder interfaces and architecture, and discusses Windows Media-based content.
Programming Guide | Details the steps necessary for creating and configuring an encoding session. Examples illustrate how to use predefined configurations, send scripts, archive content, configure Windows Media Encoder, retrieve statistics and more.
Programming Reference | Explains in detail the interfaces, methods, and enumeration types that make up the Windows Media Encoder SDK.
Windows Media Encoder SDK Glossary | Defines the terms used in this documentation.

Next
© 2000 Microsoft Corporation. All rights reserved.


About the Windows Media Encoder SDK

The Microsoft® Windows Media™ Encoder application compresses live or stored audio and video content into Windows Media files or streams. It enables users to create multimedia productions from devices attached to their computer, translate audio/visual files into Windows Media™ Format, and either save the Windows Media-based content to a local file or broadcast it to the Internet.

You can use the Microsoft® Windows Media™ Encoder Software Development Kit (SDK) to develop programs that have the same functionality as the Windows Media Encoder application. This general introduction contains the following sections.

Section | Description
Overview of the Windows Media Encoder SDK | Discusses the steps that must be followed and the interfaces needed to encode multimedia content using the Windows Media Encoder SDK.
The Windows Media Encoder Application | Illustrates Windows Media Encoder SDK concepts by examining the predefined user interfaces.
SDK Architecture | Identifies the objects, dynamic link libraries and executable files that make up the Windows Media Encoder SDK.
Windows Media Format | Discusses Windows Media Format and the differences between the Windows Media Encoder SDK and the Microsoft® Windows Media™ Format SDK.
Samples | Describes the sample applications and sample code contained in the Windows Media Encoder SDK.

See Also

  • Windows Media Encoder 7.1 SDK
  • Windows Media Format SDK


Overview of the Windows Media Encoder SDK

This section introduces the Windows Media Encoder SDK by describing the general steps that must be followed to programmatically encode multimedia content. The interfaces required during each step are highlighted. Detailed information can be found in the Progamming Guide and the Programming Reference sections.

  1. Create a Windows Media Encoder object.

    To run Windows Media Encoder, create a WMEncoder object. You can do this in one of two ways: If you are not displaying the Windows Media Encoder user interface (UI), you must create a WMEncoder object directly. If you are displaying the UI, you can create a WMEncoderApp object, and use it to acquire a WMEncoder object. Because WMEncoderApp is an out-of-process object and WMEncoder is an in-process object, avoid using the former unnecessarily.
  2. Create a source group to hold new multimedia streams.

    A source group holds the synchronized multimedia streams being encoded. It must contain an audio stream, and can contain a video stream and a script stream. You can create multiple source groups, but all must contain the same media types and only one can be active (encoded) at a time. Use the IWMEncSourceGroupCollection interface to manage the collection of source groups, the IWMEncSourceGroup interface to manage a specific source group, and the IWMEncSource interface to manage a specific multimedia stream.
  3. Capture a multimedia stream from a file or device.

    Use the IWMEncSource interface to either load streams from a file or capture streams from a device. Use the IWMEncSourceGroup interface to add streams to a source group.
  4. Select a profile for the encoding session.

    A profile specifies a codec, and identifies the number and bit rate of the encoded output streams. Only one profile can be assigned to all of the source groups in the encoding session. Windows Media Encoder supplies multiple system profiles that cannot be either edited or deleted, but custom profiles can be created using Profile Manager. Use the IWMEncProfileCollection interface to manage the collection of profiles, and use the IWMEncProfile interface to manage a specific profile. You can use the Windows Media Format SDK to programmatically create and edit profiles, or you can use the IWMEncProfileManager interface in the Windows Media Encoder SDK to create Profile Manager dialog boxes that enable an end user to edit, list, and create profiles.
  5. Specify output options.

    You can both archive and broadcast encoded content. Use the IWMEncBroadcast interface to specify a port number for the encoded content being broadcast. The IWMEncFile interface can be used to specify the name and location of a file for archiving encoded content.
  6. Add optional descriptive information.

    The IWMEncAttributes interface can be used to specify optional custom information about the encoded content. The IWMEncDisplayInfo interface can be used to provide general descriptive information about the encoded content. You can collect this data from the user by creating an MSPropShell ActiveX® control to display the predefined Session Properties UI . You can also programmatically set the data objects without implementing a UI.
  7. Run Windows Media Encoder.

    Use the IWMEncoder interface to start and stop the encoding and optional archiving processes.

Example Code

' Create a WMEncoder object.
Dim Encoder As WMEncoder
Set Encoder = New WMEncoder

' Declare objects and variables.
Dim SrcGrpColl As IWMEncSourceGroupCollection
Dim SrcGrp As IWMEncSourceGroup
Dim AudSrc As IWMEncSource
Dim VidSrc As IWMEncVideoSource
Dim ProColl As IWMEncProfileCollection
Dim Pro As IWMEncProfile
Dim File As IWMEncFile
Dim i As Integer

' Create an IWMEncSourceGroupCollection object.
Set SrcGrpColl = Encoder.SourceGroupCollection

' Create an IWMEncSourceGroup object.
Set SrcGrp = SrcGrpColl.Add("SG_1")

' Create a video and an audio source object.
Set AudSrc = SrcGrp.AddSource(WMENC_AUDIO)
Set VidSrc = SrcGrp.AddSource(WMENC_VIDEO)

' Create an IWMEncFile object.
Set File = Encoder.File

' Specify the .avi source file.
AudSrc.SetInput "C:\filename.avi"
VidSrc.SetInput "C:\filename.avi"

' Specify the output Windows Media file.
File.LocalFileName = "C:\filename.wmv"

' Loop through the collection of system profiles to set
' a specific profile into the source group object.
Set ProColl = Encoder.ProfileCollection
For i = 0 To ProColl.Count - 1
    Set Pro = ProColl.Item(i)
    If Pro.Name = "profile name" Then
        SrcGrp.Profile = Pro 'ProColl.Item(i)
        Exit For
    End If
Next

' Provide descriptive information about the encoded content.
Dim Descr As IWMEncDisplayInfo
Set Descr = Encoder.DisplayInfo
Descr.Author = "Author name"
Descr.Copyright = "Copyright information"
Descr.Description = "Text description of encoded content"
Descr.Rating = "Rating information"
Descr.Title = "Title of encoded content"

' Add an attribute to the collection.
Dim Attr As IWMEncAttributes
Set Attr = Encoder.Attributes
Attr.Add "URL", "IP address"

' Tell the encoder to start archiving when the encoder
' engine starts running.
Encoder.EnableAutoArchive = True

' Initialize the encoder engine.
Encoder.PrepareToEncode True

' Start the encoder engine.
Encoder.Start

' Wait until the encoder engine stops before ending the program.
' You can do this by using the _IWMEncoderEvents object to create
' an event sink.

See Also

  • _IWMEncoderEvents Interface
  • _IWMEncoderEvents Object
  • About the Windows Media Encoder SDK
  • IWMEncAttributes Interface
  • IWMEncAttributes Object
  • IWMEncBroadcast Interface
  • IWMEncBroadcast Object
  • IWMEncDisplayInfo Interface
  • IWMEncDisplayInfo Object
  • IWMEncFile Interface
  • IWMEncFile Object
  • IWMEncoder Interface
  • IWMEncoderApp Interface
  • IWMEncProfile Interface
  • IWMEncProfile Object
  • IWMEncProfileCollection Interface
  • IWMEncProfileCollection Object
  • IWMEncProfileManager Interface
  • IWMEncProfileManager Object
  • IWMEncSource Interface
  • IWMEncSource Object
  • IWMEncSourceGroup Interface
  • IWMEncSourceGroup Object
  • IWMEncSourceGroupCollection Interface
  • IWMEncSourceGroupCollection Object
  • IMSPropShell Interface
  • MSPropShell Object
  • Programming Guide
  • Programming Reference
  • Windows Media Format SDK
  • WMEncoder Object
  • WMEncoderApp Object


The Windows Media Encoder Application

An end user can run the Windows Media Encoder application through a user interface (UI). By using the Windows Media Encoder SDK, you can run and configure Windows Media Encoder programmatically. You can also reuse the UI components built into Windows Media Encoder, build your own UI, or encode multimedia content without a UI. To introduce the major concepts with which you must be familiar to effectively utilize the Windows Media Encoder SDK, the following sections display the predefined user interfaces and discuss how an end user runs and configures the Windows Media Encoder application.

Section | Description
Running the Windows Media Encoder Application | Discusses each of the panels that make up the primary Windows Media Encoder UI.
Configuring the Windows Media Encoder Application | Discusses how the property pages displayed by the Session Properties UI can be used to configure an encoding session.
Running Profile Manager | Discusses how Profile Manager can be used to edit, create, remove and duplicate a profile.

This document describes how to create applications by using the Windows Media Encoder SDK. For more information about Windows Media Encoder functionality, see the Help documentation included with the Windows Media Encoder application.

See Also

  • About the Windows Media Encoder SDK


Running the Windows Media Encoder Application

This section provides an overview of Windows Media Encoder operation. You do not need to display the following UI to encode multimedia content, but understanding the UI can help you understand the programmable components in the Windows Media Encoder SDK. The illustration displays the UI panels and windows, each of which can be created programmatically with the WMEncoderApp object.

Main Windows Media Encoder user interface

Each rectangular button in the Sources panel represents a collection of synchronized multimedia streams called a source group. Each source group must contain one audio stream, and can contain one video and one text stream. Only one source group can be encoded at a time, and a highlighted button in the panel indicates the active group. Click a different button to switch to a different source group. Any source group that contains live video can display either an icon or descriptive text in the button. Source groups can be managed programmatically by the IWMEncSourceGroup and IWMEncSourceGroupCollection interfaces.

The Audio panel contains controls to adjust the volume of the active audio stream. You can also mix the audio stream if the hardware card supports mixing. Audio volume can be managed programmatically by the IWMEncoder interface.

The Video window displays either a preview of the active video stream, a postview or both. A preview renders the video image before it is encoded. A postview renders the same image after encoding. Thus, the postview more closely approximates the video image that will be displayed in Microsoft® Windows Media™ Player on the client computer. Previews and postviews can be displayed side by side. You can programmatically create a preview or postview using the IWMEncSource, IWMEncDataView, and IWMEncDataViewCollection interfaces.

The Monitor panel contains three predefined property pages. A General page displays information about the input sources and the compressed packets of multimedia data. A Display Information page contains string information such as the name of the author and the copyright. A Connections page describes the connection between the server and the client.

The Annotations panel inserts either a caption or a URL into the encoded stream as a type/data pair of strings. When Windows Media Player receives this pair, it fires an event and the type/data pair to the host application. The application can either respond to or ignore this transmission. Normally, however, when type = "TEXT", Windows Media Player automatically interprets the corresponding data string as captioned text and displays it in the caption area. When type = "URL", Windows Media Player automatically interprets the data string as a URL and opens it in a browser window. When type = "CUSTOM", however, the data string is not automatically interpreted. To process this type, you must embed Windows Media Player in an HTML page, capture the event, and process it yourself. Use the WMEncoder object to send a text stream to Windows Media Encoder.

The Archive controls start, stop and pause archiving encoded content to a file. The Manual button can be used to override the archive state set on each SourceGroup button in the Sources panel. Use the WMEncoder object to control the archiving process. Use the IWMEncFile interface to identify a file to which the encoded content can be saved.

The Control panel contains buttons for starting and stopping the encoding process. Use the WMEncoder object to control the broadcast.

See Also

  • IWMEncDataView Interface
  • IWMEncDataViewCollection Interface
  • IWMEncDataViewCollection Object
  • IWMEncoderApp Interface
  • IWMEncoder Interface
  • IWMEncSource Interface
  • IWMEncSource Object
  • IWMEncSourceGroup Interface
  • IWMEncSourceGroup Object
  • IWMEncSourceGroupCollection Interface
  • IWMEncSourceGroupCollection Object
  • The Windows Media Encoder Application
  • WMEncoder Object
  • WMEncoderApp Object


Configuring the Windows Media Encoder Application

The Session Properties and New Session dialog boxes enable an end user to:

  • Define source groups.
  • Provide descriptive information about the encoded content.
  • Add custom name-value pairs to the Windows Media file header.
  • Choose a profile.
  • Identify whether to broadcast or save encoded content.
  • Provide a name for the encoder engine to facilitate remote administration.
  • Add time compression to a Windows Media file.
  • Specify the UDP packet size when streaming encoded content across a network.

New Session dialog box

The end user can display this dialog box by clicking either New or Properties on the Session menu in the predefined user interface of the Windows Media Encoder application. You can programmatically create all or part of this dialog box using the MSPropShell ActiveX control included in the Windows Media Encoder SDK.

Note Programmatically configuring Windows Media Encoder while either the Session Properties or New Session dialog box is displayed can lead to unpredictable results.

The following sections discuss each property page in the dialog box.

Property page | Description
Sources page | Specifies the source groups that contain the input media streams.
Display Information page | Specifies general descriptions of the encoded content.
Attributes page | Specifies custom name-value pairs that provide extra information about an encoding session.
Profile page | Specifies the profile associated with the encoding session.
Output page | Specifies the protocol and port number used for broadcasting encoded content, and the name and location of the file used to save encoded content.
Advanced page | Retrieves the name of the current instance of Windows Media Encoder, specifies the maximum packet size, and enables time compression.

See Also

  • Displaying Property Pages
  • IMSPropShell Interface
  • MSPropShell Object
  • The Windows Media Encoder Application


Sources Page

The Sources page identifies the source groups available during the encoding session. All source groups contain the same combination of audio, video and text streams. The input devices used to capture these streams and the archive file are listed beside the source group name. The check boxes below them indicate which media types are included in the source groups.

Sources property page in the New Session dialog box

Use the IWMEncSource, IWMEncSourceGroup, and IWMEncSourceGroupCollection interfaces to programmatically manipulate input source streams and source groups.

See Also

  • Configuring the Windows Media Encoder Application
  • Displaying Property Pages
  • IWMEncSource Interface
  • IWMEncSource Object
  • IWMEncSourceGroup Interface
  • IWMEncSourceGroup Object
  • IWMEncSourceGroupCollection Interface
  • IWMEncSourceGroupCollection Object


Display Information Page

The Display Information page specifies a title, the author's name, and copyright, rating and general descriptive information about the content being encoded. This information is displayed in Windows Media Player.

Display Information property page in the New Session dialog box

Use the IWMEncDisplayInfo interface to programmatically supply descriptive information about the multimedia content.

See Also

  • Configuring the Windows Media Encoder Application
  • Displaying Property Pages
  • IWMEncDisplayInfo Interface
  • IWMEncDisplayInfo Object


Attributes Page

The Attributes page specifies the attributes (name-value pairs) that provide extra information about the encoded content. For example, to specify the time a file was created, you can assign the string "Time" to Name and the string "22:10:35" to Value. To specify that the encoded content was captured from videotape and contains political commentary, you can assign "Videotape" to Name and "Politics" to Value. Attributes are always custom defined and implemented.

Attributes property page in the New Session dialog box

Use the IWMEncAttributes interface to programmatically create and retrieve attributes during an encoding session. To retrieve the attributes from a Windows Media file, you must use the Windows Media Format SDK.

See Also

  • Configuring the Windows Media Encoder Application
  • Displaying Property Pages
  • IWMEncAttributes Interface
  • IWMEncAttributes Object


Profile Page

The Profile page specifies a codec, and identifies the number and bit rate of the encoded output streams.

Profile property page in the New Session dialog box

Use the IWMEncProfileCollection and the IWMEncProfile interfaces to programmatically retrieve a profile. You can create and edit profiles by using either Profile Manager or the Windows Media Format SDK. You cannot either delete or edit any of the system profiles. You can use the IWMEncProfileManager interface in the Windows Media Encoder SDK to create Profile Manager dialog boxes that edit and list profiles.

See Also

  • Configuring the Windows Media Encoder Application
  • Displaying Property Pages
  • IWMEncProfile Interface
  • IWMEncProfile Object
  • IWMEncProfileCollection Interface
  • IWMEncProfileCollection Object
  • IWMEncProfileManager Interface
  • IWMEncProfileManager Object
  • Windows Media Format SDK


Output Page

The Output page specifies the broadcast protocol and port number. Only the HTTP protocol can be used. The default port number is 8080, but other ports can be used. The Output page also specifies the name and location of the file being used to save the encoded content.

Output property page in the New Session dialog box

Use the IWMEncBroadcast interface to programmatically specify the protocol and port number used to broadcast encoded content. Use the IWMEncFile interface to programmatically specify the name of the file used for saving encoded content.

See Also

  • Configuring the Windows Media Encoder Application
  • Displaying Property Pages
  • IWMEncBroadcast Interface
  • IWMEncBroadcast Object
  • IWMEncFile Interface
  • IWMEncFile Object


Advanced Page

The Advanced page can be used to retrieve the name of the current instance of Windows Media Encoder, enable time compression, and specify the maximum packet size. The name of the encoder engine can be used during remote administration. Time compression accelerates both the audio and video portions of a stream without altering the pitch of the audio or breaking the synchronization between audio and video. The end user can control the maximum packet size to efficiently stream data packets across a network.

Advanced property page in the New Session dialog box

Use the Remote Administration Interfaces (C++) to programmatically control remote administration. To see a sample that illustrates remote administration, go to C:\WMSDK\WMEncSDK\Samples\VC\Encview and click EncView.dsw. Use the IWMEncProfile.MaxPAcketSize property to programmatically specify the maximum packet size. Use the WMEncoder.Name property to programmatically specify and retrieve the name of an encoder engine.

Time compression accelerates a video stream without altering either the quality or pitch of the accompanying audio stream. You can enable time compression programmatically by using the Time Compression Plug-in.

See Also

  • Configuring the Windows Media Encoder Application
  • Displaying Property Pages
  • IWMEncProfile.MaxPAcketSize
  • Remote Administration Interfaces (C++)
  • Remote Administration Objects (Visual Basic)
  • Time Compression Plug-in


Running Profile Manager

Profile Manager creates and edits the profiles needed to identify the appropriate codec, the multimedia input streams, and the number and bit-rate of the encoded output streams. The main dialog box enumerates the profiles residing on your system, describes the highlighted item, and provides options for editing, creating, removing and duplicating a profile. System-defined profiles, identified by the monitor icon in the following illustration, cannot be edited, but you can create, edit and delete custom profiles. Custom profiles are identified by the head-shaped icon in the following dialog box.

Profile Manager user interface

Use the IWMEncProfileCollection and the IWMEncProfile interfaces to programmatically retrieve a profile. You can create and edit profiles by using either Profile Manager or the Windows Media Format SDK. You cannot either delete or edit any of the system profiles. You can use the IWMEncProfileManager interface in the Windows Media Encoder SDK to create Profile Manager dialog boxes that edit and list profiles.

See Also

  • IWMEncProfile Interface
  • IWMEncProfile Object
  • IWMEncProfileCollection Interface
  • IWMEncProfileCollection Object
  • IWMEncProfileManager Interface
  • IWMEncProfileManager Object
  • The Windows Media Encoder Application
  • Windows Media Format SDK


SDK Architecture

The following diagram illustrates that the Windows Media Encoder SDK is built atop the Windows Media Format SDK, a lower-level API that contains the interfaces needed to:

  • Write Windows Media files from uncompressed audio, video, or script data.
  • Read and decompress Windows Media files.
  • Edit the header information contained in Windows Media files.

The Windows Media Encoder SDK includes a number of objects that can be independently instantiated:

  • The WMEncoderApp object displays the Windows Media Encoder user interface.
  • The IWMEncProfileManager object creates Profile Manager edit and list dialog boxes, and produces descriptive information for a specific profile.
  • The MSPropShell ActiveX control creates a generic property page container that can be used to display dialog boxes using the other property page objects listed in the following diagram.
  • The WMEncoder object configures and operates Windows Media Encoder.

Diagram illustrating the Windows Media Encoder SDK architecture

The following sections discuss the architecture in more detail.

Section | Description
Object Hierarchy | Illustrates the interrelationship between objects.
Object Packaging | Identifies the dynamic link libraries and executable files that make up the Windows Media Encoder SDK.

See Also

  • About the Windows Media Encoder SDK
  • IWMEncoder Interface
  • IWMEncoderApp Interface
  • IWMEncProfileManager Interface
  • IWMEncProfileManager Object
  • IMSPropShell Interface
  • MSPropShell Object
  • WMEncoder Object
  • WMEncoderApp Object


Object Hierarchy

Some objects in the Windows Media Encoder SDK can be created independently by using their class IDs. For instance, you can create a WMEncoder object, and retrieve a pointer to an IWMEncoder interface, with the following C++ code.

// Initialize the COM library
    HRESULT hr = Coinitialize(NULL);

// Create a WMEncoder object and retrieve an
// IWMEncoder interface pointer.
    IWMEncoder* pEncoder = NULL;
    HRESULT hr = CoCreateInstance( CLSID_WMEncoder,
                                   NULL,
                                   CLSCTX_INPROC_SERVER,
                                   IID_IWMEncoder
                                   (void**) (&pEncoder));

Pointers to other interfaces, however, must be retrieved through objects that already exist. For example, to retrieve an IWMEncBroadcast interface, you must use the get_Broadcast method in the IWMEncoder interface. You cannot use CoCreateInstance() to directly retrieve an IWMEncBroadcast interface.

// Create a broadcast interface
    IWMEncBroadcast* pBrdCst = NULL;
    hr = pEncoder->get_Broadcast(&pBrdCst);

The following sections discuss the hierarchy of object creation.

Section | Description
The WMEncoder Object | Illustrates how to create a WMEncoder object, and identifies the interfaces that can be acquired through the WMEncoder object.
The WMEncoderApp Object | Illustrates how to create a WMEncoderApp object, and discusses the difference between this and the WMEncoder object.
The MSPropShell ActiveX Control | Illustrates how to create and populate the MSPropShell ActiveX control.
The WMEncProfileManager Object | Illustrates how to create and use the WMEncProfileManager object.
The WMEncPreview Object | Illustrates how to create an IWMEncDataView object to display previews and postviews of multimedia data.
The WMEncoderAgent Object | Illustrates how to create a WMEncoderAgent object to administer Windows Media Encoder on a remote computer.
The WMEncoderAgentLocator Object | Illustrates how to use a WMEncoderAgentLocator object to create a WMEncoderAgent object.

See Also

  • IWMEncoder Interface
  • SDK Architecture
  • WMEncoder Object


The WMEncoder Object

To configure and run Windows Media Encoder without displaying the UI, you must create an instance of the WMEncoder object and use it to acquire the interfaces listed in the following diagram.

List of interface implemented by the WMEncoder class

Example Code

Visual Basic Example

' Create a WMEncoder object.
Dim encoder As WMEncoder
Set encoder = New WMEncoder

C++ Example

// Include libraries.

#include <windows.h>
#include "wmencode.h"

// Declare variables.

    HRESULT hr = S_OK;
    IWMEncoder* pEncoder = NULL;

// Initialize the COM library and retrieve a pointer
// to an IWMEncoder interface.

    hr = CoInitialize(NULL);
    hr = CoCreateInstance( CLSID_WMEncoder,
                           NULL,
                           CLSCTX_INPROC_SERVER,
                           IID_IWMEncoder,
                           (void**) (&pEncoder));

See Also

  • IWMEncoder Interface
  • Object Hierarchy
  • WMEncoder Object


The WMEncoderApp Object

To display the predefined user interface and run Windows Media Encoder, you must create an instance of a WMEncoderApp object and use it to acquire a WMEncoder object as illustrated in the following example code. Because the former is an out-of-process component and the latter is an in-process component, do not create a WMEncoderApp object if you do not need to display the UI.

Note When you use the predefined user interface, you must completely configure the encoder engine. If you do not, unpredictable results may occur.

Example Code

Visual Basic Example

' Create a WMEncoderApp object.
Dim EncoderApp As WMEncoderApp
Set EncoderApp = New WMEncoderApp

' Retrieve a WMEncoder object from the WMEncoderApp object.
Dim Encoder As WMEncoder
Set Encoder = EncoderApp.Encoder

' Make the UI visible.
encoderapp.Visible = True

C++ Example

// Include libraries.

#include <windows.h>
#include "wmencode.h"

// Declare variables.

    HRESULT hr = S_OK;
    IWMEncoder* pEncoder = NULL;
    IWMEncoderApp* pEncoderApp = NULL;

// Initialize the COM library and retrieve a pointer
// to an IWMEncoderApp interface.

    hr = CoInitialize(NULL);
    hr = CoCreateInstance( CLSID_WMEncoderApp,
                           NULL,
                           CLSCTX_LOCAL_SERVER,
                           IID_IWMEncoderApp,
                           (void**) (&pEncoderApp));

// Display the user interface.

    hr = pEncoderApp->put_Visible(VARIANT_TRUE);

// Acquire an IWMEncoder interface.

    hr = pEncoderApp->get_Encoder(&pEncoder);

See Also

  • IWMEncoderApp Interface
  • Object Hierarchy
  • WMEncoderApp Object


The MSPropShell ActiveX Control

To create a generic property page host, create an instance of the MSPropShell ActiveX control. Each of the property pages in the following list can be independently created and added to the property page container using methods included in this object. Together, these reusable components make up the Session Properties and New Session dialog boxes. For more information about the Session Properties dialog box, see Configuring the Windows Media Encoder Application.

List of property pages that can be added to the MSPropShell ActiveX control.

Example Code

Visual Basic Example

' Create a WMEncoder object.
Dim Encoder as New WMEncoder
Set Encoder = New WMEncoder

' Create the encoder property pages.
Dim PpgSources As New WMEncSourcesPage
Dim PpgDesc As New WMEncDisplayInfoPage
Dim PpgAttr As New WMEncAttributesPage
Dim PpgProf As New WMEncProfilePage
Dim PpgOut As New WMEncOutputPage

' Add the encoder to the property page shell.
' You must add the encoder before adding the property pages.
PropPageShell.AddObject Encoder

' Add the property pages to the property page shell. To create
' MSPropShell ActiveX control, select Components from the Project
' menu and Microsoft PropShell Control 1.0 from the Components
' dialog box. In the following, the ActiveX control has been named
' PropPageShell.

PropPageShell.AddPage PpgSources
PropPageShell.AddPage PpgDesc
PropPageShell.AddPage PpgAttr
PropPageShell.AddPage PpgProf
PropPageShell.AddPage PpgOut

C++ Example

// Include libraries.

#include <windows.h>
#include "mspropshell.h"
#include "wmencode.h"

// Declare variables.

    HRESULT hr = S_OK;
    IWMEncoder* pEncoder = NULL;
    IUnknown* pPpgSources = NULL;
    IMSPropShell* pMSPShell = NULL;

// Initialize the COM library and retrieve a pointer
// to an IWMEncoder interface.

    hr = CoInitialize(NULL);
    hr = CoCreateInstance(CLSID_WMEncoder,
                          NULL,
                          CLSCTX_INPROC_SERVER,
                          IID_IWMEncoder,
                          (void**) &pEncoder);

// Create a property page.

    hr = CoCreateInstance( CLSID_WMEncSourcesPage,
                           NULL,
                           CLSCTX_INPROC_SERVER,
                           IID_IUnknown,
                           (void**) (&pPpgSources));

// Create the property page shell.

    hr = CoCreateInstance(CLSID_MSPropShell,
                          NULL,
                          CLSCTX_INPROC_SERVER,
                          IID_IMSPropShell,
                          (void**) (&pMSPShell));

// Add the encoder to the property page shell.

    hr = pMSPShell->AddObject(pEncoder);

// Add the property page(s) to the property page shell.

    hr = pMSPShell->AddPage(pPpgSources);

See Also

  • IMSPropShell Interface
  • MSPropShell Object
  • Object Hierarchy


The WMEncProfileManager Object

The WMEncProfileManager object can be independently created as illustrated by the following example code. The IWMEncProfileManager object contains methods that create Profile Manager dialog boxes that enable an end user to list and create profiles.

Example Code

Visual Basic Example

' Create a WMEncProfileManager object.
Dim ProfileMgr As WMEncProfileManager
Set ProfileMgr = New WMEncProfileManager

Dim sLastProfile As String
Dim sProfileDirectory As String
Dim sDetailsString As String

' Display the dialog box that lists the profiles. Because you
' are calling WMEncProfileListEx() rather than WMEncProfileList()
' and have indicated that a new profile is audio only, if you
' bring up the New profile dialog box, only the audio checkbox
' will be selected.
ProfileMgr.WMEncProfileListEx WMENC_FILTER_AV, WMENC_FILTER_A, 0

' Display the New Profile dialog box. If you supply the name of an
' existing profile, the new profile will be a copy of that.
ProfileMgr.WMEncProfileEdit "profile_name", WMENC_FILTER_AV, 0

' Retrieve a string containing the details of a specific profile.
sDetailsString = ProfileMgr.GetDetailsString("profile_name", 0)

' Retrieve the name of last profile created during the current
' encoding session.
sLastProfile = ProfileMgr.LastCreatedProfile

' Retrieve a string containing the path of the directory in which
' custom profiles are stored.
sProfileDirectory = ProfileMgr.ProfileDirectory

C++ Example

// Include libraries.

#include <windows.h>
#include <atlbase.h>    // Includes CComBSTR.
#include "wmencode.h"

// Declare variables.

    HRESULT hr = S_OK;
    IWMEncProfileManager* pProfileMgr = NULL;

// Initialize the COM library and retrieve a pointer
// to an IWMEncProfileManager interface.

    hr = CoInitialize(NULL);
    hr = CoCreateInstance(CLSID_WMEncProfileManager,
                          NULL,
                          CLSCTX_INPROC_SERVER,
                          IID_IWMEncProfileManager,
                          (void**) &pProfileMgr);

    CComBSTR bstrLastProfile(L"");
    CComBSTR bstrProfileDirectory(L"");
    CComBSTR bstrDetailsString(L"");
    CComBSTR bstrProfileName(L"profile_name");

// Display the dialog box that lists the profiles. Because
// you are calling WMEncProfileListEx() rather than WMEncProfileList()
// and have indicated that a new profile is audio only, if you bring
// up the New profile dialog box, only the audio checkbox will be selected.

    hr = pProfileMgr->WMEncProfileListEx(WMENC_FILTER_AV,
                                         WMENC_FILTER_A,
                                         0);

// Display the New Profile dialog box. If you supply the name of an
// existing profile, the new profile will be a copy of that.

    hr = pProfileMgr->WMEncProfileEdit(bstrProfileName,
                                       WMENC_FILTER_AV,
                                       0);

// Retrieve a string containing the details of a specific profile.

    hr = pProfileMgr->GetDetailsString(bstrProfileName,
                                       0,
                                       &bstrDetailsString);

// Retrieve the name of last profile created by the end-user
// during the current encoding session.

    hr = pProfileMgr->get_LastCreatedProfile(&bstrLastProfile);

// Retrieve a string containing the path of the directory in which
// custom profiles are stored.

    hr = pProfileMgr->get_ProfileDirectory(&bstrProfileDirectory);

See Also

  • IWMEncProfileManager Interface
  • IWMEncProfileManager Object
  • Object Hierarchy


The WMEncPreview Object

You can create a WMEncPreview object to render previews and postviews in a child window. A preview displays a specific multimedia stream before it is compressed. A postview displays the same stream after compression and decompression. This is not an Automation-compliant object. Therefore, it cannot be used in a Microsoft® Visual Basic™ application.

C++ Example

// Include libraries.

#include <windows.h>
#include "wmencode.h"
#include "wmencvu.h"

// Declare variables.

    HRESULT hr = S_OK;
    IWMEncoder* pEncoder = NULL;
    IWMEncDataView* pPreview = NULL;
    IWMEncDataViewCollection* pPreviewColl = NULL;
    IWMEncSource* pSrcVid = NULL

// Initialize the COM library and retrieve a pointer
// to an IWMEncoder interface.

    hr = CoInitialize(NULL);
    CoCreateInstance(CLSID_WMEncoder,
                     NULL,
                     CLSCTX_INPROC_SERVER,
                     IID_IWMEncoder,
                     (void**) &pEncoder);

// Retrieve a pointer to a preview object.

    hr = CoCreateInstance( CLSID_WMEncPreview,
                           NULL,
                           CLSCTX_INPROC_SERVER,
                           IID_IWMEncDataView,
                           (void**)&pPreview);

// Retrieve preview collection.
// Assume that you have created a source group and a video source.

    hr = pSrcVid->get_PreviewCollection( &pPreviewColl );

// Add the preview object to the data view collection. If you set the
// cookie to -1, the encoder engine automatically generates a unique
// cookie.

    long lCookie = -1;
    hr = pPreviewColl->Add( pPreview, &lCookie);

// Initialize the encoder engine.

    hr = pEncoder->PrepareToEncode(VARIANT_TRUE);

// Create a parent window for the preview, and specify the window
// settings for the encoder engine. For instance, you can create a
// window by using the Win32 API function CreateWindow(), and pass the
// window handle retrieved from this function to the
// SetViewSetting() method.
// Windows Media Encoder embeds the preview window in the parent window.
// If you do not create a parent window, and do not specify the display
// settings, Windows Media Encoder creates a default window for the
// preview.

    HWND hWnd;
    hr = pPreview->SetViewSetting((DWORD) lCookie,
                                  sizeof(hWnd),
                                  (BYTE*)&hWnd);

// Start the encoder engine.

    hr = pEncoder->Start();

// Start previewing the stream in a pop-up window.

    hr = pPreview->Start((DWORD) lCookie);

See Also

  • IWMEncDataView Interface
  • IWMEncDataViewCollection Interface
  • IWMEncDataViewCollection Object
  • Object Hierarchy


The WMEncoderAgent Object

You can use the methods and properties in the WMEncoderAgent object to administer Windows Media Encoder on a remote computer. To see a sample that uses this object, go to C:\WMSDK\WMEncSDK\Samples\VC\Encview and click EncView.dsw.

See Also

  • IWMEncoderAgent Interface
  • Object Hierarchy
  • Remote Administration
  • Remote Administration Interfaces (C++)
  • Remote Administration Objects (Visual Basic)
  • Samples
  • WMEncoderAgent Object


The WMEncoderAgentLocator Object

Although you can use the WMEncoderAgent object within a C++ or Visual Basic application to administer Windows Media Encoder on a remote computer, scripting languages cannot create components on remote computers. Therefore, your VBScript or JScript application must first create an WMEncAgentLocator object, and then create the encoder agent.

' Declare objects.
Dim AgentLocator
Dim EncoderAgent

' Create a WMEncAgentLocator object.
Set AgentLocator = CreateObject("WMEncLoc.WNEncAgentLocator")

' Create a WMEncoderAgent object on a remote computer.
Set EncoderAgent = AgentLocator.GetAgent("computer name")

See Also

  • IWMEncoderAgentLocator Interface
  • Object Hierarchy
  • Remote Administration
  • Remote Administration Interfaces (C++)
  • Remote Administration Objects (Visual Basic)
  • WMEncAgentLocator Object


Object Packaging

Windows Media Encoder SDK objects and type libraries are organized into the dynamic link libraries and executable files discussed in the following sections.

Section | Description
WMEX.dll | Dynamic link library containing the IWMEncProfileManager interface and the reusable property page components.
WMEncEng.dll | Dynamic link library containing the interfaces that configure and run the encoder engine.
MSPShell.dll | Dynamic link library containing a generic interface for creating a property page host.
WMEnc.exe | Executable file containing the WMEncoderApp object.
Wmencagt.exe | Executable file containing the WMEncoderAgent object.
Wmencloc.dll | Dynamic link library containing the interfaces that administer Windows Media Encoder on a remote computer.
Wmprevu.dll | Dynamic link library containing the interface that creates previews and postviews of multimedia content.

See Also

  • SDK Architecture


WMEX.dll

The WMEX.dll dynamic link library contains user interface components and the IWMEncProfileManager interface. The classes are predefined property page objects used by the MSPropShell ActiveX control to create a Session Properties UI.

Interfaces

  • IWMEncProfileManager
  • MSPropShell Object

Classes (Property Pages)

  • WMEncAdvancedPage
  • WMEncAttributesPage
  • WMEncDisplayInfoPage
  • WMEncMonConnectionsPage
  • WMEncMonDisplayPage
  • WMEncMonMainPage
  • WMEncOutputPage
  • WMEncProfilePage
  • WMEncProfileManager
  • WMencSourcesPage
  • WMEncSourcesAltPage

See Also

  • IMSPropShell Interface
  • Interfaces (C++)
  • IWMEncoderApp Interface
  • IWMEncProfileManager Interface
  • IWMEncProfileManager Object
  • MSPropShell Object
  • Object Packaging
  • Objects (Visual Basic)
  • WMEncoderApp Object


WMEncEng.dll

The WMEncEng.dll dynamic link library contains the interfaces needed to configure and operate the encoder engine.

Interfaces

  • _IWMEncoderEvents Interface
  • IWMEncAttributes Interface
  • IWMEncBroadcast Interface
  • IWMEncDataViewCollection Interface
  • IWMEncDisplayInfo Interface
  • IWMEncFile Interface
  • IWMEncFileArchiveStats Interface
  • IWMEncIndexerStats Interface
  • IWMEncNetConnectionStats Interface
  • IWMEncoder Interface
  • IWMEncOutputStats Interface
  • IWMEncPluginInfo Interface
  • IWMEncProfile Interface
  • IWMEncProfileCollection Interface
  • IWMEncProfileManager Interface
  • IWMEncSource Interface
  • IWMEncSourceGroup Interface
  • IWMEncSourceGroupCollection Interface
  • IWMEncSourcePluginInfoManager Interface
  • IWMEncStatistics Interface
  • IWMEncTransform Interface
  • IWMEncTransformCollection Interface
  • IWMEncTransformPluginInfoManager Interface
  • IWMEncVideoSource Interface

Class

  • WMEncoder

See Also

  • Interfaces (C++)
  • IWMEncoder Interface
  • Object Packaging
  • Objects (Visual Basic)
  • WMEncoder Object


MSPShell.dll

The MSPShell.dll dynamic link library contains the IMSPropShell interface that can be used to create a general-purpose property page host. The Windows Media Encoder application uses IMSPropShell to implement the predefined property pages of the Session Properties UI.

Interface

  • IMSPropShell Interface

Class

  • MSPropShell

See Also

  • IMSPropShell Interface
  • MSPropShell Object
  • Object Packaging


WMEnc.exe

The WMEnc.exe executable file starts the Windows Media Encoder application and displays the user interface. It contains the WMEncoderApp object and the IWMEncoderApp interface.

Interface

  • IWMEncoderApp Interface

Class

  • WMEncoderApp

See Also

  • Interfaces (C++)
  • IWMEncoderApp Interface
  • Object Packaging


WMEncagt.exe

The WMEncagt.exe executable file contains the WMEncoderAgent object.

See Also

  • Object Hierarchy
  • Remote Administration
  • Remote Administration Interfaces (C++)
  • Remote Administration Objects (Visual Basic)
  • WMEncoderAgent Object


Wmencloc.dll

The WMEncloc.dll dynamic link library contains the interfaces needed to administer Windows Media Encoder on a remote computer.

Interfaces

  • IWMEncoderAgent Interface
  • IWMEncoderNamesCollection Interface

Class

  • WMEncoderAgent

See Also

  • Object Hierarchy
  • Remote Administration
  • Remote Administration Interfaces (C++)
  • Remote Administration Objects (Visual Basic)
  • WMEncoderAgent Object


Wmprevu.dll

The Wmprevu.dll dynamic link library contains the IWMEncDataview interface needed to create previews and postviews of multimedia content. This is not an Automation-compliant interface. Therefore, it cannot be used inside a Visual Basic application.

Interface

  • IWMEncDataView Interface

Class

  • WMEncPreview

See Also

  • IWMEncDataView Interface
  • IWMEncDataViewCollection Interface
  • IWMEncSource::get_PostviewCollection
  • IWMEncSource::get_PreviewCollection


Windows Media Format

The following sections introduce Windows Media™ Format and the Windows Media Format SDK. The former defines the proprietary format of the compressed content produced by Windows Media Encoder. The latter provides low-level functionality to read multimedia data and create Windows Media-based content.

Section | Description
Windows Media Format Features | Describes several key aspects of Windows Media Format.
The Windows Media Format SDK | Compares the Windows Media Format SDK to the Windows Media Encoder SDK.

See Also

  • About the Windows Media Encoder SDK


Windows Media Format Features

Windows Media Format is a proprietary format designed primarily for streaming audio, video and text from Internet servers to client computers. A Windows Media file can also be stored and played locally. Each Windows Media file contains one or more media streams that together form a multimedia presentation. Stream delivery is synchronized to a common timeline. The following list presents the key features of Windows Media Format:

  • A Windows Media file can be transported over any underlying data communication transport protocol. Windows Media Format does not specify the format of data packets for different network protocols.
  • Windows Media Format is scalable to any bandwidth. A single input stream can be encoded into multiple output streams within a single Windows Media file. Each scaled stream differs by the bit rate at which it can be rendered, and only one can be rendered at a time. The Windows Media server uses intelligent streaming to send the highest quality stream a client is capable of receiving.
  • The delivery and presentation of multiple media streams is synchronized to a common timeline. The media data inside a Windows Media file is time-stamped.
  • A Windows Media file can contain one video, one audio and one script stream.
  • A client does not need to store Windows Media-based content to play a multimedia stream.
  • The Windows Media Format SDK facilitates lower level control of reading and writing operations.

See Also

  • Windows Media Format
  • Windows Media Format SDK


The Windows Media Format SDK

The Windows Media Encoder SDK is an Application Programming Interface (API) built on top of the Windows Media Format SDK. The latter contains interfaces that read multimedia data from a file or buffer and write encoded Windows Media-based content. The former extends this functionality so that you can create higherlevel programmatic solutions for the configuration, capture, transformation and encoding processes.

Both of the SDKs convert raw multimedia content into a Windows Media file or stream, but with the Windows Media Format SDK you must manage the data flow at every step of the process. The following table identifies the main differences between the Windows Media Encoder SDK and the Windows Media Format SDK.

Functionality | Windows Media Encoder SDK | Windows Media Format SDK
Automates an application. | Yes | No
Automatically reads raw multimedia content, and compresses and writes it as Windows Media-based content. | Yes | No
Can transform audio-visual streams to Windows Media Format. | Yes | No
Provides an optional Windows Media Encoder user interface. | Yes | No
Implements Profile Manager. | Yes | No
Can remotely control Windows Media Encoder. | Yes | No
Compresses multimedia data | Yes | Yes
Edits the header information of a Windows Media file. | Yes | Yes
Tracks encoding statistics. | Yes | Yes
Decompresses multimedia data for playback. | No | Yes
Programmatically creates a profile. | No | Yes
Supports programming languages. | C, C++, Microsoft® Visual Basic®, Visual Basic Scripting Edition, Microsoft® JScript®, Microsoft® Windows® Script Host | C, C++

See Also

  • Windows Media Format


Samples

The executable files and code samples supplied with the Windows Media Encoder SDK are in the form of projects for Microsoft® Visual C++® version 6.0 and Microsoft Visual Basic.

Note You must have Visual Basic version 6.0 installed to run the Visual Basic sample programs (Batcher.exe, EncControl.exe, StationManager.exe, and TOWM.exe).

The following samples are installed in C:\WMSDK\WMEncSDK\Samples.

Sample | Description
Batcher | Visual Basic sample that creates a batch process to automatically encode audio, audio-visual, and Windows Media files. The sample demonstrates how to add source streams to the batch process and remove streams from it, how to load and save batch processes, how to enumerate the profile collection and assign a specific profile to Windows Media Encoder, how to transcode from audio-visual files to Windows Media files without using the predefined user interface, and how to start and stop the encoder engine.
EncControl | Visual Basic sample that configures, starts and stops the encoder engine. The sample demonstrates how to create a generic property page container using the MSPropShell ActiveX control and populate it with the reusable property page objects included in the Windows Media Encoder SDK. These property pages are used to identify the source of an input stream, describe the multimedia content produced, specify attributes, choose a profile, and specify either a port number or a file to send the encoded content to. The source code also demonstrates how to start and stop the encoder engine and display statistics about the encoding process.
EncControl | Visual C++ sample corresponding to the Visual Basic EncControl sample.
EncView Visual C++ sample that demonstrates remote administration of Windows Media Encoder. The sample illustrates how to embed, in an HTML page, an ActiveX control that can be used to display the properties of each encoder engine running on a remote computer.

You must install Atlapp.h before you can build this sample. Go to the Download Center at the Microsoft Web site, and perform the following steps:

  1. Click Keyword Search.
  2. In the Keywords text box, type Platform SDK.
  3. In the Operating System drop-down box, click Windows 2000.
  4. In the Show Results for drop-down box, click All Downloads.
  5. Click Find It!.
  6. Click Microsoft Platform SDK in the sorted list.
  7. On the Microsoft Platform SDK page, click Installing the Platform SDK, and then, under Download the Platform SDK from the Web, click here.
  8. On the Instructions for Web Download page, click Download for Whistler, Windows NT/2000, and Windows 98/Me.
  9. Click Run this program from its current location.
  10. Click I Agree to the end-user license agreement.
  11. Enter the requested user information.
  12. Click Custom when prompted to select an installation type.
  13. Select a location to install the Platform SDK.
  14. Select only the Source Code (199.4 KB max download) feature. This installs the required files to ..\Src\WTL\Include.
StationManager | Visual Basic sample that manages broadcast stations. The sample demonstrates how to create, configure, and add stations to a broadcast manager dialog box. The source code also demonstrates how to define a playlist for each station, add or remove streams from the playlist, specify the source for each stream, and start the encoder engine to broadcast a specific station to a local network or the Internet.
TOWM | Visual Basic command line sample that creates encoded content using an input file and profile specified as command line arguments.

See Also

  • About the Windows Media Encoder SDK


Programming Guide

You can use the Microsoft® Windows Media™ Encoder 7.1 Software Development Kit (SDK) to create Windows Media-based content from live sources, audio-visual files, and attached capture devices. The following sections explain in detail the steps required to encode multimedia content. For more information about each interface and object, see the Programming Reference section.

Section | Description
Include Files and Type Libraries | Identifies the required and optional header files, the type libraries and Microsoft® ActiveX® controls included in the Windows Media Encoder SDK.
File Name Extension Guidelines | Identifies the file name extensions needed to produce a Windows Media file.
Software Redistribution Setup | Describes how to include the Windows Media Encoder SDK in an application setup.
Plug-ins | Describes how to use the plug-ins included in the Windows Media Encoder SDK to capture and transform multimedia streams.
Batch Files and Windows Script Host | Describes how to use Microsoft® Visual Basic® Scripting Edition and Microsoft® Windows® Script Host (WSH) to automatically encode multiple audio-visual files.
Remote Administration | Describes how to administer an instance of Microsoft® Windows Media™ Encoder running on a remote computer.
Code Examples | Provides Microsoft® Visual Basic® and C++ examples illustrating how to use the Windows Media Encoder SDK.

See Also

  • Programming Reference
  • Windows Media Encoder 7.1 SDK


Include Files and Type Libraries

The following header files are provided with the Windows Media Encoder SDK:

#include "wmencode.h"
#include "mspropshell.h"
#include "wmencvu.h"
#include "localagent.h"
#include "wmsencid.h"

The first file includes interfaces that configure and run Windows Media Encoder. The second includes interfaces that enable you to implement dialog boxes containing the predefined property pages. The third includes an interface that can be used to create and run a preview of a stream. The fourth includes interfaces that enable remote administration of Windows Media Encoder. The fifth includes a complete set of DISPID definitions.

Instead of including the Wmencode.h and Mspropshell.h header files, you can import the corresponding type libraries to generate wrapper classes that simplify implementation of the related COM interfaces.

#import "WMEnc.exe"
#import "MSPShell.dll"

If you develop in Microsoft® Visual Basic®, you must add a reference to the type library contained in Wmencode.exe by clicking References on the Project menu and selecting the Windows Media Encoder object library. To develop applications that enable remote administration, you must also select the Windows Media Encoder Agent and Windows Media Encoder Agent Locator object libraries. To use the MSPropShell control, you must click Components on the Project menu and select Microsoft PropShell Control 1.0.

See Also

  • Code Examples
  • Programming Guide


File Name Extension Guidelines

A file name extension provides information about the content contained in the file. The following guidelines pertain specifically to Windows Media-based content:

  • Applications that create Windows Media files containing audio streams, script streams or both must use the .wma file name extension.
  • Applications that create Windows Media files containing both audio and video streams must use the .wmv extension. Such files can also contain script streams.
  • Files containing predefined Windows Media Encoder configurations must use the .wme extension.
  • Do not use the .asf file name extension for Windows Media files. The .asf extension supports legacy content only.

See Also

  • Programming Guide


Software Redistribution Setup

The inclusion of Windows Media Encoder software in an application setup is known as redistribution. Redistribution setup is discussed in the following sections.

Section | Description
Redistribution Package | Describes the redistribution package that is installed when you run WMEDist.exe.
Redistribution Example Code | Provides code examples for the redistribution setup.

See Also

  • Programming Guide


Redistribution Package

The redistribution package is contained in WMEDist.exe. It includes the following components.

File | Description
MSPShell.dll | Contains an ActiveX control that creates a general-purpose property page host.
WMEnc.exe | Contains the Windows Media Encoder application.
WMEncagt.exe | Contains the interfaces needed to remotely administer Windows Media Encoder.
WMEncEng.dll | Contains the interfaces needed to configure and run Windows Media Encoder.
WMEncEnu.dll | Contains English-language resources for WMEncEng.dll.
WMEncloc.dll | Contains an interface that can be used to create a WMEncoderAgent object on a remote computer.
WMerrenu.dll | Contains error resources.
WMEx.dll | Contains the IWMEncProfileManager interface and property page components.
WMExEnu.dll | Contains English-language resources for WMEx.dll.
WMFdist.exe | Contains the redistribution package for the Microsoft® Windows Media™ Format Software Development Kit (SDK).

To create a redistribution setup

  1. Before invoking the redistribution packages, use your setup routine to install your application files and make required settings.
  2. Install WMEDist.exe. You can use the /Q:A flag to do a quiet, unattended installation and suppress the user interface of the redistribution setup during the installation of your application. You can also use the /R:N flag to suppress restarting during installation. For example:
    WMEDist.exe /Q:A /R:N

    By default, WMEDist.exe installs Windows Media Encoder in C:\Program Files\Windows Media Components\Encoder.

See Also

  • Software Redistribution Setup


Redistribution Example Code

You can use the /Q:A flag to perform a quiet, unattended installation and suppress the user interface of the redistribution setup during the installation of your application. You can also use the /R:N flag to suppress restarting during installation, but your routine must determine whether it is necessary to restart the computer.

The following code example can be used in your setup routine to run the redistribution packages in quiet mode and notify your setup routine when the computer must be restarted.

#define MAX_TIMEOUT_MS 30 * 60 * 1000
#define TIME_INCREMENT 250
///////////////////////////////////////////////////////////////////////
BOOL SystemNeedsReboot( )
///////////////////////////////////////////////////////////////////////
{
    BOOL fNeedExists = FALSE;
    OSVERSIONINFO osvi;

    osvi.dwOSVersionInfoSize = sizeof( OSVERSIONINFO );
    GetVersionEx( &osvi );

    if( VER_PLATFORM_WIN32_NT != osvi.dwPlatformId )
    {
        TCHAR szIniPath[MAX_PATH];

        GetWindowsDirectory(szIniPath, sizeof(szIniPath)/sizeof(TCHAR));
        AppendSlash( szIniPath );
        _tcscat( szIniPath, _T("wininit.ini") );

        if( 0xFFFFFFFF != GetFileAttributes( szIniPath ) )
        {
            HFILE hFile;

            if( (hFile = _lopen( szIniPath, OF_READ|OF_SHARE_DENY_NONE))
                                                        != HFILE_ERROR )
            {
                fNeedExists = ( 0 != _llseek(hFile, 0L, FILE_END) );
                _lclose(hFile);
            }
        }
    }
    else
    {
        HKEY hKey = NULL;

        if( ERROR_SUCCESS == RegOpenKeyEx( HKEY_LOCAL_MACHINE,
              _T("System\\CurrentControlSet\\Control\\Session Manager"),
              0, KEY_READ, &hKey ) )
        {
            if( ERROR_SUCCESS == RegQueryValueEx( hKey,
            _T("PendingFileRenameOperations"), NULL, NULL, NULL, NULL))
            {
                fNeedExists = TRUE;
            }

            RegCloseKey( hKey );
        }
    }

    return( fNeedExists );
}

///////////////////////////////////////////////////////////////////////
BOOL GoInstallWMRedist( BOOL fWaitForCompletion )
///////////////////////////////////////////////////////////////////////
{
    STARTUPINFO StartUpInfo;
    PROCESS_INFORMATION ProcessInfo;

    StartUpInfo.cb = sizeof( StartUpInfo );
    StartUpInfo.lpReserved = NULL;
    StartUpInfo.dwFlags = 0;
    StartUpInfo.cbReserved2 = 0;
    StartUpInfo.lpReserved2 = NULL;
    StartUpInfo.lpDesktop = NULL;
    StartUpInfo.lpTitle = NULL;
    StartUpInfo.dwX = 0;
    StartUpInfo.dwY = 0;
    StartUpInfo.dwXSize = 0;
    StartUpInfo.dwYSize = 0;
    StartUpInfo.dwXCountChars = 0;
    StartUpInfo.dwYCountChars = 0;
    StartUpInfo.dwFillAttribute = 0;
    StartUpInfo.dwFlags = 0;
    StartUpInfo.wShowWindow = 0;
    StartUpInfo.hStdInput = NULL;
    StartUpInfo.hStdOutput = NULL;
    StartUpInfo.hStdError = NULL;

// Run the installer with the Quiet for All dialogs and Reboot:Never
// flags. The installation should be silent, and the setup routine
// will be notified whether the computer must be restarted.

    if( !CreateProcess( "c:\\temp\\WMFRedist.exe",
            "c:\\temp\\WMFRedist.exe /Q:A /R:N", NULL, FALSE, 0,
            NULL, NULL, &StartUpInfo, &ProcessInfo ) )
    {
        DWORD myError = GetLastError();
        return( FALSE );
    }

    CloseHandle( ProcessInfo.hThread );

    if( fWaitForCompletion )
    {
        DWORD dwTimePassed = 0;

        while( TRUE )
        {

            if( WAIT_TIMEOUT != WaitForMultipleObjects( 1,
                  &ProcessInfo.hProcess, FALSE, TIME_INCREMENT ) )
            {
                break;
            }

            if( dwTimePassed > MAX_TIMEOUT_MS )
            {
                TerminateProcess( ProcessInfo.hProcess, E_FAIL );
                break;
            }

            dwTimePassed += TIME_INCREMENT;
        }
    }

    CloseHandle( ProcessInfo.hProcess);

    if( SystemNeedsReboot() )
    {
       // Write some code here to ensure your application
       // restarts the computer, and delays dll registrations
       // until after the restart, if possible. For example,
       // set a global flag for use by the application.
    }

    return( TRUE );
}

See Also

  • Software Redistribution Setup


Plug-ins

The Windows Media Encoder SDK uses source plug-ins to capture streams, and transform plug-ins to manipulate streams. The following table categorizes the available of plug-ins by scheme type.

Scheme type | Plug-in type | Description
Device | Source | Captures a stream from an attached device.
File | Source | Captures a stream from a file.
ScreenCap | Source | Captures a stream from the screen.
UserScript | Source | Sends a script stream to the encoder engine.
TCGroupTransformPlugin | Transform | Enables accelerated rendering of a stream without audio or video distortion.

The scheme type is a pre-defined string that must, except when sourcing from a file, be used to identify the plug-in. The following sections illustrate how to use each plug-in.

Section | Description
Plug-in Property Pages | Describes how to display the property pages for plug-ins that support property pages.
Device Plug-in | Describes how to capture a stream from an attached device.
File Plug-in | Describes how to capture a stream from a file.
Screen Capture Plug-in | Describes how to capture a stream from the screen.
Script Plug-in | Describes how to send a script stream to the encoder engine.
Time Compression Plug-in | Describes how to apply time compression to an encoded stream.

See Also

  • Programming Guide


Plug-in Property Pages

The device, screen capture, and time compression plug-ins support property pages. You can display these pages to enable an end-user to configure the plug-in. The following examples illustrate how to invoke property pages for source and transform plug-ins.

Source Plug-in Property Pages

// Include libraries.

#include <windows.h>
#include <atlbase.h>
#include "wmencode.h"

// Declare variables.

    HRESULT hr;
    IWMEncoder* pEncoder;
    IWMEncSourceGroupCollection* pSrcGrpColl;
    IWMEncSourceGroup* pSrcGrp;
    IWMEncSource *pVidSrc, *pAudSrc;
    IWMEncProfileCollection* pProColl;
    IWMEncProfile* pPro;
    IUnknown* pPlugin = NULL;
    ISpecifyPropertyPages* pPages = NULL;
    CAUUID uuid;
    HWND m_hWnd = NULL;

    long lCount;
    int i;

// Initialize the COM library and retrieve a pointer
// to an IWMEncoder interface.

    hr = CoInitialize(NULL);
    hr = CoCreateInstance(CLSID_WMEncoder,
                          NULL,
                          CLSCTX_INPROC_SERVER,
                          IID_IWMEncoder,
                          (void**) &pEncoder);

// Retrieve a pointer to an IWMEncSourceGroupCollection
// interface.

    hr = pEncoder->get_SourceGroupCollection(&pSrcGrpColl);

// Add an empty source group to the collection.

    hr = pSrcGrpColl->Add(L"SG_1", &pSrcGrp);

// Add video and audio streams to the source group.

    hr = pSrcGrp->AddSource(WMENC_VIDEO, &pVidSrc);
    hr = pSrcGrp->AddSource(WMENC_AUDIO, &pAudSrc);

// Specify the plug-in to use for capturing the streams.

    hr = pVidSrc->SetInput(L"DEVICE://Default_Video_Device");
    hr = pAudSrc->SetInput(L"DEVICE://Default_Audio_Device");

// Loop through the profile collection and retrieve a specific
// profile.

    hr = pEncoder->get_ProfileCollection(&pProColl);
    CComVariant varProfile;
    varProfile.vt = VT_DISPATCH;
    hr = pProColl->get_Count(&lCount);
    for (i=0; i<lCount; i++)
    {
        CComBSTR bstrName(L" ");
        hr = pProColl->Item(i, &pPro);
        hr = pPro->get_Name(&bstrName);
        if (_wcsicmp(bstrName, L"profile_name")==0)
        {
            varProfile.pdispVal = pPro;
            pSrcGrp->put_Profile(varProfile);
            break;
        }
    }

// Initialize the encoder engine.

    hr = pEncoder->PrepareToEncode(VARIANT_TRUE);

// Retrieve the plugin object.

    hr = pVidSrc->GetSourcePlugin( &pPlugin );

// Call QueryInterface to verify whether the plug-in supports
// property pages. If it does, retrieve a pointer to the
//ISpecifyPropertyPages interface, and fill an array of GUID
// values in which each GUID specifies the CLSID of each property
// page that can be displayed for this object.

    hr = pPlugin->QueryInterface(IID_ISpecifyPropertyPages,
                                (LPVOID*)&pPages);

    hr = pPages->GetPages( &uuid );

// Invoke a dialog box to display

    hr = OleCreatePropertyFrame
         (
          m_hWnd,              // You must create the parent window.
          200,                 // Horizontal position for the dialog box.
          200,                 // Vertical position for the dialog box.
          L"name",             // String used for the dialog box caption.
          1,                   // Number of pointers passed in pPlugin.
          &pPlugin,            // Pointer to the plug-in.
          uuid.cElems,         // Number of property pages.
          uuid.pElems,         // Array of property page CLSIDs.
          LOCALE_USER_DEFAULT, // Locale ID for the dialog box.
          0,                   // Reserved.
          NULL                 // Reserved.
          );

// Release memory.

    if ( uuid.pElems )
    {
        CoTaskMemFree( uuid.pElems );
    }

Transform Plug-in Property Pages

// Include headers.

#include <windows.h>
#include <atlbase.h>
#include "wmencode.h"

// Declare variables.

    HRESULT hr;
    IWMEncoder* pEncoder;
    IWMEncSourceGroupCollection* pSrcGrpColl;
    IWMEncSourceGroup* pSrcGrp;
    IWMEncSource *pVidSrc, *pAudSrc;
    IWMEncProfileCollection* pProColl;
    IWMEncProfile* pPro;
    IWMEncTransformCollection* pTransColl;
    IWMEncTransform* pTrans;
    IUnknown* pPlugin = NULL;
    ISpecifyPropertyPages* pPages = NULL;
    CAUUID uuid;
    HWND m_hWnd = NULL;

    long lCount;
    int i;

// Initialize the COM library and retrieve a pointer
// to an IWMEncoder interface.

    hr = CoInitialize(NULL);
    hr = CoCreateInstance(CLSID_WMEncoder,
                          NULL,
                          CLSCTX_INPROC_SERVER,
                          IID_IWMEncoder,
                          (void**) &pEncoder);

// Retrieve a pointer to an IWMEncSourceGroupCollection
// interface.

    hr = pEncoder->get_SourceGroupCollection(&pSrcGrpColl);

// Add an empty source group to the collection.

    hr = pSrcGrpColl->Add(L"SG_1", &pSrcGrp);

// Add video and audio streams to the source group.

    hr = pSrcGrp->AddSource(WMENC_VIDEO, &pVidSrc);
    hr = pSrcGrp->AddSource(WMENC_AUDIO, &pAudSrc);

// Specify the plug-ins to use for capturing streams from the
// video card.

    hr = pVidSrc->SetInput(L"DEVICE://Default_Video_Device");
    hr = pAudSrc->SetInput(L"DEVICE://Default_Audio_Device");

// Loop through the profile collection and retrieve a specific
// profile.

    hr = pEncoder->get_ProfileCollection(&pProColl);
    CComVariant varProfile;
    varProfile.vt = VT_DISPATCH;
    hr = pProColl->get_Count(&lCount);
    for (i=0; i<lCount; i++)
    {
        CComBSTR bstrName;
        hr = pProColl->Item(i, &pPro);
        hr = pPro->get_Name(&bstrName);
        if (_wcsicmp(bstrName, L"profile_name")==0)
        {
            varProfile.pdispVal = pPro;
            pSrcGrp->put_Profile(varProfile);
            break;
        }
    }

// Retrieve the group transform collection.

    hr = pSrcGrp->get_GroupTransformCollection(&pTransColl);

// Add a transform plug-in to the collection.

    hr = pTransColl->Add(&pTrans);

// Set the time compression plug-in.

    hr = pTrans->SetInput(
             L"TCGroupTransformPlugin://");

// Initialize the encoder engine.

    hr = pEncoder->PrepareToEncode(VARIANT_TRUE);

// Retrieve an IUnknown pointer to the transform plug-in object.

    hr = pTrans->GetTransformPlugin(&pPlugin);

// Call QueryInterface to verify whether the plug-in supports
// property pages. If it does, retrieve a pointer to the
// ISpecifyPropertyPages interface, and fill an array of GUID
// values in which each GUID specifies the CLSID of each property
// page that can be displayed for this object.

    hr = pPlugin->QueryInterface(IID_ISpecifyPropertyPages,
                                (LPVOID*)&pPages);

    hr = pPages->GetPages( &uuid );

// Invoke a dialog box to display.

    hr = OleCreatePropertyFrame
         (
          m_hWnd,              // You must create the parent window.
          200,                 // Horizontal position for the dialog box.
          200,                 // Vertical position for the dialog box.
          L"name",             // String used for the dialog box caption.
          1,                   // Number of pointers passed in pPlugin.
          &pPlugin,            // Pointer to the plug-in.
          uuid.cElems,         // Number of property pages.
          uuid.pElems,         // Array of property page CLSIDs.
          LOCALE_USER_DEFAULT, // Locale ID for the dialog box.
          0,                   // Reserved.
          NULL                 // Reserved.
          );

// Release memory.

    if ( uuid.pElems )
    {
        CoTaskMemFree( uuid.pElems );
    }

See Also

  • Device Plug-in
  • Plug-ins
  • Screen Capture Plug-in
  • Time Compression Plug-in


Device Plug-in

You can use this plug-in to capture streams from devices attached to your computer. The current Windows Media Encoder includes two device plug-ins, one to capture streams from audio devices, and another to capture streams from video devices. Device plug-ins support resources that identify the string names of the capture devices. To completely specify a device plug-in, you must provide both the scheme type and the resource name in a "DEVICE://resource name" format.

Device plug-ins support a property page that enables configuration of the plug-in by end-users. To learn how to create a dialog box and display a property page, see the Plug-in Property Pages section.

The following example code illustrates how to configure the encoder engine to use a device plug-in.

' Declare objects and variables.
Dim Encoder As WMEncoder
Dim PluginIndex As Integer
Dim ResourceIndex As Integer
Dim Scheme As String
Dim Resource As String
Dim SrcPlugMgr As IWMEncSourcePluginInfoManager
Dim PlugInfo As IWMEncPluginInfo

' Create a WMEncoder object and retrieve an
' IWMEncSourcePluginInfoManager from it.
Set Encoder = New WMEncoder
Set SrcPlugMgr = Encoder.SourcePluginInfoManager

' Loop through the source plug-ins. Call the Item method on each
' plug-in to retrieve an IWMEncPluginInfo object. Use the
' SchemeType property to retrieve a string containing the scheme
' type of the plug-in. If the scheme type is "DEVICE" and if the
' plug-in supports resources, call the Item method to retrieve a
' string identifying the resource.
' To capture streams from an attached device, you must choose a
' specific device plug-in.
For PluginIndex = 0 To SrcPlugMgr.Count - 1
    Set PlugInfo = SrcPlugMgr.Item(PluginIndex)
    Scheme = PlugInfo.SchemeType
    If Scheme = "DEVICE" Then
        If PlugInfo.Resources = True Then
            For ResourceIndex = 0 To PlugInfo.Count - 1
                Resource = PlugInfo.Item(ResourceIndex)
            Next
        End If
    End If
Next

' Choose one of the device plug-ins identified in the preceeding
' step. For example, you can choose "DEVICE://Default_Video_Device"
' if there is a video capture card attached to your computer.
' Declare a source group object and a source group collection object.
' Get the source group collection object from the encoder object.
Dim SrcGrpColl As IWMEncSourceGroupCollection
Dim SrcGrp As IWMEncSourceGroup
Set SrcGrpColl = Encoder.SourceGroupCollection

' Add an emtpy source group to the source group collection.
Set SrcGrp = SrcGrpColl.Add("SG_1")

' Add video and audio streams to the new source group.
Dim SrcAud As IWMEncSource
Dim SrcVid As IWMEncSource
Set SrcVid = SrcGrp.AddSource(WMENC_VIDEO)
Set SrcAud = SrcGrp.AddSource(WMENC_AUDIO)

' Specify the plug-in to use for capturing streams from the
' video card.
SrcVid.SetInput "DEVICE://Default_Video_Device"
SrcAud.SetInput "DEVICE://Default_Audio_Device"

See Also

  • IWMEncPluginInfo Interface
  • IWMEncPluginInfo Object
  • IWMEncSource Interface
  • IWMEncSource Object
  • IWMEncSourceGroup Interface
  • IWMEncSourceGroup Object
  • IWMEncSourceGroupCollection Interface
  • IWMEncSourceGroupCollection Object
  • IWMEncSourcePluginInfoManager Interface
  • IWMEncSourcePluginInfoManager Object
  • Plug-ins


File Plug-in

Multiple file plug-ins are included with Windows Media Encoder, one plug-in for each type of file (.wav, .mp3, .wma, .avi, .mpg, .wmv, .asf, .bmp) that can be encoded. Windows Media Encoder automatically chooses the correct plug-in for a specific file. Therefore, including the FILE scheme type is optional. You can specify only the full path and name of the file.

' Create a WMEncoder object.
Dim Encoder As WMEncoder
Set Encoder = New WMEncoder

' Declare objects and variables.
Dim SrcGrpColl As IWMEncSourceGroupCollection
Dim SrcGrp As IWMEncSourceGroup
Dim AudSrc As IWMEncSource
Dim VidSrc As IWMEncVideoSource
Dim ProColl As IWMEncProfileCollection
Dim Pro As IWMEncProfile
Dim File As IWMEncFile
Dim i As Integer

' Create an IWMEncSourceGroupCollection object.
Set SrcGrpColl = Encoder.SourceGroupCollection

' Create an IWMEncSourceGroup object.
Set SrcGrp = SrcGrpColl.Add("SG_1")

' Create a video and an audio source object.
Set AudSrc = SrcGrp.AddSource(WMENC_AUDIO)
Set VidSrc = SrcGrp.AddSource(WMENC_VIDEO)

' Specify the File plugin and the path of the
' source file.
AudSrc.SetInput "FILE://filename.avi"
VidSrc.SetInput "FILE://filename.avi"

' Create an IWMEncFile object.
Set File = Encoder.File

' Specify the output Windows Media file.
File.LocalFileName = "filename.wmv"

' Loop through the collection of system profiles to set
' a specific profile into the source group object.
Set ProColl = Encoder.ProfileCollection
For i = 0 To ProColl.Count - 1
    Set Pro = ProColl.Item(i)
    If Pro.Name = "profile name" Then
        SrcGrp.Profile = Pro
        Exit For
    End If
Next

' Tell the encoder to start archiving when the encoder
' engine starts running.
Encoder.EnableAutoArchive = True

' Initialize the encoder engine.
Encoder.PrepareToEncode True

See Also

  • IWMEncSource Interface
  • IWMEncSource Object
  • IWMEncSourceGroup Interface
  • IWMEncSourceGroup Object
  • IWMEncSourceGroupCollection Interface
  • IWMEncSourceGroupCollection Object
  • Plug-ins


Screen Capture Plug-in

This plug-in enables capture of all or part of the screen. It supports a property page that enables configuration of the capture process by end-users. To learn how to create a dialog box and display a property page, see the Plug-in Property Pages section. The following example illustrates how to configure the encoder engine for screen capture. It is recommended that you use a profile that supports screen capture. In the current release of the Windows Media Encoder SDK, you can use the following profiles:

  • Screen capture (live) for dial-up modems (28.8 Kbps)
  • Screen capture for dial-up modems (28.8 Kbps)
  • Screen capture for e-mail and dual-ISDN (128 Kbps)
' Create a WMEncoder object.
Set Encoder = New WMEncoder

' Declare a source group object and a source group collection object.
' Get the source group collection object from the encoder object.
Dim SrcGrpColl As IWMEncSourceGroupCollection
Dim SrcGrp As IWMEncSourceGroup
Set SrcGrpColl = Encoder.SourceGroupCollection

' Add an emtpy source group to the source group collection.
Set SrcGrp = SrcGrpColl.Add("SG_1")

' Add audio (mandatory) and video sources to the new source group.
Dim SrcVid As IWMEncSource
Dim SrcAud As IWMEncSource
Set SrcVid = SrcGrp.AddSource(WMENC_VIDEO)
Set SrcAud = SrcGrp.AddSource(WMENC_AUDIO)

' Specify the screen capture plug-in. This sets up the video source.
SrcVid.SetInput "ScreenCap://ScreenCapture1"

' You must also specify an audio source.
SrcAud.SetInput "DEVICE://Default_Audio_Device"

' Select a profile for the source. It is recommended that you use
' one of the following screen capture profiles.
'    "Screen capture (live) for dial-up modems (28.8 Kbps)"
'    "Screen capture for dial-up modems (28.8 Kbps)"
'    "Screen capture for e-mail and dual-ISDN (128 Kbps)"

Dim ProColl As IWMEncProfileCollection
Dim Pro As IWMEncProfile

Set ProColl = Encoder.ProfileCollection
For i = 0 To ProColl.Count - 1
    Set Pro = ProColl.Item(i)
    If Pro.Name = "Screen capture (live) for dial-up modems (28.8 Kbps)" Then
        SrcGrp.Profile = Pro
        Exit For
    End If
Next

' Initialize the encoder engine.
Encoder.PrepareToEncode (True)

See Also

  • Plug-ins
  • Plug-in Property Pages


Script Plug-in

To broadcast script, you must send a type/data string pair to the encoder. Windows Media Player automatically processes predefined command types, the most common of which are the TEXT and URL types. When Windows Media Player receives the TEXT type, it interprets the data string as captioned text and displays it in the caption window. When Windows Media Player receives a URL type, it interprets the data string as a URL and opens the URL in a browser.

Windows Media Encoder does not include a profile enabled for script. However, you can use either the Windows Media Format SDK or Profile Manager to create a suitable custom profile.

The following example illustrates how you can use the script plug-in to send a script command to the encoder engine.

' Create a WMEncoder object
Dim Encoder As WMEncoder
Set Encoder = New WMEncoder

' Declare a source group object and a source group collection object.
' Get the source group collection object from the encoder object.
Dim SrcGrpColl As IWMEncSourceGroupCollection
Dim SrcGrp As IWMEncSourceGroup
Set SrcGrpColl = Encoder.SourceGroupCollection

' Add an emtpy source group to the source group collection.
Set SrcGrp = SrcGrpColl.Add("SG_1")

' Add video, audio, and script streams to the new source group.
Dim SrcAud As IWMEncSource
Dim SrcVid As IWMEncSource
Dim SrcScript As IWMEncSource
Set SrcVid = SrcGrp.AddSource(WMENC_VIDEO)
Set SrcAud = SrcGrp.AddSource(WMENC_AUDIO)
Set SrcScript = SrcGrp.AddSource(WMENC_SCRIPT)

' Specify the plug-in to use for capturing audio and video
' streams from the capture card.
SrcVid.SetInput "DEVICE://Default_Video_Device"
SrcAud.SetInput "DEVICE://Default_Audio_Device"

' Specify the script plug-in.
SrcScript.SetInput "UserScript://"

' Select a profile for the source group. The profile must be
' enabled for script streams. You can use either the Windows
' Media Format SDK or Profile Manager to create the
' profile. Because this is a custom profile, you can
' associate it with a source group by specifying the path and
' name.
SrcGrp.Profile = "C:\Program Files\Windows Media Components\ _
Encoder\Profiles\profile_name.prx"

' Initialize and start the encoder
Encoder.PrepareToEncode
Encoder.Start

' Broadcast a text string. This appears in the Windows
' Media Player caption window.
Encoder.SendScript 0, "TEXT", "This is a test"

See Also

  • IWMEncBroadcast Interface
  • IWMEncBroadcast Object
  • IWMEncoder Interface
  • IWMEncSource Interface
  • IWMEncSource Object
  • IWMEncSourceGroup Interface
  • IWMEncSourceGroup Object
  • IWMEncSourceGroupCollection Interface
  • IWMEncSourceGroupCollection Object
  • Plug-ins
  • WMEncoder Object


Time Compression Plug-in

You can use this plug-in to accelerate a video stream without distorting the accompanying audio stream. By default, the plug-in provides no compression. Therefore, you must display the predefined property page so that end-users can configure the plug-in. To learn how to create a dialog box and display a property page, see the Plug-in Property Pages section. The following example illustrates how to configure the encoder engine for time compression.

' Create a WMEncoder object.
Set Encoder = New WMEncoder

' Declare a source group object and a source group collection object.
' Get the source group collection object from the encoder object.
Dim SrcGrpColl As IWMEncSourceGroupCollection
Dim SrcGrp As IWMEncSourceGroup
Set SrcGrpColl = Encoder.SourceGroupCollection

' Add an emtpy source group to the source group collection.
Set SrcGrp = SrcGrpColl.Add("SG_1")

' Add audio (mandatory) and video sources to the new source group.
Dim SrcVid As IWMEncSource
Dim SrcAud As IWMEncSource
Set SrcVid = SrcGrp.AddSource(WMENC_VIDEO)
Set SrcAud = SrcGrp.AddSource(WMENC_AUDIO)

' Specify the audio and video capture source
SrcVid.SetInput "DEVICE://Default_Video_Device"
SrcAud.SetInput "DEVICE://Default_Audio_Device"

' Select a profile for the source.
Dim ProColl As IWMEncProfileCollection
Dim Pro As IWMEncProfile

Set ProColl = Encoder.ProfileCollection
For i = 0 To ProColl.Count - 1
    Set Pro = ProColl.Item(i)
    If Pro.Name = "profile_name" Then
        SrcGrp.Profile = Pro
        Exit For
    End If
Next

' Retrieve the transform collection from the source group.

Dim GrpTrnsColl As IWMEncTransformCollection
Set GrpTrnsColl = SrcGrp.GroupTransformCollection

' Add a transform plugin to the collection

Dim TCTrans As IWMEncTransform
Set TCTrans = GrpTrnsColl.Add

' Set the time compression plug-in into the source group.

TCTrans.SetInput "TCGroupTransformPlugin://TimeCompression1"

' To configure the time compression plug-in, you must enable the
' relevant property page and retrieve input from the end-user.
' The plug-in defaults to no compression.
' You must also create an IWMEncFile object and configure the
' archiving process.

See Also

  • Plug-ins


Batch Files and Windows Script Host

Windows Script Host (WSH) can execute scripts written in any language that conforms to the ActiveX scripting specification. You can use WSH to run scripts in the Windows operating system. The following topics describe WSH in more detail.

Topic | Description
Windows Script Host | Discusses what Windows Script Host is and how it can be used to run scripts in the Windows operating system.
Batch File Example Code | Provides a code example that automatically encodes multiple audio-visual files.

See Also

  • Programming Guide


Windows Script Host

Windows Script Host is a language-neutral host interface that works with any ActiveX scripting engine. The Visual Basic Scripting Edition and JScript scripting engines are provided by Microsoft. Other ActiveX scripting engines are available from third-party vendors.

Because scripting languages cannot be compiled, you need a host to read and interpret the script. Windows Script Host can perform this function for the Windows operating system. WSH includes objects that make it easy to access the Windows file system and environment. WSH is ideal for automating repetitive tasks, writing network logon scripts, and administering a Windows network. You can also use WSH to access COM objects.

You can use WSH by associating the file name extension for your script file with Wscript.exe so that when you double-click the script file name, WSH automatically runs it. You can also run scripts from the command line using Cscript.exe as shown in the following example:

    cscript c:\foldername\scriptname.extension

For more information about Windows Script Host, see the Windows Media Developer Center at the Microsoft Web site.

See Also

  • Batch Files and Windows Script Host


Batch File Code Example

The following example demonstrates how to automatically encode multiple audio-visual files, the names of which have been entered into a text file, one name for each line. You must create this file and provide a path to it in the following line:

Set PlaylistFile = fso.OpenTextFile("file_name",1,0)

You must also specify the name of a profile in the following code section:

For Each profile In profilecoll
    If profile.Name = "some_profile_name" Then
        srcgrp.Profile = profile
    End If

The example is written using VBScriptVisual Basic Scripting Edition. The file name extension is .vbs, and the file is associated, by default, with Wscript.exe. Therefore, you can double-click the file name to invoke WSH and run the script. You can also open an MS-DOS command window and run the script by using Cscript.exe.

Note When using members of enumeration types in a scripting language, you must use the numeric value of the member. These are available in the Programming Reference.

' Create a WMEncoder object.

Dim encoder
Set encoder = WScript.CreateObject("WMEncEng.WMEncoder")

' Add a new source group to the source group collection.
' For example, call the source group "SG_1".

Dim srcgrpcoll
Dim srcgrp
Set srcgrpcoll = encoder.SourceGroupCollection
Set srcgrp = srcgrpcoll.Add("SG_1")

' Add video and text streams to the source group.

Dim vidsrc
Dim audsrc
Set vidsrc = srcgrp.AddSource(2)
Set audsrc = srcgrp.AddSource(1)

' Choose a profile and add it to the source group.
' For example, choose the Video for general purpose (100 Kbps) profile.
' You must loop through the collection to find the profile.

Dim profilecoll
Dim profile
set profilecoll=encoder.ProfileCollection

For Each profile In profilecoll
    If profile.Name = "profile_name" Then
        srcgrp.Profile = profile
    End If

next

' Make the source group active.

srcgrpcoll.Active = srcgrp

' Retrieve a file containing a list of string names of
' audio-visual files. Supply the path to the file.
' FileSystemObject is from the VBScript runtime
' object library.

Dim fso
Dim PlaylistFile
Set fso = WScript.CreateObject("Scripting.FileSystemObject")
Set PlaylistFile = fso.OpenTextFile("file_name",1,0)

' Create a file object to store the encoded content.

Dim outputfile
Set outputfile = encoder.file

' Loop through the playlist and encode each audio-visual file.

Dim AVFile
Do While PlaylistFile.AtEndOfStream<> True

    ' Read the name of each audio-visual file from the playlist file.

    AVFile = PlaylistFile.readline

    ' Specify the name of the output file in which to store
    ' encoded content.

    outputfile.LocalFileName = AVFile & ".wmv"

    ' Identify the file to Windows Media Encoder.

    audsrc.SetInput(AVFile)
    vidsrc.SetInput(AVFile)

    ' Start Windows Media Encoder. It automatically stops at the end
    ' of each audio-visual file.

    encoder.Start

    ' You must wait for the encoder engine to stop.
Loop

See Also

  • Batch Files and Windows Script Host


Remote Administration

An administrator can control multiple instances of Windows Media Encoder running on a remote computer on either a local area network (LAN) or the Internet. By using the IWMEncAgentLocator, IWMEncoderAgent and IWMEncoderNamesCollection interfaces, you can write applications that enable an administrator to:

  • Create WMEncoderApp objects on remote computers.
  • Enumerate the WMEncoder objects running on a specific computer.
  • Connect to and control a specific WMEncoder object.
  • Monitor the status of the encoding process.

The following topics describe remote administration in more detail.

Topic | Description
Creating an Encoder Agent on a Remote Computer | Discusses the role of the encoder agent in remote administration of Windows Media Encoder. The encoder agent creates instances of Windows Media Encoder on remote computers.
Specifying Registry Security Settings | Discusses how to configure the registry so that clients can create remote instances of Windows Media Encoder.
Displaying the User Interface on a Remote Computer | Discusses how to display the predefined Windows Media Encoder user interface on a remote computer.

See Also

  • Programming Guide
  • Remote Administration Interfaes (C++)
  • Remote Administration Interfaces (Visual Basic)


Creating an Encoder Agent on a Remote Computer

To enable remote administration of Windows Media Encoder, you must create a WMEncoderAgent object on the remote computer and use it to create one or more instances of Windows Media Encoder. The WMEncoderAgent object passes the string names of the running WMEncoder objects to the IWMEncoderNamesCollection object. You can use these names to retrieve pointers to specific encoder engines. You can use the pointers to programmatically control Windows Media Encoder on the remote computer.

Note Windows Media Encoder must be installed on the remote computer. Also, you must use the DCOMCnfg utility to set the access, launch, and configuration permissions, and identify the users who can administer Windows Media Encoder. For more information, see Specifying Registry Security Settings.

VBScript Example

' If you use a scripting language you must create a
' WMEncoderAgentLocator object, and use it to create a
' WMEncoderAgent object on the remote computer

' Declare objects.
Dim AgentLocator
Dim EncoderAgent

' Create a WMEncAgentLocator object.
Set AgentLocator = CreateObject("WMEncLoc.WNEncAgentLocator")

' Create a WMEncoderAgent object on a remote computer.
Set EncoderAgent = AgentLocator.GetAgent("computer name")

Visual Basic Example

' Declare objects and variables.
Dim Encoder As WMEncoder
Dim EncoderApp As WMEncoderApp
Dim EncoderAgent As WMEncoderAgent
Dim EncoderNames As IWMEncoderNamesCollection

' Create a WMEncoderAgent object on a remote computer.
Set EncoderAgent = CreateObject("WMEncAgt.WMEncoderAgent",
                        "computer name")

C++ Example

#ifndef _WIN32_WINNT
#define _WIN32_WINNT 0x0400
#endif

// Include libraries.

#include <windows.h>
#include <atlbase.h>
#include <objbase.h>
#include "wmencode.h"
#include "localagent.h"

// Declare variables.

    HRESULT hr;
    IWMEncoderAgent* pAgent = NULL;

// Create a COSERVERINFO structure containing information
// about the computer on which to create the IWMEncoderAgent
// object.

    COSERVERINFO cs;
    ZeroMemory(&cs,sizeof(cs));
    cs.pwszName = L"name of remote computer";
    cs.pAuthInfo = NULL;

// Create a MULTI_QI structure to hold an IUnknown pointer
// to a IWMEncoderAgent object.

    MULTI_QI mqi;
    ZeroMemory(&mqi,sizeof(mqi));
    mqi.pIID = &IID_IWMEncoderAgent;
    mqi.pItf = pAgent;
    mqi.hr = 0;

// Initialize the COM library and retrieve a pointer
// to an IWMEncoderAgent interface on the remote computer.

    hr = CoInitialize(NULL);
    hr = CoCreateInstanceEx(CLSID_WMEncoderAgent,
                            NULL,
                            CLSCTX_SERVER,
                            &cs,
                            1,
                            &mqi);

    hr = mqi.pItf->QueryInterface(IID_IWMEncoderAgent,
                                  (void**) &pAgent);

See Also

  • IWMEncoder Interface
  • IWMEncoderAgent Interface
  • IWMEncoderNamesCollection Interface
  • Remote Administration
  • Specifying Registry Security Settings


Specifying Registry Security Settings

Windows Media Encoder and Windows Media Encoder Agent are contained in COM servers that can be run on the Microsoft® Windows® 95, Windows 98, Windows 2000, or Microsoft® Windows NT® operating systems. Because these objects can be launched from a computer other than that on which they reside, you must use the DCOMCnfg utility to specify the security settings in the registry.

Setting Security for Windows 95 and Windows 98 Operating Systems

  1. Click Start, click Run, type DCOMCnfg, and click OK.
  2. In the Distributed COM Configuration Properties dialog box, click the Default Properties tab. Select the Enable Distributed COM on this computer check box.
  3. Click the Default Security tab, and select the Enable remote connection check box.
  4. Click the Applications tab. Select the Windows Media Encoder Agent application. Click Properties and click Use custom access permissions on the Security tab. Add the users you want to allow to administer Windows Media Encoder on this computer. Click OK, and then click OK again.
  5. Click the Applications tab. Select the Windows Media Encoder application. Click Properties and click Use custom access permissions on the Security tab. Add the users you want to allow to administer Windows Media Encoder on this computer. Click OK, and then click OK again.
  6. Click OK to quit the DCOMCnfg utility.

You can download the latest version of DCOM from the Microsoft COM downloads page at the Microsoft Web site.

Setting Security for Windows NT and Windows 2000 Operating Systems

You must use the DCOMCnfg utility to configure the registry so that Windows Media Encoder can be controlled from a remote computer.

  1. Click Start, click Run, type DCOMCnfg, and click OK.
  2. In the Distributed COM Configuration Properties dialog box, click the Applications tab.
  3. Click Windows Media Encoder Agent, and click Properties.
  4. Click the Security tab.
  5. Click Use custom access permissions, and then click Edit. Add the users you want to allow to administer the encoder engines on this computer. Click OK.
  6. Click Use custom launch permissions, and then click Edit. Add the users you want to allow to administer the encoder engines on this computer. Click OK.
  7. Click Use custom configuration permissions, and then click Edit. Add the users you want to allow to administer the encoder engines on this computer. Click OK.
  8. Click the Identity tab. Click This user, and then type the name and password of the user account that you want to use for encoder administration. Click OK.
  9. Click the Applications tab, click Windows Media Encoder, and then click Properties.
  10. Repeat steps 4 through 8, and then click OK.

See Also

  • IWMEncoder Interface
  • IWMEncoderAgent Interface
  • IWMEncAgentLocator Interface
  • Remote Administration


Displaying the User Interface on a Remote Computer

When an end user logs onto a computer running either the Windows NT or Windows 2000 operating system, an object called a WinStation is created to hold the desktop. The end user is called the interactive user, and only the WinStation desktop of the interactive user is visible. Therefore, to display the predefined user interface on the remote computer, you must use the DCOMCnfg utility to specify that the Windows Media Encoder COM server runs as the interactive user.

  1. Click Start, click Run, type DCOMCnfg, and click OK.
  2. In the Distributed COM Configuration Properties dialog box, click the Applications tab.
  3. Click Windows Media Encoder, and click properties.
  4. Click the Identity tab.
  5. Click The interactive user. Click OK.
  6. Click OK to quit the DCOMCnfg utility.

See Also

  • Remote Administration


Code Examples

The following examples describe in detail how to programmatically configure and run Windows Media Encoder.

Topic | Description
Creating Windows Media Encoder | Describes how to create Windows Media Encoder with or without the predefined user interface.
Working with Source Groups | Describes how to retrieve the source group collection, create a new source group and add it to the collection.
Working with Profiles | Describes how to retrieve a profile from the profile collection.
Running Profile Manager | Describes how to create Profile Manager to list and edit profiles.
Displaying Property Pages | Describes how to create a property page host and populate it with the predefined Session Properties property pages.
Configuring an Encoding Session | Describes how to set the data objects that configure an encoding session.
Capturing Multimedia Streams | Describes how to capture streams from both a file and a plug-in.
Broadcasting and Archiving Content | Describes how to broadcast encoded content to a server running Microsoft® Windows Media™ Services and simultaneously save the content to a local destination.
Cropping a Video Stream | Describes how to eliminate pixels from the edges of a video stream.
Previewing and Postviewing | Describes how to create a previews and postviews of streams.
Broadcasting Live Content | Describes how to create the Windows Media Encoder user interface, and how to programmatically configure, broadcast, and archive live multimedia content to a Windows Media server.
Administering Windows Media Encoder on a Remote Computer | Describes how to administer Windows Media Encoder on a remote computer.

See Also

  • Programming Guide


Creating Windows Media Encoder

To operate the encoder engine, you must use the WMEncoder object. If you are displaying the predefined Windows Media Encoder UI, you must acquire the WMEncoder object through the WMEncoderApp object. If you are not implementing a UI or are implementing a custom UI, you can directly create an instance of a WMEncoder object. The WMEncoderApp object must have module scope to exist outside of a procedure.

To determine the header files and type libraries needed for the following tasks, see Include Files and Type Libraries.

Visual Basic Example

Creating a WMEncoder Object Without the UI

' Create a WMEncoder object.
Dim encoder As WMEncoder
Set encoder = New WMEncoder

Creating a WMEncoder Object and Displaying the UI

' Create a WMEncoderApp object.
Dim encoder As WMEncoder
Dim encoderapp As WMEncoderApp
Set encoderapp = New WMEncoderApp

' Make the UI visible.
encoderapp.Visible = True

' Get a WMEncoder object from the WMEncoderApp object.
Set encoder = encoderapp.Encoder

C++ Example

Creating a WMEncoder Object Without the UI

// Include libraries.

#include <windows.h>
#include "wmencode.h"

// Declare variables.

    HRESULT hr;
    IWMEncoder* pEncoder;

// Initialize the COM library and retrieve a pointer
// to an IWMEncoder interface.

    hr = CoInitialize(NULL);
    hr = CoCreateInstance( CLSID_WMEncoder,
                           NULL,
                           CLSCTX_INPROC_SERVER,
                           IID_IWMEncoder,
                           (void**) (&pEncoder));

Creating a WMEncoder Object and Displaying the UI

// Include libraries.

#include <windows.h>
#include "wmencode.h"

// Declare variables.

    HRESULT hr;
    IWMEncoder* pEncoder;
    IWMEncoderApp* pEncoderApp;

// Initialize the COM library and retrieve a pointer
// to an IWMEncoderApp interface.

    hr = CoInitialize(NULL);
    hr = CoCreateInstance( CLSID_WMEncoderApp,
                           NULL,
                           CLSCTX_LOCAL_SERVER,
                           IID_IWMEncoderApp,
                           (void**) (&pEncoderApp));

// Display the user interface.

    hr = pEncoderApp->put_Visible(VARIANT_TRUE);

// Acquire an IWMEncoder interface.

    hr = pEncoderApp->get_Encoder(&pEncoder);

See Also

  • Code Examples
  • Include Files and Type Libraries
  • IWMEncoder Interface
  • IWMEncoder Object
  • IWMEncoderApp Interface
  • IWMEncoderApp Object


Working with Source Groups

Multimedia input streams are passed to Windows Media Encoder in source groups. A source group is a synchronized collection containing any combination of up to one audio, one script and one video stream. Only one source group can be active at a time, but you can switch between active source groups by using the IWMEncSourceGroupCollection::put_Active method. Use the IWMEncSourceGroup interface to manage an individual source group and the IWMEncSourceGroupCollection interface to manage the source group collection.

You can refer to the Include Files and Type Libraries section to determine the header files and type libraries needed for the following.

Visual Basic Example

' Create a Windows Media Encoder object.
Dim encoder As WMEncoder
Set encoder = New WMEncoder

' Declare a source group object and a source group collection object.
Dim srcgrpcoll As IWMEncSourceGroupCollection
Dim srcgrp1 As IWMEncSourceGroup

' Get the source group collection object from the encoder object.
Set sgcoll = encoder.SourceGroupCollection

' Create a source group, for example "SG_1".
srcgpr1 = sgcoll.Add("SG_1")

' Or, if you already have a collection containing multiple source
' groups and want to find a specific source group, such as "SG_1",
' enter the following code:
' Dim Count As Long
' Dim I As Integer
'
' Set srcgrpcoll = encoder.SourceGroupCollection.
' Count = srcgrpcoll.Count
' For I = 0 To Count - 1
'     Set srcgrp1 = srcgrpcoll.Item(I)
'     If srcgrp1.Name = "SG_1" Then
'         ' Do something with the source group.
'         Exit For
'     End If
' Next

' Create an IWMEncSource object for each type of multimedia content
' in the source group.
Dim srcaud1 As IWMEncSource
Dim srcvid1 As IWMEncSource
Dim srctxt1 As IWMEncSource

Set srcaud1 = srcgrp1.Source(WMENC_AUDIO, 0)
Set srcvid1 = srcgrp1.Source(WMENC_VIDEO, 0)
Set srctxt1 = srcgrp1.Source(WMENC_SCRIPT, 0)

' Add a new source group, by name, to the collection.
Dim srcgrp2 As IWMEncSourceGroup
srcgrp2 = srcgrpcoll.Add("SG_2")

' Add source streams to the source group.
Dim srcaud2 As IWMEncSource
Dim srcvid2 As IWMEncSource

Set srcaud2 = srcgrp2.AddSource(WMENC_AUDIO)
Set srcvid2 = srcgrp2.AddSource(WMENC_VIDEO)

C++ Example

// Include libraries.

#include <windows.h>
#include <atlbase.h>        // Includes CComBSTR and CComVariant.
#include "wmencode.h"

// Declare variables.

    HRESULT hr;
    IWMEncoder* pEncoder;
    IWMEncSourceGroupCollection* pSrcGrpColl;
    IWMEncSourceGroup* pSrcGrp1;
    IWMEncSource* pSrcAud1;
    IWMEncSource* pSrcVid1;
    IWMEncSource* pSrcTxt1;
    IWMEncSource* pSrcAud2;
    IWMEncSource* pSrcVid2;
    long lCount;
    short i;

// Initialize the COM library and retrieve a pointer
// to an IWMEncoder interface.

    hr = CoInitialize(NULL);
    hr = CoCreateInstance( CLSID_WMEncoder,
                           NULL,
                           CLSCTX_INPROC_SERVER,
                           IID_IWMEncoder,
                           (void**) (&pEncoder));

// Retrieve a pointer to an IWMEncSourceGroupCollection interface.

    hr=pEncoder->get_SourceGroupCollection(&pSrcGrpColl);

// Create a source group and add it to the collection.

    CComBSTR bstrName(L"SG_1");
    hr = pSrcGrpColl->Add(bstrName, &pSrcGrp1);

// Or, if you already have a collection containing multiple source
// groups and want to find a specific source group, such as "SG_1",
// enter the following code:
//
//    bstrName.Detach();
//    CComVariant varIndex;
//    varIndex.vt = VT_I2;
//    hr=pSrcGrpColl->get_Count(&lCount);
//    for (i=0; i<lCount; i++)
//    {
//        varIndex.iVal = i;
//        hr=pSrcGrpColl->Item(varIndex, &pSrcGrp1);
//        hr=pSrcGrp1->get_Name(&bstrName);
//        if (_wcsicmp(bstrName,L"SG_1")==0)
//        {
//            // Do something with the source group.
//        }
//    }

// Retrieve the audio, video, and script streams from the source group.

    hr=pSrcGrp1->get_Source(WMENC_AUDIO,0,&pSrcAud1);
    hr=pSrcGrp1->get_Source(WMENC_VIDEO,0,&pSrcVid1);
    hr=pSrcGrp1->get_Source(WMENC_SCRIPT,0,&pSrcTxt1);

// Add a new source group, "SG_2", to the collection.

    IWMEncSourceGroup* pSrcGrp2;
    hr=pSrcGrpColl->Add(L"SG_2", &pSrcGrp2);

// Add source streams to the source group.

    hr=pSrcGrp2->AddSource(WMENC_AUDIO, &pSrcAud2);
    hr=pSrcGrp2->AddSource(WMENC_VIDEO, &pSrcVid2);

See Also

  • Capturing Multimedia Streams
  • Code Examples
  • Include Files and Type Libraries
  • IWMEncSourceGroup Interface
  • IWMEncSourceGroup Object
  • IWMEncSourceGroupCollection Interface
  • IWMEncSourceGroupCollection Object
  • IWMEncSourceGroupCollection.Active
  • IWMEncSourceGroupCollection.put_Active


Working with Profiles

Profiles describe both the content being encoded and the anticipated target audience. A profile includes the number and type of source streams, the codecs used for compression and the target bit rates of the encoded content. Only one profile can be associated with a source group at a time, and the profile must be the same for all source groups in the encoding session. Profiles can be programmatically created and edited by using the Windows Media Format SDK. End users can edit profiles by using Profile Manager. Profile Manager edit and list dialog boxes can be programmatically created using the IWMEncProfileManager interface in the Windows Media Encoder SDK.

You can refer to the Include Files and Type Libraries section to determine the header files and type libraries needed for the following.

Visual Basic Example

' Create a WMEncoder object.
Dim Encoder As WMEncoder
Set Encoder = New WMEncoder

' Declare objects and variables.
Dim ProColl As IWMEncProfileCollection
Dim Pro As IWMEncProfile
Dim i As Integer

' Loop through the collection of system profiles to
' retrieve a specific profile.

Set ProColl = Encoder.ProfileCollection
For i = 0 To ProColl.Count - 1
    Set Pro = ProColl.Item(i)
    If Pro.Name = "profile_name" Then
        ' Use the profile.
        Exit For
    End If
Next

C++ Example

// Include libraries.

#include <windows.h>
#include <atlbase.h>    // Includes CComBSTR and CComVariant.
#include "wmencode.h"

// Declare variables.

    HRESULT hr;
    IWMEncoder* pEncoder;
    IWMEncProfileCollection* pProColl;
    IWMEncProfile* pPro;
    long lCount;
    int i;

// Initialize the COM library and retrieve a pointer
// to an IWMEncoder interface.

    hr = CoInitialize(NULL);
    hr = CoCreateInstance(CLSID_WMEncoder,
                          NULL,
                          CLSCTX_INPROC_SERVER,
                          IID_IWMEncoder,
                          (void**) &pEncoder);

// Retrieve a pointer to an IWMEncProfileCollection interface.

    hr = pEncoder->get_ProfileCollection(&pProColl);

// Loop through the profile collection and retrieve a specific
// profile.

    varProfile.vt = VT_DISPATCH;
    hr = pProColl->get_Count(&lCount);
    for (i=0; i<lCount; i++)
    {
        CComBSTR bstrName(L"");
        CComVariant varProfile;
        hr = pProColl->Item(i, &pPro);
        hr = pPro->get_Name(&bstrName);
        if (_wcsicmp(bstrName, L"profile_name")==0)
        {
        // Do something with the profile.
        break;
        }
    }

See Also

  • Code Examples
  • Include Files and Type Libraries
  • IWMEncoder Interface
  • IWMEncoder Object
  • IWMEncProfile Interface
  • IWMEncProfile Object
  • IWMEncProfileCollection Interface
  • IWMEncProfileCollection Object
  • IWMencProfileManager Interface
  • IWMEncProfileManager Object
  • IWMEncSourceGroup Interface
  • IWMEncSourceGroup Object
  • Running Profile Manager


Running Profile Manager

Although you must use the Windows Media Format SDK to programmatically create and edit profiles, you can use the Windows Media Encoder SDK to create and display Profile Manager edit and list dialog boxes.

You can refer to the Include Files and Type Libraries section to determine the header files and type libraries needed for the following.

Visual Basic Example

' Create a WMEncProfileManager object.
Dim ProfileMgr As WMEncProfileManager
Set ProfileMgr = New WMEncProfileManager

Dim sLastProfile As String
Dim sProfileDirectory As String
Dim sDetailsString As String

' Display the dialog box that lists the profiles. Because you
' are calling WMEncProfileListEx() rather than WMEncProfileList()
' and have indicated that a new profile is audio only, if you
' open the New profile dialog box, only the audio check box
' will be selected.
ProfileMgr.WMEncProfileListEx WMENC_FILTER_AV, WMENC_FILTER_A, 0

' Display the New Profile dialog box. If you supply the name of an
' existing profile, the new profile will be a copy of that.
ProfileMgr.WMEncProfileEdit "profile_name", WMENC_FILTER_AV, 0

' Retrieve a string containing the details of a specific profile.
sDetailsString = ProfileMgr.GetDetailsString("profile_name", 0)

' Retrieve the name of the last profile created during the current
' encoding session.
sLastProfile = ProfileMgr.LastCreatedProfile

' Retrieve a string containing the path of the directory in which
' custom profiles are stored.
sProfileDirectory = ProfileMgr.ProfileDirectory

C++ Example

// Include libraries.

#include <windows.h>
#include <atlbase.h>    // Includes CComBSTR.
#include "wmencode.h"

// Declare variables.

    HRESULT hr;
    IWMEncProfileManager* pProfileMgr;

// Initialize the COM library and retrieve a pointer
// to an IWMEncProfileManager interface.

    hr = CoInitialize(NULL);
    hr = CoCreateInstance(CLSID_WMEncProfileManager,
                          NULL,
                          CLSCTX_INPROC_SERVER,
                          IID_IWMEncProfileManager,
                          (void**) &pProfileMgr);

    CComBSTR bstrLastProfile(L"");
    CComBSTR bstrProfileDirectory(L"");
    CComBSTR bstrDetailsString(L"");
    CComBSTR bstrProfileName(L"profile_name)");

// Display the dialog box that lists the profiles. Because
// you are calling WMEncProfileListEx() rather than WMEncProfileList()
// and have indicated that a new profile is audio only, if you open
// the New profile dialog box, only the audio check box will be selected.

    hr = pProfileMgr->WMEncProfileListEx(WMENC_FILTER_AV,
                                         WMENC_FILTER_A,
                                         0);

// Display the New Profile dialog box. If you supply the name of an
//  existing profile, the new profile will be a copy of that.

    hr = pProfileMgr->WMEncProfileEdit(bstrProfileName,
                                       WMENC_FILTER_AV,
                                       0);

// Retrieve a string containing the details of a specific profile.

    hr = pProfileMgr->GetDetailsString(bstrProfileName,
                                       0,
                                       &bstrDetailsString);

// Retrieve the name of the last profile created by the end user
// during the current encoding session.

    hr = pProfileMgr->get_LastCreatedProfile(&bstrLastProfile);

// Retrieve a string containing the path of the directory in which
// custom profiles are stored.

    hr = pProfileMgr->get_ProfileDirectory(&bstrProfileDirectory);

See Also

  • Code Examples
  • Include Files and Type Libraries
  • IWMEncProfile Manager Interface
  • IWMEncProfileManager Object


Displaying Property Pages

The Windows Media Encoder SDK provides the predefined property pages used in the Session Properties dialog box and on the Monitor panel of the main user interface. You can use any of these or write your own. The property pages must be hosted by an MSPropshell ActiveX control.

You can refer to the Include Files and Type Libraries section to determine the header files and type libraries needed for the following.

Visual Basic Example

' Create a WMEncoder object.
Dim Encoder as New WMEncoder
Set Encoder = New WMEncoder

' Create the encoder property pages.
Dim PpgSources As New WMEncSourcesPage
Dim PpgDesc As New WMEncDisplayInfoPage
Dim PpgAttr As New WMEncAttributesPage
Dim PpgProf As New WMEncProfilePage
Dim PpgOut As New WMEncOutputPage

' Add Windows Media Encoder to the property page shell.
' You must add the encoder before adding the property pages.
PropPageShell.AddObject Encoder

' Add the property pages to the property page shell. To create an
' MSPropShell ActiveX control, select Components on the Project
' menu and Microsot PropShell Control 1.0 from the Components
' dialog box. In the following, the ActiveX control has been named
' PropPageShell.

PropPageShell.AddPage PpgSources
PropPageShell.AddPage PpgDesc
PropPageShell.AddPage PpgAttr
PropPageShell.AddPage PpgProf
PropPageShell.AddPage PpgOut

C++ Example

// Include libraries.

#include <windows.h>
#include "mspropshell.h"
#include "wmencode.h"

// Declare variables.

    HRESULT hr;
    IWMEncoder* pEncoder;
    IUnknown* pPpgSources;
    IMSPropShell* pMSPShell;

// Initialize the COM library and retrieve a pointer
// to an IWMEncoder interface.

    hr = CoInitialize(NULL);
    hr = CoCreateInstance(CLSID_WMEncoder,
                          NULL,
                          CLSCTX_INPROC_SERVER,
                          IID_IWMEncoder,
                          (void**) &pEncoder);

// Create a property page.

    hr = CoCreateInstance( CLSID_WMEncSourcesPage,
                           NULL,
                           CLSCTX_INPROC_SERVER,
                           IID_IUnknown,
                           (void**) (&pPpgSources));

// Create the property page shell.

    hr = CoCreateInstance(CLSID_MSPropShell,
                          NULL,
                          CLSCTX_INPROC_SERVER,
                          IID_IMSPropShell,
                          (void**) (&pMSPShell));

// Add Windows Media Encoder to the property page shell.

    hr = pMSPShell->AddObject((IUnknown*)pEncoder);

// Add the property page(s) to the property page shell.

    hr = pMSPShell->AddPage(pPpgSources);

See Also

  • Code Examples
  • Include Files and Type Libraries
  • IMSPropShell Interface
  • IWMEncoder Interface
  • IWMEncoder Object


Configuring an Encoding Session

To fully configure an encoding session programmatically, the following interfaces must be set correctly. Optional interfaces are noted:

  • The IWMEncAttributes interface (optional).
  • The IWMEncBroadcast interface (optional).
  • The IWMEncDisplayInfo interface (optional).
  • The IWMEncFile interface (optional).
  • The IWMEncProfile interface.
  • The IWMEncSource interface.
  • The IWMEncVideoSource interface [optional].

Either the IWMEncBroadcast interface or the IWMEncFile interface or both must be used to specify the destination of the encoded content.

You can refer to the Include Files and Type Libraries section to determine the header files and type libraries needed for the following.

Visual Basic Example

' Create a WMEncoder object.
Dim Encoder As WMEncoder
Set Encoder = New WMEncoder

' Specify the source for the input stream.
Dim SrcgrpColl As IWMEncSourceGroupCollection
Dim SrcGrp As IWMEncSourceGroup
Dim SrcVid As IWMEncVideoSource
Dim SrcAud As IWMEncSource

' Add a source group to the collection.
Set SrcgrpColl = Encoder.SourceGroupCollection
Set SrcGrp = SrcgrpColl.Add("SG_1")

' Add a video and audio source to the source group.
Set SrcVid = SrcGrp.AddSource(WMENC_VIDEO)
Set SrcAud = SrcGrp.AddSource(WMENC_AUDIO)

' Identify the capture cards that will produce the content.
SrcVid.SetInput "device://video capture card name"
SrcAud.SetInput "device://audio capture card name"

' Choose a profile from the collection.
Dim ProColl As IWMEncProfileCollection
Dim Pro As IWMEncProfile
Dim i As Integer
Dim Length As Long

Set ProColl = Encoder.ProfileCollection
Length = ProColl.Count

For i = 0 To Length - 1
    Set Pro = ProColl.Item(i)
    If Pro.Name = "profile_name" Then
        SrcGrp.Profile = Pro
        Exit For
    End If
Next

' Fill in the description object members.
Dim descr As IWMEncDisplayInfo
Set descr = Encoder.DisplayInfo
descr.Author = "Author name"
descr.Copyright = "Copyright information"
descr.Description = "Text description of encoded content"
descr.Rating = "Rating information"
descr.Title = "Title of encoded content"

' Add an attribute to the collection.
Dim Attr As IWMEncAttributes
Set Attr = Encoder.Attributes
Attr.Add "URL", "IP address"

' Create a broadcast object to specify a port and a protocol.
Dim brdcst As IWMEncBroadcast
Set brdcst = enc.Broadcast
brdcst.PortNumber(WMENC_PROTOCOL_HTTP) = 2357

' Specify a file object in which to save encoded content.
' Archiving defaults to automatic operation.
Dim OutFile As IWMEncFile
Set OutFile = enc.File
OutFile.LocalFileName = "file name"

' Create an IWMEncVideoSource object to crop the video stream.
' Because SrcVid was declared as an IWMEncVideoSource
' object earlier, it can use the methods and properties of both the
' IWMEncVideoSource and IWMEncSource objects.

SrcVid.CroppingBottomMargin = 5
SrcVid.CroppingTopMargin = 5
SrcVid.CroppingLeftMargin = 3
SrcVid.CroppingRightMargin = 3

' Start the encoder engine

Encoder.Start

' Wait until the engoder engine stops before exiting the application.
' You can do this by using the _IWMEncoderEvents object to create an
' event sink.

C++ Example

// Include libraries.

#include <windows.h>
#include <atlbase.h>
#include "wmencode.h"

// Declare variables.

    HRESULT hr;
    IWMEncoder* pEncoder;
    IWMEncSourceGroupCollection* pSrcGrpColl;
    IWMEncSourceGroup* pSrcGrp;
    IWMEncSource* pAudSrc1;
    IWMEncSource* pSrc1;
    IWMEncVideoSource* pVidSrc1;
    IWMEncProfileCollection* pProColl;
    IWMEncProfile* pPro;
    IWMEncDisplayInfo* pDispInfo;
    IWMEncAttributes* pAttr;
    IWMEncBroadcast* pBrdcast;
    IWMEncFile* pFile;
    long lCount;
    short i;

// Initialize the COM library and retrieve a pointer
// to an IWMEncoder interface.

    hr = CoInitialize(NULL);
    hr = CoCreateInstance(CLSID_WMEncoder,
                          NULL,
                          CLSCTX_INPROC_SERVER,
                          IID_IWMEncoder,
                          (void**) &pEncoder);

// Retrieve a pointer to an IWMEncSourceGroupCollection
// interface.

    hr = pEncoder->get_SourceGroupCollection(&pSrcGrpColl);

// Add a source group to the collection.

    hr = pSrcGrpColl->Add(L"SG_1", &pSrcGrp);

// Add a video and audio source to the source group.

    hr = pSrcGrp->AddSource(WMENC_VIDEO, &pSrc1);
    hr = pSrcGrp->AddSource(WMENC_AUDIO, &pAudSrc1);

// Retrieve a pointer to an IWMEncVideoSource interface.

    hr = pSrc1->QueryInterface(IID_IWMEncVideoSource, (void**)&pVidSrc1);

// Identify the capture cards.

    hr = pVidSrc1->SetInput(L"device://video card name");
    hr = pAudSrc1->SetInput(L"device://audio card name");

// Choose a profile from the collection.

    CComBSTR bstrName = NULL;
    CComVariant varProfile;
    varProfile.vt = VT_DISPATCH;
    hr = pEncoder->get_ProfileCollection(&pProColl);
    hr = pProColl->get_Count(&lCount);
    for (i=0; i<lCount; i++)
    {
        hr = pProColl->Item(i, &pPro);
        hr = pPro->get_Name(&bstrName);
        if (_wcsicmp(bstrName,L"profile name")==0)
        {
            // Set the profile in the source group.
            varProfile.pdispVal = pPro;
            hr = pSrcGrp->put_Profile(varProfile);
            break;
        }
}

// Retrieve a pointer to an IWMEncDisplayInfo interface.

    hr = pEncoder->get_DisplayInfo(&pDispInfo);

// Describe the encoded content.

    CComBSTR bstrAuthor("Content Author's name.");
    CComBSTR bstrCopyright("Copyright 2000. All rights reserved.");
    CComBSTR bstrDescription("Description of the encoded content.");
    CComBSTR bstrRating("Content rating.");
    CComBSTR bstrTitle("Title of the encoded content.");

    hr = pDispInfo->put_Author(bstrAuthor);
    hr = pDispInfo->put_Copyright(bstrCopyright);
    hr = pDispInfo->put_Description(bstrDescription);
    hr = pDispInfo->put_Rating(bstrRating);
    hr = pDispInfo->put_Title(bstrTitle);

// Retrieve a pointer to an IWMEncAttributes interface.

    hr = pEncoder->get_Attributes(&pAttr);

// Add an attribute to the attributes collection.

    CComBSTR bstrAttrName(L"DateCreated: ");
    CComVariant varValue;
    varValue.vt = VT_BSTR;
    varValue.bstrVal = L"02/15/2000";
    hr = pAttr->Add(bstrAttrName,varValue);

// Retrieve a pointer to an IWMEncBroadcast interface.

    hr = pEncoder->get_Broadcast(&pBrdcast);

// Specify a port number and a protocol.

    hr = pBrdcast->put_PortNumber(WMENC_PROTOCOL_HTTP, 8080);

// Retrieve a pointer to an IWMEncFile interface.

    hr = pEncoder->get_File(&pFile);

// Specify a file in which to save encoded content.

    CComBSTR bstrFileName(L"file name");
    hr = pFile->put_LocalFileName(bstrFileName);

// Use the IWMEncVideoSource object to crop the video
// stream. Because pVidSrc1 was declared as an
// IWMEncVideoSource object earlier, it can use the methods of
// both the IWMEncVideoSource and IWMEncSource objects.

    hr = pVidSrc1->put_CroppingBottomMargin(5);
    hr = pVidSrc1->put_CroppingTopMargin(5);
    hr = pVidSrc1->put_CroppingLeftMargin(3);
    hr = pVidSrc1->put_CroppingRightMargin(3);

// Start the encoder enngine.

    hr = pEncoder->Start();

// Wait until the engoder engine stops before exiting the application.
// You can do this by using the _IWMEncoderEvents object to create an
// event sink.

See Also

  • _IWMEncoderEvents Interface
  • _IWMEncoderEvents Object
  • Code Examples
  • Include Files and Type Libraries
  • IWMEncAttributes Interface
  • IWMEncAttributes Object
  • IWMEncBroadcast Interface
  • IWMEncBroadcast Object
  • IWMEncDisplayInfo Interface
  • IWMEncDisplayInfo Object
  • IWMEncFile Interface
  • IWMEncFile Object
  • IWMEncoder Interface
  • IWMEncoder Object
  • IWMEncProfile Interface
  • IWMEncProfile Object
  • IWMEncSource Interface
  • IWMEncSource Object
  • IWMEncVideoSource Interface
  • IWMEncVideoSource Object


Capturing Multimedia Streams

A multimedia stream can be captured from either a file or a device. The following code example illustrates capture from a device. Before capturing multimedia content, you must fully configure the encoding session. For more information, see Working with Source Groups, Working with Profiles, and Configuring an Encoding Session.

You can refer to the Include Files and Type Libraries section to determine the minimum set of header files and type libraries needed for the following.

Visual Basic Example

' Create a WMEncoder object.
Dim Encoder As WMEncoder
Set Encoder = New WMEncoder

' Specify the source for the input stream.
Dim SrcGrpColl As IWMEncSourceGroupCollection
Dim SrcGrp As IWMEncSourceGroup
Dim SrcVid As IWMEncSource
Dim SrcAud As IWMEncSource

Set SrcGrpColl = Encoder.SourceGroupCollection
Set SrcGrp = SrcGrpColl.Add("SG_1")

' Add video, audio, and text streams to the source group.
Set SrcVid = SrcGrp.AddSource(WMENC_VIDEO)
Set SrcAud = SrcGrp.AddSource(WMENC_AUDIO)

' Assume that the audio and video streams are captured by an
' installed device. Identify the device by specifying a
' "device://device name" string.

SrcVid.SetInput "DEVICE://video capture card name"
SrcAud.SetInput "DEVICE://audio capture card name"

C++ Example

// Include libraries.

#include <windows.h>
#include "wmencode.h"

// Declare variables.

    HRESULT hr;
    IWMEncoder* pEncoder;
    IWMEncSourceGroupCollection* pSrcGrpColl;
    IWMEncSourceGroup* pSrcGrp;
    IWMEncSource* pVidSrc1;
    IWMEncSource* pAudSrc1;

// Initialize the COM library and retrieve a pointer
// to an IWMEncoder interface.

    hr = CoInitialize(NULL);
    hr = CoCreateInstance( CLSID_WMEncoder,
                           NULL,
                           CLSCTX_INPROC_SERVER,
                           IID_IWMEncoder,
                           (void**) &pEncoder);

// Retrieve a pointer to an IWMEncSourceGroupCollection
// interface.

    hr = pEncoder->get_SourceGroupCollection(&pSrcGrpColl);

// Add a source group to the collection.

    hr = pSrcGrpColl->Add(L"SG_1", &pSrcGrp);

// Add a video and audio source to the source group.

    hr=pSrcGrp->AddSource(WMENC_VIDEO, &pVidSrc1);
    hr=pSrcGrp->AddSource(WMENC_AUDIO, &pAudSrc1);

// Identify the capture cards.

    hr=pVidSrc1->SetInput(L"DEVICE://video card name");
    hr=pAudSrc1->SetInput(L"DEVICE://audio card name");

See Also

  • Code Examples
  • Creating Windows Media Encoder
  • Include Files and Type Libraries
  • IWMEncoder Interface
  • IWMEncoder Object
  • IWMEncSource Interface
  • IWMEncSource Object
  • IWMEncSourceGroup Interface
  • IWMEncSourceGroup Object
  • IWMEncSourceGroupCollection Interface
  • IWMEncSourceGroupCollection Object
  • Working with Profiles
  • Working with Source Groups


Broadcasting and Archiving Content

To broadcast encoded content, you must specify a protocol and a port number by using an IWMEncBroadcast interface. HTTP and port 80 work best for broadcasting through firewalls.

Archiving can be controlled either automatically or manually. Unless you set IWMEncoder.EnableAutoArchive to False, the archiving process starts automatically when the encoder engine starts. Use the IWMEncFile interface to create an output file on a local computer for the archived content.

Before archiving or broadcasting, you must fully configure the encoding session. For more information, see Working with Source Groups, Working with Profiles, and Configuring an Encoding Session. You can also load a predefined configuration.

You can refer to the Include Files and Type Libraries section to determine the header files and type libraries needed for the following.

Visual Basic Example

' Create a WMEncoder object.
Dim Encoder As WMEncoder
Set Encoder = New WMEncoder

' Specify a broadcast protocol and port number.
Dim Broadcast As IWMEncBroadcast
Set Broadcast = Encoder.Broadcast
Broadcast.PortNumber(WMENC_PROTOCOL_HTTP) = 2376

' Specify a file in which to save encoded content.
Dim OutFile As IWMEncFile
Set OutFile = Encoder.File
OutFile.LocalFileName = "C:\file name"

C++ Example

// Include libraries.

#include <windows.h>
#include "wmencode.h"

// Declare variables.

    HRESULT hr;
    IWMEncoder* pEncoder;
    IWMEncBroadcast* pBrdcast;
    IWMEncFile* pFile;

// Initialize the COM library and retrieve a pointer
// to an IWMEncoder interface.

    hr = CoCreateInstance( CLSID_WMEncoder,
                           NULL,
                           CLSCTX_INPROC_SERVER,
                           IID_IWMEncoder,
                           (void**)&pEncoder);

// Specify a broadcast protocol and port number.

    hr = pEncoder->get_Broadcast(&pBrdcast);
    hr = pBrdcast->put_PortNumber(WMENC_PROTOCOL_HTTP, 80);

// Specify a file in which to save encoded content.

    hr = pEncoder->get_File(&pFile);
    hr = pFile->put_LocalFileName(L"C:\file name");

See Also

  • Code Examples
  • Creating Windows Media Encoder
  • Include Files and Type Libraries
  • IWMEncBroadcast Interface
  • IWMEncBroadcast Object
  • IWMEncFile Interface
  • IWMEncFile Object
  • IWMEncoder Interface
  • IWMEncoder Object
  • Working with Profiles
  • Working with Source Groups


Trimming a Stream

Use the IWMEncSource interface to trim content from the start and end of a stream. The time unit is milliseconds.

Before trimming an input stream, you must fully configure the encoding session. For more information, see Working with Source Groups, Working with Profiles, and Configuring an Encoding Session. Alternatively, you can load a predefined configuration from a file.

You can refer to the Include Files and Type Libraries section to determine the header files and type libraries needed for the following.

Visual Basic Example

' Create a WMEncoder object.
Dim Encoder As WMEncoder
Set Encoder = New WMEncoder

' Specify the source input stream.
Dim SrcGrpColl As IWMEncSourceGroupCollection
Dim SrcGrp As IWMEncSourceGroup
Dim SrcVid As IWMEncSource
Dim SrcAud As IWMEncSource

' Add a source group to the collection.
Set SrcGrpColl = enc.SourceGroupCollection
Set SrcGrp = SrcGrpColl.Add("SG_1")

' Add video and audio streams to the source group.
Set SrcVid = SrcGrp.AddSource(WMENC_VIDEO)
Set SrcAud = SrcGrp.AddSource(WMENC_AUDIO)

' Specify a source file containing a video stream.
SrcVid.SetInput ("Name of the input file")
SrcAud.SetInput ("Name of the input file")

' Trim the video by specifying the start and end points
' of the stream, in milliseconds. In the following code, the
' start point is set to 25 seconds and the end point is
' set to 100 seconds. No content is encoded before
' the 25-second marker or after the 100-second marker.
SrcVid.MarkIn = 25000
SrcVid.MarkOut = 100000

C++ Example

// Include libraries.

#include <windows.h>
#include "wmencode.h"

// Declare variables.

    HRESULT hr;
    IWMEncoder* pEncoder;
    IWMEncSourceGroupCollection* pSrcGrpColl;
    IWMEncSourceGroup* pSrcGrp;
    IWMEncSource* pVidSrc;
    IWMEncSource* pAudSrc;

// Initialize the COM library and retrieve a pointer
// to an IWMEncoder interface.

    hr = CoInitialize(NULL);
    hr = CoCreateInstance(CLSID_WMEncoder,
                          NULL,
                          CLSCTX_INPROC_SERVER,
                          IID_IWMEncoder,
                          (void**) &pEncoder);

// Retrieve an IWMEncSourceGroupCollection pointer.

    hr = pEncoder->get_SourceGroupCollection(&pSrcGrpColl);

// Add a source group to the collection.

    hr=pSrcGrpColl->Add(L"SG_1", &pSrcGrp);

// Add audio and video streams to the source group.

    hr=pSrcGrp->AddSource(WMENC_VIDEO, &pVidSrc);
    hr=pSrcGrp->AddSource(WMENC_VIDEO, &pAudSrc);

// Specify a source file containing a video stream.

    hr=pVidSrc->SetInput(L"file name");
    hr=pAudSrc->SetInput(L"file name");

// Trim the video by specifying the start and end points
// of the stream, in milliseconds. In the following code, the
// start point is set to 25 seconds and the end point is
// set to 100 seconds. No content is encoded before
// the 25-second marker or after the 100-second marker.

    hr=pVidSrc->put_MarkIn(25000);
    hr=pVidSrc->put_MarkOut(100000);

See Also

  • Code Examples
  • Creating Windows Media Encoder
  • Include Files and Type Libraries
  • IWMEncoder Interface
  • IWMEncoder Object
  • IWMEncSource Interface
  • IWMEncSource Object
  • IWMEncSourceGroup Interface
  • IWMEncSourceGroup Object
  • IWMEncSourceGroupCollection Interface
  • IWMEncSourceGroupCollection Object
  • Working with Profiles
  • Working with Source Groups


Cropping a Video Stream

Use the IWMEncVideoSource interface to specify the number of pixels to crop from the edge of a video image. The IWMEncVideoSource interface is derived from the IWMEncSource interface.

Before cropping a video stream, you must fully configure the encoding session. For more information, see Working with Source Groups, Working with Profiles, and Configuring an Encoding Session.

You can refer to the Include Files and Type Libraries section to determine the header files and type libraries needed for the following.

Visual Basic Example

' Create a WMEncoder object.
Dim Encoder As WMEncoder
Set Encoder = New WMEncoder

' Specify the source for the input stream.
Dim SrcGrpColl As IWMEncSourceGroupCollection
Dim SrcGrp As IWMEncSourceGroup
Dim SrcVid As IWMEncVideoSource
Dim SrcAud As IWMEncSource

' Add a source group to the collection.
Set SrcGrpColl = Encoder.SourceGroupCollection
Set SrcGrp = SrcGrpColl.Add("SG_1")

' Add a video and audio source to the source group.
Set SrcVid = SrcGrp.AddSource(WMENC_VIDEO)
Set SrcAud = SrcGrp.AddSource(WMENC_AUDIO)

' Specify the cropping margins.
VidSrc.CroppingBottomMargin = 5
VidSrc.CroppingTopMargin = 5
VidSrc.CroppingLeftMargin = 3
VidSrc.CroppingRightMargin = 3

C++ Example

// Include libraries.

#include <windows.h>
#include "wmencode.h"

// Declare variables.

    HRESULT hr;
    IWMEncoder* pEncoder;
    IWMEncSourceGroupCollection* pSrcGrpColl;
    IWMEncSourceGroup* pSrcGrp;
    IWMEncSource* pAudSrc;
    IWMEncSource* pSrc;
    IWMEncVideoSource* pVidSrc;

// Initialize the COM library and retrieve a pointer
// to an IWMEncoder interface.

    hr = CoInitialize(NULL);
    hr = CoCreateInstance(CLSID_WMEncoder,
                          NULL,
                          CLSCTX_INPROC_SERVER,
                          IID_IWMEncoder,
                          (void**) &pEncoder);

// Retrieve an IWMEncSourceGroupCollection pointer.

    hr = pEncoder->get_SourceGroupCollection(&pSrcGrpColl);

// Add a source group to the collection.

    hr = pSrcGrpColl->Add(L"SG_1", &pSrcGrp);

// Add a video stream to the source group.

    hr = pSrcGrp->AddSource(WMENC_VIDEO, &pSrc);
    hr = pSrcGrp->AddSource(WMENC_AUDIO, &pAudSrc);

// Retrieve an IWMEncVideoSource pointer.

    hr = pSrc->QueryInterface(IID_IWMEncVideoSource, (void**)&pVidSrc);

// Specify the cropping margins.

    hr = pVidSrc->put_CroppingBottomMargin(5);
    hr = pVidSrc->put_CroppingTopMargin(5);
    hr = pVidSrc->put_CroppingLeftMargin(3);
    hr = pVidSrc->put_CroppingRightMargin(3);

See Also

  • Code Examples
  • Creating Windows Media Encoder
  • Include Files and Type Libraries
  • IWMEncSource Object
  • IWMEncSourceGroup Object
  • IWMEncSourceGroupCollection Object
  • IWMEncVideoSource Object
  • Working with Profiles
  • Working with Source Groups
  • WMEncoder Object


Previewing and Postviewing

The current version of Windows Media Encoder supplies an IWMEncDataView interface that can be used to render both previews and postviews in a window. A preview object displays a specific multimedia stream before it is compressed. A postview object displays the same stream after compression and decompression. Postviews, therefore, more closely resemble the image rendered in Windows Media Player on a client computer.

To render either a preview or a postview, you must retrieve a pointer to an IWMEncDataView interface, and retrieve either a preview or postview collection from the IWMEncSource interface. You must use the IWMEncDataViewCollection::Add method to add the IWMEncDataView interface to the collection, and use the returned cookie to render the stream in a pop-up window. If you set the cookie to –1 before calling the Add method, Windows Media Encoder automatically generates a cookie. A cookie is a long integer used to identify a specific preview object. The stream is not rendered until Windows Media Encoder starts running.

Because the IWMEncDataView interface does not support Automation, you must use C++ to enable previewing and postviewing.

C++ Example

// Include libraries.

#include <windows.h>
#include <atlbase.h>
#include "wmencode.h"
#include "wmencvu.h"

// Declare variables.

    HRESULT hr;
    IWMEncoder* pEncoder;
    IWMEncDataView* pPreview;
    IWMEncDataViewCollection* pPreviewColl;
    IWMEncSourceGroupCollection* pSrcGrpColl;
    IWMEncSourceGroup* pSrcGrp;
    IWMEncSource* pAudSrc;
    IWMEncSource* pVidSrc;
    IWMEncProfileCollection* pProColl;
    IWMEncProfile* pPro;

    long lCount;
    int i;

// Initialize the COM library and retrieve a pointer
// to an IWMEncoder interface.

    hr = CoInitialize(NULL);
    hr = CoCreateInstance(CLSID_WMEncoder,
                          NULL,
                          CLSCTX_INPROC_SERVER,
                          IID_IWMEncoder,
                          (void**) &pEncoder);

// Retrieve a pointer to an IWMEncSourceGroupCollection
// interface.

    hr = pEncoder->get_SourceGroupCollection(&pSrcGrpColl);

// Add a source group to the collection.

    hr = pSrcGrpColl->Add(L"SG_1", &pSrcGrp);

// Add a video and audio source to the source group.

    hr = pSrcGrp->AddSource(WMENC_VIDEO, &pVidSrc);
    hr = pSrcGrp->AddSource(WMENC_AUDIO, &pAudSrc);

// Identify the capture cards.

    hr = pVidSrc->SetInput(L"DEVICE://Default_Video_Device");
    hr = pAudSrc->SetInput(L"DEVICE://Default_Audio_Device");

// Choose a profile from the collection.

    CComBSTR bstrName = NULL;
    CComVariant varProfile;
    varProfile.vt = VT_DISPATCH;
    hr = pEncoder->get_ProfileCollection(&pProColl);
    hr = pProColl->get_Count(&lCount);
    for (i=0; i<lCount; i++)
    {
        hr = pProColl->Item(i, &pPro);
        hr = pPro->get_Name(&bstrName);
        if (_wcsicmp(bstrName,L"profile name")==0)
        {
            // Set the profile in the source group.
            varProfile.pdispVal = pPro;
            hr = pSrcGrp->put_Profile(varProfile);
            break;
        }
    }

// Retrieve a pointer to a preview object.

    hr = CoCreateInstance( CLSID_WMEncPreview,
                           NULL,
                           CLSCTX_INPROC_SERVER,
                           IID_IWMEncDataView,
                           (void**)&pPreview);

// Retrieve the preview collection.

    hr = pVidSrc->get_PreviewCollection( &pPreviewColl );

// Add the postiew object to the data view collection. If you set the
// cookie to -1, the encoder engine automatically generates a unique
// cookie.

    long lCookie = -1;
    hr = pPreviewColl->Add( pPreview, &lCookie);

// Continue configuring the encoder engine.

// Initialize the encoder engine.

    hr = pEncoder->PrepareToEncode(VARIANT_TRUE);

// Create a parent window for the preview, and specify the window
// settings for the encoder engine. For instance, you can create a
// window by using the Win32 API function CreateWindow(), and pass the
// window handle retrieved from this function to the
// SetViewSetting() method.
// Windows Media Encoder embeds the preview window in the parent window.
// If you do not create a parent window, and do not specify the display
// settings, Windows Media Encoder creates a default window for the
// preview.

    HWND hWnd;
    hr = pPreview->SetViewSetting((DWORD) lCookie,
                                   sizeof(hWnd),
                                  (BYTE*)&hWnd);

// Start the encoder engine.

    hr = pEncoder->Start();

// Start viewing the stream in a pop-up window.

    hr = pPreview->Start(lCookie);

See Also

  • Code Examples
  • Include Files and Type Libraries
  • IWMEncDataView Interface
  • IWMEncDataViewCollection::Add
  • IWMEncDataViewCollection Interface
  • IWMEncDataViewCollection Object


Broadcasting Live Content

The following Visual Basic example illustrates how to create the predefined user interface and use Windows Media Encoder to broadcast live multimedia content to a Windows Media server. You must attach a digital video camera to the video capture card input jack on your computer.

Visual Basic Example

' Create WMEncoderApp and WMEncoder objects.
Dim Encoder As WMEncoder
Dim EncoderApp As WMEncoderApp
Set EncoderApp = New WMEncoderApp
Set Encoder = EncoderApp.Encoder

' Display the predefined encoder UI.
EncoderApp.Visible = True

' Specify the source for the input stream.
Dim SrcGrpColl As IWMEncSourceGroupCollection
Dim SrcGrp As IWMEncSourceGroup
Dim SrcVid As IWMEncSource
Dim SrcAud As IWMEncSource

Set SrcGrpColl = Encoder.SourceGroupCollection
Set SrcGrp = SrcGrpColl.Add("SG_1")
Set SrcVid = SrcGrp.AddSource(WMENC_VIDEO)
Set SrcAud = SrcGrp.AddSource(WMENC_AUDIO)

SrcVid.SetInput "DEVICE://Default_Video_Device"
SrcAud.SetInput "DEVICE://Default_Audio_Device"

' Specify a profile.
Dim ProColl As IWMEncProfileCollection
Dim Pro As IWMEncProfile
Dim i As Integer

Set ProColl = Encoder.ProfileCollection

For i = 0 To ProColl.Count - 1
    Set Pro = ProColl.Item(i)
    If Pro.Name = " profile name" Then
        SrcGrp.Profile = Pro
        Exit For
    End If
Next

' Create a broadcast.
Dim BrdCst As IWMEncBroadcast
Set BrdCst = Encoder.Broadcast
BrdCst.PortNumber(WMENC_PROTOCOL_HTTP) = 8080

' Specify a file in which to save encoded content.
' Archiving defaults to automatic operation.
Dim OutFile As IWMEncFile
Set OutFile = Encoder.File
OutFile.LocalFileName = "file name"

' Start the encoder engine.
Encoder.Start

' Wait until the encoder engine stops before quitting the application.
' You can do this by using the _IWMEncoderEvents object to create an
' event sink.

See Also

  • _IWMEncoderEvents Object
  • Code Examples


Administering Windows Media Encoder on a Remote Computer

You can use the Windows Media Encoder SDK to write applications that enable an end user to administer WMEncoder objects on remote computers. Windows Media Encoder must be installed on the remote computer, and security settings must be configured by using the DCOMCnfg utility.

Setting Security for Windows 95 and Windows 98 Operating Systems

  1. Click Start, click Run, type DCOMCnfg, and click OK.
  2. In the Distributed COM Configuration Properties dialog box, click the Default Properties tab. Select the Enable Distributed COM on this computer check box.
  3. Click the Default Security tab, and select the Enable remote connection check box.
  4. Click the Applications tab. Select the Windows Media Encoder Agent application. Click Properties and click Use custom access permissions on the Security tab. Add the users you want to allow to administer Windows Media Encoder on this computer. Click OK.
  5. Click the Applications tab. Select the Windows Media Encoder application. Click Properties and click Use custom access permissions on the Security tab. Add the users you want to allow to administer Windows Media Encoder on this computer. Click OK.

You can download the latest version of DCOM from the Microsoft COM downloads page at the Microsoft Web site.

Setting Security for Windows NT and Windows 2000 Operating Systems

You must use the DCOMCnfg utility to configure the registry so that Windows Media Encoder can be controlled from a remote computer.

  1. Click Start, click Run, type DCOMCnfg, and click OK.
  2. In the Distributed COM Configuration Properties dialog box, click the Applications tab.
  3. Click Windows Media Encoder Agent, and click properties.
  4. Click the Security tab.
  5. Click Use custom access permissions, and then click Edit. Add the users you want to allow to administer the encoder engines on this computer. Click OK.
  6. Click Use custom launch permissions, and then click Edit. Add the users you want to allow to administer the encoder engines on this computer. Click OK.
  7. Click Use custom configuration permissions, and then click Edit. Add the users you want to allow to administer the encoder engines on this computer. Click OK.
  8. Click the Identity tab. Click This user, and then type the name and password of the user account that you want to use for encoder administration. Click OK.
  9. Click the Applications tab, click Windows Media Encoder, and then click Properties.
  10. Repeat steps 4 through 8, and then click OK.

VBScript Example

' If you use a scripting language you must create a
' WMEncoderAgentLocator object, and use it to create a
' WMEncoderAgent object on the remote computer

' Declare objects.
Dim AgentLocator
Dim EncoderAgent

' Create a WMEncAgentLocator object.
Set AgentLocator = CreateObject("WMEncLoc.WNEncAgentLocator")

' Create a WMEncoderAgent object on a remote computer.
Set EncoderAgent = AgentLocator.GetAgent("computer name")
' Create a WMEncoderApp object on the remote computer.
Set EncoderApp = EncoderAgent.CreateEncoder("WMEnc_1",
                        "WMEnc.WMEncoderApp")

' For more information, see the following Visual Basic example.

Visual Basic Example

' Declare objects and variables.
Dim Encoder As WMEncoder
Dim EncoderApp As WMEncoderApp
Dim EncoderAgent As WMEncoderAgent
Dim EncoderNames As IWMEncoderNamesCollection

Dim lCount As Long
Dim sName As String

' Create a WMEncoderAgent object on a remote computer.
Set EncoderAgent = CreateObject("WMEncAgt.WMEncoderAgent",
                        "computer name")

' Create a WMEncoderApp object on the remote computer.
Set EncoderApp = EncoderAgent.CreateEncoder("WMEnc_1",
                        "WMEnc.WMEncoderApp")

' Retrieve an IWMEncoderNamesCollection object.
Set EncoderNames = EncoderAgent.EncoderNamesCollection

' Retrieve the number of WMEncoder objects that have been
' created on the remote computer.
lCount = EncoderNames.Count

' For simplicity, this example created only one WMEncoder object.
' Retrieve the name.
sName = EncoderNames.Item(0)

' Retrieve the WMEncoder object.
Set Encoder = EncoderAgent.GetEncoder(sName)

C++ Example

#ifndef _WIN32_WINNT
#define _WIN32_WINNT 0x0400
#endif

// Include libraries.

#include <windows.h>
#include <atlbase.h>
#include <objbase.h>
#include "wmencode.h"
#include "localagent.h"

// Declare variables.

    HRESULT hr;
    IWMEncoder* pEncoder = NULL;
    IWMEncoderApp* pEncoderApp = NULL;
    IWMEncoderAgent* pAgent = NULL;
    IDispatch* pDispEncNames = NULL;
    IDispatch* pDispEnc = NULL;
    IDispatch* pDispEncApp = NULL;
    IWMEncoderNamesCollection* pEncNames = NULL;

    long lCount;
    int i;

// Create a COSERVERINFO structure containing information
// about the computer on which to create the IWMEncoderAgent
// object.

    COSERVERINFO cs;
    ZeroMemory(&cs,sizeof(cs));
    cs.pwszName = L"name of remote computer";
    cs.pAuthInfo = NULL;

// Create a MULTI_QI structure to hold an IUnknown pointer
// to a IWMEncoderAgent object.

    MULTI_QI mqi;
    ZeroMemory(&mqi,sizeof(mqi));
    mqi.pIID = &IID_IWMEncoderAgent;
    mqi.pItf = pAgent;
    mqi.hr = 0;

// Initialize the COM library and retrieve a pointer
// to an IWMEncoderAgent interface on the remote computer.

    hr = CoInitialize(NULL);
    hr = CoCreateInstanceEx(CLSID_WMEncoderAgent,
                            NULL,
                            CLSCTX_SERVER,
                            &cs,
                            1,
                            &mqi);

    hr = mqi.pItf->QueryInterface(IID_IWMEncoderAgent,
                                  (void**) &pAgent);

// Create a WMEncoderApp object on the remote computer.

    CComVariant var;
    var = L"WMEnc.WMEncoderApp";
    CComBSTR    bstrEncoderName;
    bstrEncoderName = L"WMEncoder_1";

    // Instead of a ProgID, you can also set the vt member
    // of the Variant structure to VT_ERROR to create a
    // WMEncoderApp object.

    hr = pAgent->CreateEncoder(bstrEncoderName,var,&pDispEncApp);

    // Call QueryInterface() to retrieve an IWMEncoderApp pointer.

    hr = pDispEncApp->QueryInterface(IID_IWMEncoderApp,
                                     (void**) &pEncoderApp);

// Retrieve an IDispatch pointer to an IWMEncoderNamesCollection
// interface.

    hr = pAgent->get_EncoderNamesCollection(&pDispEncNames);

// Call QueryInterface() to retrieve an IWMEncoderNamesCollection
// interface.

    hr = pDispEncNames->QueryInterface(
                           IID_IWMEncoderNamesCollection,
                           (void**) &pEncNames);

// Retrieve the number of WMEncoder objects created on the
// remote computer. For simplicity, this example created only
// one WMEncoder object.

    hr = pEncNames->get_Count(&lCount);

    for (i=0; i<lCount; i++)
    {
        pDispEnc = NULL;
        CComBSTR bstrName;

        // Retrieve the name of each WMEncoder object.
        hr = pEncNames->Item(i, &bstrName);

        // Retrieve the IDispatch pointer to each
        // WMEncoder object.
        hr = pAgent->GetEncoder(bstrName, &pDispEnc);

        // Retrieve each IWMEncoder pointer.
        hr = pDispEnc->QueryInterface(IID_IWMEncoder,
                                          (void**) &pEncoder);

     }

See Also

  • Code Examples
  • Remote Administration
  • Remote Administration Interfaces (C++)
  • Remote Administration Objects (Visual Basic)


Programming Reference

The Microsoft® Windows Media™ Encoder Software Development Kit (SDK) supports interfaces and enumeration types for both Microsoft® Visual Basic® and C++. The following sections detail these.

Section | Description
Interfaces (C++) | Describes encoder automation interfaces for developers using C++.
Objects (Visual Basic) | Describes encoder automation objects for Visual Basic developers.
Property Page Interfaces (C++) | Describes property page interfaces for developers using C++.
Property Page Objects (Visual Basic) | Describes property pages for Visual Basic objects.
Remote Administration Interfaces (C++) | Describes the interfaces that manage remote administration of Windows Media Encoder for developers using C++.
Remote Administration Interfaces (Visual Basic) | Describes the objects that manage remote administration of Windows Media Encoder for developers using Visual Basic.
Structures and Enumeration Types | Lists the structures and enumeration types in this SDK.

See Also

  • Windows Media Encoder 7.1 SDK


Interfaces (C++)

The Windows Media Encoder SDK provides the following interfaces to configure and operate Windows Media Encoder and capture multimedia streams from files or devices.

Interface | Description
_IWMEncoderEvents Interface | Receives Windows Media Encoder event notifications.
IWMEncAttributes Interface | Manages a collection of name-value pairs created by the content author to provide extra information about the encoding session.
IWMEncBroadcast Interface | Manages the port number used for broadcasting encoded content.
IWMEncDataView Interface | Controls display of preview and postview objects in a video window. This is not an Automation-compliant interface.
IWMEncDataViewCollection Interface | Manages a collection of objects used to display a stream. The most common examples are preview and postview objects.
IWMEncDisplayInfo Interface | Manages information about the content being encoded. This includes the name of the author, the copyright date, the title and rating of the content, and descriptive text.
IWMEncFile Interface | Manages the name of the file used for archiving encoded content.
IWMEncFileArchiveStats Interface | Retrieves the size, in bytes, of the archive file and the duration, in milliseconds, of the encoded content stored in the file.
IWMEncIndexerStats Interface | Monitors the indexing process for a Windows Media file.
IWMEncNetConnectionStats Interface | Retrieves information about the number and nature of the clients connected to Windows Media Encoder.
IWMEncoder Interface | Operates the Windows Media Encoder engine.
IWMEncoderApp Interface | Displays the primary user interface built into Windows Media Encoder.
IWMEncOutputStats Interface | Retrieves status information about the encoding session.
IWMEncPluginInfo Interface | Retrieves information about plug-ins.
IWMEncPostViewCollection Interface | Manages a collection of interfaces that can be used to display streams after compression and decompression.
IWMEncProfile Interface | Retrieves descriptive information about the profile associated with the active source group.
IWMEncProfileCollection Interface | Enumerates the profiles that are available to an encoding session.
IWMEncProfileManager Interface | Creates an instance of the Profile Manager to edit and create profiles.
IWMEncSource Interface | Defines the source of a multimedia stream.
IWMEncSourceGroup Interface | Manages a source group of source streams.
IWMEncSourceGroupCollection Interface | Manages the collection of source groups that are available during an encoding session.
IWMEncSourcePluginInfoManager Interface | Enumerates the available source plug-ins.
IWMEncStatistics Interface | Retrieves status information about the encoding session.
IWMEncTransform Interface | Specifies and retrieves transform plug-ins.
IWMEncTransformCollection Interface | Manages the collection of transform plug-ins used during the current encoding session.
IWMEncTransformPluginInfoManager Interface | Enumerates the available transform plug-ins.
IWMEncVideoSource Interface | Crops the edges of a video image and specifies the pixel format and video optimization.

See Also

  • Programming Reference
  • [Visual Basic] Objects (Visual Basic)


_IWMEncoderEvents Interface

The _IWMEncoderEvents interface is a callback interface to which Windows Media Encoder sends event notifications. Use this interface to respond to run-time errors, configuration changes, and state changes.

Note Do not perform blocking actions when the encoder engine is firing events. You will not be able to receive the events in a timely manner. For example, do not create a modal dialog box when events are being fired.

The following header and the implementation code in each method utilize the Active Template Library (ATL).

#ifndef __CallBack_H__
#define __CallBack_H__

#include <atlbase.h>
extern CComModule _Module;
#include <atlcom.h>

#include "wmencode.h"
#include "wmsencid.h"

#define EVENT_ID        100
#define LIB_VERMAJOR    1
#define LIB_VERMINOR    0

class CCallBack : public IDispEventImpl< EVENT_ID,
                                         CCallBack,
                                         &DIID__IWMEncoderEvents,
                                         &LIBID_WMEncoderLib,
                                         LIB_VERMAJOR,
                                         LIB_VERMINOR >
{
public:
    //
    // Encoder Event Sink using ATL 3.0
    //
    // Note: This example uses _ATL_FUNC_INFO and SINK_ENTRY_INFO
    // because the SINK_ENTRY_EX macro doesn't allow enumerated
    // types to be passed as parameters to IDispatch.

    static _ATL_FUNC_INFO StateChangeInfo;
    static _ATL_FUNC_INFO ErrorInfo;
    static _ATL_FUNC_INFO ArchiveStateChangeInfo;
    static _ATL_FUNC_INFO ConfigChangeInfo;
    static _ATL_FUNC_INFO ClientConnectInfo;
    static _ATL_FUNC_INFO ClientDisconnectInfo;
    static _ATL_FUNC_INFO SourceStateChangeInfo;
    static _ATL_FUNC_INFO IndexerStateChangeInfo;

BEGIN_SINK_MAP(CCallBack)
    SINK_ENTRY_INFO( EVENT_ID,
                     DIID__IWMEncoderEvents,
                     DISPID_ENCODEREVENT_STATECHANGE,
                     OnStateChange,
                     &StateChangeInfo )
    SINK_ENTRY_INFO( EVENT_ID,
                     DIID__IWMEncoderEvents,
                     DISPID_ENCODEREVENT_ERROR,
                     OnError,
                     &ErrorInfo )
    SINK_ENTRY_INFO( EVENT_ID,
                     DIID__IWMEncoderEvents,
                     DISPID_ENCODEREVENT_ARCHIVESTATECHANGE,
                     OnArchiveStateChange,
                     &ArchiveStateChangeInfo )
    SINK_ENTRY_INFO( EVENT_ID,
                     DIID__IWMEncoderEvents,
                     DISPID_ENCODEREVENT_CONFIGCHANGE,
                     OnConfigChange,
                     &ConfigChangeInfo)
    SINK_ENTRY_INFO( EVENT_ID,
                     DIID__IWMEncoderEvents,
                     DISPID_ENCODEREVENT_CLIENTCONNECT,
                     OnClientConnect,
                     &ClientConnectInfo)
    SINK_ENTRY_INFO( EVENT_ID,
                     DIID__IWMEncoderEvents,
                     DISPID_ENCODEREVENT_CLIENTDISCONNECT,
                     OnClientDisconnect,
                     &ClientDisconnectInfo)
    SINK_ENTRY_INFO( EVENT_ID,
                     DIID__IWMEncoderEvents,
                     DISPID_ENCODEREVENT_SRCSTATECHANGE,
                     OnSourceStateChange,
                     &SourceStateChangeInfo )
    SINK_ENTRY_INFO( EVENT_ID,
                     DIID__IWMEncoderEvents,
                     DISPID_ENCODEREVENT_INDEXERSTATECHANGE,
                     OnIndexerStateChange,
                     &IndexerStateChangeInfo )
END_SINK_MAP()

public:
    STDMETHOD(OnStateChange)(/*[in]*/ WM_ENCODER_STATE enumState);
    STDMETHOD(OnSourceStateChange)(
                 /*[in]*/WMENC_SOURCE_STATE enumState,
                 /*[in*/]WMENC_SOURCE_TYPE enumType,
                 /*[in*/]short iIndex)
                 /*[in]*/BSTR bstrSourceGroup;
    STDMETHOD(OnError)(/*[in]*/ long hResult);
    STDMETHOD(OnArchiveStateChange)(
                 /*[in]*/ WMENC_ARCHIVE_TYPE enumArchive,
                 /*[in]*/ WMENC_ARCHIVE_STATE enumState );
    STDMETHOD(OnConfigChange)(/*[in]*/ long hResult, /*[in]*/ BSTR bstr);
    STDMETHOD(OnClientConnect)(
                 /*[in]*/ WMENC_BROADCAST_PROTOCOL protocol,
                 /*[in]*/ BSTR bstr);
    STDMETHOD(OnClientDisconnect)(
                 /*[in]*/ WMENC_BROADCAST_PROTOCOL protocol,
                 /*[in]*/ BSTR bstr);
    STDMETHOD(OnIndexerStateChange)(
                 /*[in]*/ WMENC_INDEXER_STATE enumIndexerState,
                 /*[in]*/ BSTR bstrFile );

    HRESULT CCallBack::Init( IWMEncoder* pEncoder )
    {
        HRESULT hr = DispEventAdvise( pEncoder );
        if( FAILED( hr ) )
        {
        }
    return hr;
    }

    HRESULT CCallBack::ShutDown( IWMEncoder* pEncoder )
    {
        HRESULT hr = DispEventUnadvise( pEncoder );
        if( FAILED( hr ) )
        {
        }
        return hr;
    }

    CCallBack();

};

#endif // __EncBase_H__

In addition to the methods inherited from IDispatch, the _IWMEncoderEvents interface exposes the following methods.

Method | Description
OnArchiveStateChange | Receives an event notice indicating a change in the archiving state.
OnClientConnect | Receives an event notice indicating that a client has connected to Windows Media Encoder.
OnClientDisconnect | Receives an event notice indicating that a client has disconnected from Windows Media Encoder.
OnConfigChanged | Receives an event notice indicating a change in the Windows Media Encoder configuration.
OnError | Receives Windows Media Encoder run-time error event notices.
OnIndexerStateChange | Receives an event notice indicating whether the creation of an index for a Windows Media file has been started or stopped.
OnSourceStateChange | Receives an event notice indicating whether a specific input stream has started or stopped sending data to the encoder engine.
OnStateChange | Receives an event notice indicating whether Windows Media Encoder has been started or stopped.

See Also

  • [Visual Basic] _IWMEncoderEvents Object
  • Interfaces (C++)


_IWMEncoderEvents::OnArchiveStateChange

The OnArchiveStateChange method receives an event notice indicating a change in the archiving state.

Syntax

HRESULT OnArchiveStateChange(
  WMENC_ARCHIVE_TYPE  enumArchive,
  WMENC_ARCHIVE_OPERATION  enumState
);

Parameters

enumArchive

[in] Member of a WMENC_ARCHIVE_TYPE enumeration type sent by Windows Media Encoder to specify where the archived content is being saved. This parameter must take the following value.

Value | Number | Meaning
WMENC_ARCHIVE_LOCAL | 1 | Save encoded content to a local file.

enumState

[in] Member of a WMENC_ARCHIVE_STATE enumeration type sent by Windows Media Encoder to specify the archiving state. This parameter must take one of the following values.

Value | Number | Meaning
WMENC_ARCHIVE_RUNNING | 1 | The archiving operation is running.
WMENC_ARCHIVE_PAUSED | 2 | The archiving operation has been paused.
WMENC_ARCHIVE_STOPPED | 3 | The archiving operation has been stopped.

Remarks

Use OnArchiveStateChange to respond to notifications of changes in the state of the archiving process. For example, use this callback to determine when to enable or disable UI command buttons that depend upon whether archiving has been started or stopped.

Example Code

#include "callback.h"

CComModule _Module;

/////////////////////////////////////////////////////////////

CCallBack::CCallBack( )
{
}
_ATL_FUNC_INFO CCallBack::ArchiveStateChangeInfo= {CC_STDCALL,
          VT_ERROR, 2, { VT_I4, VT_I4 } };

/////////////////////////////////////////////////////////////

STDMETHODIMP CCallBack::OnArchiveStateChange(
                WMENC_ARCHIVE_TYPE enumArchive,
                WMENC_ARCHIVE_STATE enumState )
{

switch ( enumArchive )
    {
    case WMENC_ARCHIVE_LOCAL:
        break;
    default:
        break;
    }

switch ( enumState )
    {
    case WMENC_ARCHIVE_RUNNING:
        // Process the case.
        break;

    case WMENC_ARCHIVE_PAUSED:
        // Process the case.
        break;

    case WMENC_ARCHIVE_STOPPED:
        // Process the case.
        break;

    default:
        break;
    }
return S_OK;
}

See Also

  • IWMEncoder Interface
  • _IWMEncoderEvents Interface


_IWMEncoderEvents::OnClientConnect

The OnClientConnect method receives an event notice indicating that a client has connected to Windows Media Encoder.

Syntax

HRESULT OnClientConnect(
  WMENC_BROADCAST_PROTOCOL  protocol,
  BSTR  bstrIPAddr
);

Parameters

protocol

[in] Member of a WMENC_BROADCAST_PROTOCOL enumeration type containing the broadcast protocol. This must be the following value.

Value | Number | Description
WMENC_PROTOCOL_HTTP | 1 | The client has connected using the HTTP protocol.

bstrIPAddr

[in] BSTR containing the IP address of the client.

Example Code

#include "callback.h"

CComModule _Module;

///////////////////////////////////////////////

CCallBack::CCallBack( )
{
}
_ATL_FUNC_INFO CCallBack::ClientConnectInfo = {CC_STDCALL,
          VT_ERROR, 2, { VT_I4, VT_BSTR } };

///////////////////////////////////////////////

STDMETHODIMP CCallBack::OnClientConnect(
                WMENC_BROADCAST_PROTOCOL protocol,
                BSTR bstr)
{
return S_OK;
}

See Also

  • _IWMEncoderEvents Interface


_IWMEncoderEvents::OnClientDisconnect

The OnClientDisconnect method receives an event notice indicating that a client has disconnected from Windows Media Encoder.

Syntax

HRESULT OnClientDisconnect(
  WMENC_BROADCAST_PROTOCOL  protocol,
  BSTR  bstrIPAddr
);

Parameters

protocol

[in] Member of a WMENC_BROADCAST_PROTOCOL enumeration type containing the broadcast protocol. This must be the following value.

Value | Number | Description
WMENC_PROTOCOL_HTTP | 1 | The client has connected using the HTTP protocol.

bstrIPAddr

[in] BSTR containing the IP address of the client.

Example Code

#include "callback.h"

CComModule _Module;

///////////////////////////////////////////////

CCallBack::CCallBack( )
{
}

_ATL_FUNC_INFO CCallBack::ClientDisconnectInfo = {CC_STDCALL,
            VT_ERROR, 2, { VT_I4, VT_BSTR } };

STDMETHODIMP CCallBack::OnClientDisconnect(
                 WMENC_BROADCAST_PROTOCOL protocol,
                 BSTR bstr)
{
return S_OK;
}

See Also

  • _IWMEncoderEvents Interface


_IWMEncoderEvents::OnConfigChange

The OnConfigChanged method receives an event notice indicating a change in the Windows Media Encoder configuration.

Syntax

HRESULT OnConfigChanged(
  long  lDispID
..BSTR..bstr
);

Parameters

lDispID

[in] long sent by Windows Media Encoder, containing the DISPID of the property that changed.

bstr

[in] BSTR sent by Windows Media Encoder, containing the name of the source group in which the change occurred.

Remarks

This event is fired for any property in the Windows Media Encoder type library.

Example Code

#include "callback.h"

CComModule _Module;

///////////////////////////////////////////////

CCallBack::CCallBack( )
{
}

_ATL_FUNC_INFO CCallBack::ConfigChangeInfo
= {CC_STDCALL, VT_ERROR, 2, { VT_I4, VT_BSTR } };

///////////////////////////////////////////////

STDMETHODIMP CCallBack::OnConfigChange(long hResult, BSTR bstr)
{
    return S_OK;
}

See Also

  • _IWMEncoderEvents Interface


_IWMEncoderEvents::OnError

The OnError method receives Windows Media Encoder run-time error event notices.

Syntax

HRESULT OnError(
  long  hResult
);

Parameters

hResult

[in] long sent by the encoder, containing the error code. This can be one of the following values.

Value | Number | Description
NS_E_BAD_MARKIN | 0xC00D1B58 | The starting time must be greater than zero and less than the ending time.
NS_E_BAD_MARKOUT | 0xC00D1B59 | The ending time must be greater than the starting time and less than the file duration.
NS_E_VIDEODEVICE_BUSY | 0xC00D1B64 | The video capture device is in use and cannot be opened.
NS_E_VIDEODRIVER_UNSTABLE | 0xC00D1B68 | The video capture driver returned an unrecoverable error.
NS_E_VIDCAPSTARTFAILED | 0xC00D1B69 | The video capture device did not start.
NS_E_VIDCAPCREATEWINDOW | 0xC00D1B6D | The video capture window was not created.
NS_E_INVALIDCALL_WHILE_ARCHIVAL_RUNNING | 0xC00D1B74 | The specified operation is not allowed when the file is being archived.
NS_E_ARCHIVE_FILENAME_NOTSET | 0xC00D1B79 | The archive file name is not properly specified.
NS_E_INVALIDCALL_WHILE_ENCODER_STOPPED | 0xC00D1B7F | The specified operation is not allowed when the encoder engine is not running.
NS_E_INVALID_INPUTFPS | 0xC00D1B81 | Inverse telecine cannot be specified when the frame rate does not equal 30 frames per second.
NS_E_NO_DATAVIEW_SUPPORT | 0xC00D1B82 | Internal problems are preventing the preview or postview.
NS_E_CODEC_UNAVAILABLE | 0xC00D1B83 | One or more required codecs cannot be found.
NS_E_UNEXPECTED_DISPLAY_SETTINGS | 0xC00D1B88 | The display size or color setting has changed since the encoding session was defined.

Remarks

Use the OnError method to respond to run-time error event notices. The get_ErrorState method in the IWMEncoder interface provides another way to retrieve errors while the encoder is running.

Example Code

#include "callback.h"

CComModule _Module;

///////////////////////////////////////////////

CCallBack::CCallBack( )
{
}

_ATL_FUNC_INFO CCallBack::ErrorInfo = {CC_STDCALL,
         VT_ERROR, 1, { VT_I4 } };

///////////////////////////////////////////////

STDMETHODIMP CCallBack::OnError(long hResult)
{
MessageBox(NULL,"Error Encoding","Error",MB_ICONINFORMATION);
return S_OK;
}

See Also

  • IWMEncoder::get_ErrorState
  • _IWMEncoderEvents Interface


_IWMEncoderEvents::OnIndexerStateChange

The OnIndexerStateChange method receives an event notice indicating whether the indexing process for a Windows Media file has been started or stopped.

Syntax

HRESULT OnIndexerStateChange(
  WMENC_INDEXER_STATE  enumIndexerState,
  BSTR  bstrFile
);

Parameters

enumIndexerState

[in] Member of a WMENC_INDEXER_STATE enumeration type sent by Windows Media Encoder to specify the state of the indexing process. This must be one of the following values.

Value | Number | Description
WMENC_INDEXER_RUNNING | 1 | The indexing process has been started.
WMENC_INDEXER_STOPPED | 2 | The indexing process has been stopped.

bstrFile

[in] BSTR sent by Windows Media Encoder, containing the name of the file being indexed.

Remarks

A file index enables operations, such as fast-fowarding, that must seek to specific time offsets in a file. For each file, an event is sent when the indexing process starts, and another event is sent when the process stops. The indexing process is performed in the background on a lower priority thread.

Example Code

#include "callback.h"

CComModule _Module;

///////////////////////////////////////////////

CCallBack::CCallBack( )
{
}

_ATL_FUNC_INFO CCallBack::IndexerStateChangeInfo = {CC_STDCALL,
         VT_ERROR, 2, { VT_I4, VT_BSTR } };

///////////////////////////////////////////////

STDMETHODIMP CCallBack::OnIndexerStateChange(
                 WMENC_INDEXER_STATE enumIndexerState,
                 BSTR bstrFile )
{
    return S_OK;
}

See Also

  • _IWMEncoderEvents Interface
  • IWMEncIndexerStats Interface


_IWMEncoderEvents::OnSourceStateChange

The OnSourceStateChange method receives an event notice indicating whether the encoding of a specific source stream has started or stopped.

Syntax

HRESULT OnSourceStateChange(
  WMENC_SOURCE_STATE  enumState,
  WMENC_SOURCE_TYPE  enumType,
  short  iIndex,
  BSTR  bstrSourceGroup
);

Parameters

enumState

[in] Member of a WMENC_SOURCE_STATE enumeration type indicating whether input stream capture has been started or stopped. This must be one of the following values.

Value | Number | Description
WMENC_SOURCE_START | 1 | The input stream is being captured.
WMENC_SOURCE_STOP | 2 | The input stream is not being captured.
WMENC_SOURCE_PREPARE | 3 | A source plug-in has been added.
WMENC_SOURCE_UNPREPARE | 4 | A source plug-in has been removed.

enumType

[in] Member of a WMENC_SOURCE_TYPE enumeration type indicating the type of the input stream. This must be one of the following values.

Value | Number | Description
WMENC_AUDIO | 1 | Identifies an audio stream.
WMENC_VIDEO | 2 | Identifies a video stream.
WMENC_SCRIPT | 4 | Identifies a script stream.

iIndex

[in] short identifying which audio, video or text stream is being captured. Because there can only be one stream of each type, iIndex must be zero.

bstrSourceGroup

[in] BSTR containing the name of the source group of which the source stream is a member.

Remarks

Use OnSourceStateChange to determine when a source stream has finished transmitting data to the encoder engine. When all streams have finished, you can begin encoding another source group. This enables you to broadcast playlists from Windows Media Encoder.

Example Code

#include "callback.h"

CComModule _Module;

///////////////////////////////////////////////

CCallBack::CCallBack( )
{
}

_ATL_FUNC_INFO CCallBack::SourceStateChangeInfo = {CC_STDCALL,
          VT_ERROR, 3, { VT_I4, VT_I4, VT_I2 } };

///////////////////////////////////////////////

STDMETHODIMP CCallBack::OnSourceStateChange(
                 WMENC_SOURCE_STATE enumState,
                 WMENC_SOURCE_TYPE enumType,
                 short iIndex)
{
switch ( enumState )
    {
    case WMENC_SOURCE_START:
        break;
    case WMENC_SOURCE_STOP:
        break;
    default:
        break;
    }

switch ( enumType )
    {
    case WMENC_AUDIO:
        break;
    case WMENC_VIDEO:
        break;
    case WMENC_SCRIPT:
        break;
    default:
        break;
    }

return S_OK;
}

See Also

  • _IWMEncoderEvents Interface


_IWMEncoderEvents::OnStateChange

The OnStateChange method receives an event notice indicating whether Windows Media Encoder has been started or stopped.

Syntax

HRESULT OnStateChange(
  WMENC_ENCODER_STATE  enumState
);

Parameters

enumState

[in] Member of a WMENC_ENCODER_STATE enumeration type sent by Windows Media Encoder to specify the operating state. This parameter must be one of the following values.

Value | Number | Meaning
WMENC_ENCODER_STARTING | 1 | Windows Media Encoder is starting.
WMENC_ENCODER_RUNNING | 2 | Windows Media Encoder is running.
WMENC_ENCODER_STOPPING | 4 | Windows Media Encoder is stopping.
WMENC_ENCODER_STOPPED | 5 | Windows Media Encoder has been stopped.

Remarks

Use the OnStateChange method to respond to Windows Media Encoder state event notices. For example, use this callback to determine when to enable or disable UI command buttons that depend upon whether the encoder is running or stopped.

Example Code

#include "callback.h"

CComModule _Module;

///////////////////////////////////////////////

CCallBack::CCallBack( )
{
}

_ATL_FUNC_INFO CCallBack::StateChangeInfo = {CC_STDCALL,
        VT_ERROR, 1, { VT_I4 } };

///////////////////////////////////////////////

STDMETHODIMP CCallBack::OnStateChange(WM_ENCODER_STATE enumState)
{
switch ( enumState )
    {
    case WM_ENCODER_STARTING:
        break;
    case WM_ENCODER_STARTED:
        break;
    case WM_ENCODER_PAUSED:
        break;
    case WM_ENCODER_STOPPING:
        break;
    case WM_ENCODER_STOPPED:
        break;
    default:
        break;
    }

return S_OK;
}///////////////////////////////////////////////

See Also

  • _IWMEncoderEvents Interface


IWMEncAttributes Interface

The IWMEncAttributes interface manages a collection of user-defined attributes. These are combinations of name-value pairs that provide extra, author-defined information about an encoding session. For example, you can indicate the creation date for a stream by assigning the string "Date" to the attribute name and a string containing the formatted date to the attribute value. You can also use this interface to categorize content.

In addition to the methods inherited from IDispatch, the IWMEncAttributes interface exposes the following methods.

Method | Description
Add | Adds a new name-value pair to the collection of user-defined attributes.
get_Count | Retrieves the number of name-value pairs in the collection of user-defined attributes.
Item | Retrieves a specific name-value pair from the collection of user-defined attributes.
Remove | Removes a specific name-value pair from the collection of user-defined attributes.
RemoveAll | Removes all attributes from the collection.

See Also

  • [Visual Basic] IWMEncAttributes Object
  • Interfaces (C++)


IWMEncAttributes::Add

The Add method adds a new name-value pair to the collection of user-defined attributes.

Syntax

HRESULT Add(
  BSTR  bstrName,
  VARIANT  varValue
);

Parameters

bstrName

[in] BSTR containing the attribute name.

varValue

[in] VARIANT containing the attribute value.

Return Values

If the method succeeds, it returns S_OK. If it fails, it supports an IErrorInfo interface and returns an HRESULT error code.

Return code | Number | Meaning
E_INVALIDARG | 0x80070057 | The string containing the name cannot be empty.
E_POINTER | 0x80004003 | The address of the variable containing the name is NULL.
NS_E_INVALID_CALL_WHILE_ENCODER_RUNNING | 0xC00D1B65 | You cannot call this method if the encoder engine is running.

Remarks

The IWMEncAttributes::Remove method removes a single name-value pair from the collection, and IWMEncAttributes::RemoveAll clears all attributes from the collection.

Example code

// Include libraries.

#include <windows.h>
#include <comdef.h>                // Includes _bstr_T and _variant_T.
#include <atlbase.h>               // Includes CComBSTR.
#include "wmencode.h"

// Declare variables.

HRESULT hr;
IWMEncoder* pEncoder;
IWMEncAttributes* pAttr;
CComBSTR m_bstrName;
CComVariant m_varValue;
CComVariant m_varIndex;
long cnt;

// Initialize the COM library and retrieve a pointer
// to an IWMEncoder interface.

hr = CoInitialize(NULL);
hr = CoCreateInstance(CLSID_WMEncoder,
                      NULL,
                      CLSCTX_INPROC_SERVER,
                      IID_IWMEncoder,
                      (void**) &pEncoder);

// Retrieve a pointer to an IWMEncAttributes interface.

hr = pEncoder->get_Attributes(&pAttr);

// Add name:value pairs to the attributes collection.

_bstr_t bName[] =
{
    _bstr_t("Date Created: "),
    _bstr_t("Time Created: "),
    _bstr_t("File Content: ")
};
_variant_t vVal[] =
{
    _variant_t("02/15/2000"),
    _variant_t("13:30:15"),
    _variant_t("multimedia data"),
};

for(int i=0;i<3;i++)
{
    pAttr->Add(bName[i],vVal[i]);
}

// Retrieve the name-value pairs from the collection.

pAttr->get_Count(&cnt);
for (i=0; i<cnt; i++)
{
    pAttr->Item(i, &m_bstrName, &m_varValue);
}

// Remove an attribute by name.

CComVariant m_varNameRemove("File Content: ");
hr = pAttr->Remove(m_varNameRemove);

// Remove an attribute by index.

hr = pAttr->Remove(m_varIndex=0);

// Remove all attributes;

hr = pAttr->RemoveAll();

See Also

  • IWMEncAttributes Interface
  • IWMEncAttributes::get_Count
  • IWMEncAttributes::Item
  • IWMEncAttributes::Remove
  • IWMEncAttributes::RemoveAll


IWMEncAttributes::get_Count

The get_Count method retrieves the number of name-value pairs in the collection of user-defined attributes.

Syntax

HRESULT get_Count(
  long*  plCount
);

Parameters

plCount

[out] Pointer to a long containing the number of attributes in the collection.

Return Values

If the method succeeds, it returns S_OK. If it fails it supports an IErrorInfo interface.

Remarks

Call get_Count before iterating through the collection, and use the returned value as an upper loop boundary.

Example Code

// Include libraries.

#include <windows.h>
#include <comdef.h>                // Includes _bstr_T and _variant_T.
#include <atlbase.h>               // Includes CComBSTR.
#include "wmencode.h"

// Declare variables.

HRESULT hr;
IWMEncoder* pEncoder;
IWMEncAttributes* pAttr;
CComBSTR m_bstrName;
CComVariant m_varValue;
CComVariant m_varIndex;
long cnt;

// Initialize the COM library and retrieve a pointer
// to an IWMEncoder interface.

hr = CoInitialize(NULL);
hr = CoCreateInstance(CLSID_WMEncoder,
                      NULL,
                      CLSCTX_INPROC_SERVER,
                      IID_IWMEncoder,
                      (void**) &pEncoder);

// Retrieve a pointer to an IWMEncAttributes interface.

hr = pEncoder->get_Attributes(&pAttr);

// Add name-value pairs to the attributes collection.

_bstr_t bName[] =
{
    _bstr_t("Date Created: "),
    _bstr_t("Time Created: "),
    _bstr_t("File Content: ")
};
_variant_t vVal[] =
{
    _variant_t("02/15/2000"),
    _variant_t("13:30:15"),
    _variant_t("multimedia data"),
};

for(int i=0;i<3;i++)
{
    pAttr->Add(bName[i],vVal[i]);
}

// Retrieve the name-value pairs from the collection.

pAttr->get_Count(&cnt);
for (i=0; i<cnt; i++)
{
    pAttr->Item(i, &m_bstrName, &m_varValue);
}

// Remove an attribute by name.

CComVariant m_varNameRemove("File Content: ");
hr = pAttr->Remove(m_varNameRemove);

// Remove an attribute by index.

hr = pAttr->Remove(m_varIndex=0);

// Remove all attributes;

hr = pAttr->RemoveAll();

See Also

  • IWMEncAttributes Interface
  • IWMEncAttributes::Add
  • IWMEncAttributes::Item
  • IWMEncAttributes::Remove
  • IWMEncAttributes::RemoveAll


IWMEncAttributes::Item

The Item method retrieves a specific name-value pair from the collection of user-defined attributes.

Syntax

HRESULT Item(
  long  iIndex,
  BSTR*  pbstrName,
  VARIANT*  pvarValue
);

Parameters

iIndex

[in] long containing the index number of the attribute in the collection.

pbstrName

[out] Pointer to a BSTR containing the attribute name.

pvarValue

[out] Pointer to a VARIANT containing the attribute value.

Return Values

If the method succeeds, it returns S_OK. If it fails, it supports an IErrorInfo interface and returns an HRESULT error code.

Return code | Number | Meaning
NS_E_INVALID_INDEX | 0xC00D0011 | The input parameter does not match a valid index in the attributes collection.

Remarks

You can iterate through the collection and use this method to find the index for a specific attribute. Call IWMEncAttributes::get_Count first to determine the upper limit of the number of items you must iterate through.

Example code

// Include libraries.

#include <windows.h>
#include <comdef.h>                // Includes _bstr_T and _variant_T.
#include <atlbase.h>               // Includes CComBSTR.
#include "wmencode.h"

// Declare variables.

HRESULT hr;
IWMEncoder* pEncoder;
IWMEncAttributes* pAttr;
CComBSTR m_bstrName;
CComVariant m_varValue;
CComVariant m_varIndex;
long cnt;

// Initialize the COM library and retrieve a pointer
// to an IWMEncoder interface.

hr = CoInitialize(NULL);
hr = CoCreateInstance(CLSID_WMEncoder,
                      NULL,
                      CLSCTX_INPROC_SERVER,
                      IID_IWMEncoder,
                      (void**) &pEncoder);

// Retrieve a pointer to an IWMEncAttributes interface.

hr = pEncoder->get_Attributes(&pAttr);

// Add name:value pairs to the attributes collection.

_bstr_t bName[] =
{
    _bstr_t("Date Created: "),
    _bstr_t("Time Created: "),
    _bstr_t("File Content: ")
};
_variant_t vVal[] =
{
    _variant_t("02/15/2000"),
    _variant_t("13:30:15"),
    _variant_t("multimedia data"),
};

for(int i=0;i<3;i++)
{
    pAttr->Add(bName[i],vVal[i]);
}

// Retrieve the name-value pairs from the collection.

pAttr->get_Count(&cnt);
for (i=0; i<cnt; i++)
{
    pAttr->Item(i, &m_bstrName, &m_varValue);
}

// Remove an attribute by name.

CComVariant m_varNameRemove("File Content: ");
hr = pAttr->Remove(m_varNameRemove);

// Remove an attribute by index.

hr = pAttr->Remove(m_varIndex=0);

// Remove all attributes;

hr = pAttr->RemoveAll();

See Also

  • IWMEncAttributes Interface
  • IWMEncAttributes::Add
  • IWMEncAttributes::get_Count
  • IWMEncAttributes::Remove
  • IWMEncAttributes::RemoveAll


IWMEncAttributes::Remove

The Remove method removes a specific name-value pair from the collection of user-defined attributes.

Syntax

HRESULT Remove(
  VARIANT  var
);

Parameters

var

[in] VARIANT containing either the name or index of the attribute to be removed.

Return Values

If the method succeeds, it returns S_OK. If it fails, it supports an IErrorInfo interface and returns an HRESULT error code.

Return code | Number | Meaning
NS_E_INVALID_INDEX | 0xC00D0011 | The input parameter does not match a valid index in the attributes collection.
NS_E_INVALID_CALL_WHILE_ENCODER_RUNNING | 0xC00D1B66 | You cannot call this method if the encoder engine is running.

Remarks

The attribute to be removed can be specified either by a string name or an index into the attribute collection. Use the IWMEncAttributes::Add method to add an attribute to the collection. Use the IWMEncAttributes::RemoveAll method to delete all attributes from the collection.

Example code

// Include libraries.

#include <windows.h>
#include <comdef.h>                // Includes _bstr_T and _variant_T.
#include <atlbase.h>               // Includes CComBSTR.
#include "wmencode.h"

// Declare variables.

HRESULT hr;
IWMEncoder* pEncoder;
IWMEncAttributes* pAttr;
CComBSTR m_bstrName;
CComVariant m_varValue;
CComVariant m_varIndex;
long cnt;

// Initialize the COM library and retrieve a pointer
// to an IWMEncoder interface.

hr = CoInitialize(NULL);
hr = CoCreateInstance(CLSID_WMEncoder,
                      NULL,
                      CLSCTX_INPROC_SERVER,
                      IID_IWMEncoder,
                      (void**) &pEncoder);

// Retrieve a pointer to an IWMEncAttributes interface.

hr = pEncoder->get_Attributes(&pAttr);

// Add name:value pairs to the attributes collection.

_bstr_t bName[] =
{
    _bstr_t("Date Created: "),
    _bstr_t("Time Created: "),
    _bstr_t("File Content: ")
};
_variant_t vVal[] =
{
    _variant_t("02/15/2000"),
    _variant_t("13:30:15"),
    _variant_t("multimedia data"),
};

for(int i=0;i<3;i++)
{
    pAttr->Add(bName[i],vVal[i]);
}

// Retrieve the name-value pairs from the collection.

pAttr->get_Count(&cnt);
for (i=0; i<cnt; i++)
{
    pAttr->Item(i, &m_bstrName, &m_varValue);
}

// Remove an attribute by name.

CComVariant m_varNameRemove("File Content: ");
hr = pAttr->Remove(m_varNameRemove);

// Remove an attribute by index.

hr = pAttr->Remove(m_varIndex=0);

// Remove all attributes;

hr = pAttr->RemoveAll();

See Also

  • IWMEncAttributes Interface
  • IWMEncAttributes::Add
  • IWMEncAttributes::get_Count
  • IWMEncAttributes::Item
  • IWMEncAttributes::RemoveAll


IWMEncAttributes::RemoveAll

The RemoveAll method removes all attributes from the collection of user-defined attributes.

Syntax

HRESULT RemoveAll();

Parameters

This method takes no parameters.

Return Values

If the method succeeds, it returns S_OK. If it fails, it supports an IErrorInfo interface and returns an HRESULT error code.

Return code | Number | Meaning
NS_E_INVALID_CALL_WHILE_ENCODER_RUNNING | 0xC00D1B66 | You cannot call this method if the encoder engine is running.

Remarks

Use the IWMEncAttributes::Remove method to remove a single attribute from the collection. Use the IWMEncAttributes::Add method to add an attribute to the collection.

Example code

// Include libraries.

#include <windows.h>
#include <comdef.h>                // Includes _bstr_T and _variant_T.
#include <atlbase.h>               // Includes CComBSTR.
#include "wmencode.h"

// Declare variables.

HRESULT hr;
IWMEncoder* pEncoder;
IWMEncAttributes* pAttr;
CComBSTR m_bstrName;
CComVariant m_varValue;
CComVariant m_varIndex;
long cnt;

// Initialize the COM library and retrieve a pointer
// to an IWMEncoder interface.

hr = CoInitialize(NULL);
hr = CoCreateInstance(CLSID_WMEncoder,
                      NULL,
                      CLSCTX_INPROC_SERVER,
                      IID_IWMEncoder,
                      (void**) &pEncoder);

// Retrieve a pointer to an IWMEncAttributes interface.

hr = pEncoder->get_Attributes(&pAttr);

// Add name:value pairs to the attributes collection.

_bstr_t bName[] =
{
    _bstr_t("Date Created: "),
    _bstr_t("Time Created: "),
    _bstr_t("File Content: ")
};
_variant_t vVal[] =
{
    _variant_t("02/15/2000"),
    _variant_t("13:30:15"),
    _variant_t("multimedia data"),
};

for(int i=0;i<3;i++)
{
    pAttr->Add(bName[i],vVal[i]);
}

// Retrieve the name-value pairs from the collection.

pAttr->get_Count(&cnt);
for (i=0; i<cnt; i++)
{
    pAttr->Item(i, &m_bstrName, &m_varValue);
}

// Remove an attribute by name.

CComVariant m_varNameRemove("File Content: ");
hr = pAttr->Remove(m_varNameRemove);

// Remove an attribute by index.

hr = pAttr->Remove(m_varIndex=0);

// Remove all attributes;

hr = pAttr->RemoveAll();

See Also

  • IWMEncAttributes Interface
  • IWMEncAttributes::Add
  • IWMEncAttributes::get_Count
  • IWMEncAttributes::Item
  • IWMEncAttributes::Remove


IWMEncBroadcast Interface

The IWMEncBroadcast interface manages the port number and protocol used for broadcasting encoded content. In addition to the methods inherited from IDispatch, the IWMEncBroadcast interface exposes the following methods.

Method | Description
get_PortNumber | Retrieves the port number used for broadcasting encoded content.
put_PortNumber | Specifies the port number used for broadcasting encoded content.

See Also

  • [Visual Basic] IWMEncBroadcast Object
  • Interfaces (C++)


IWMEncBroadcast::get_PortNumber

The get_PortNumber method retrieves the port number used for broadcasting encoded content.

Syntax

HRESULT get_PortNumber(
  WMENC_BROADCAST_PROTOCOL  enumProtocol,
  short*  piPort
);

Parameters

enumProtocol

[in] short containing the protocol for transmitting encoded content. Currently, this must be the following value.

Value | Number | Meaning
WMENC_PROTOCOL_HTTP | 1 | The transmission uses the HTTP protocol.

piPort

[out] Pointer to a short containing the port number.

Return Values

If the method succeeds, it returns S_OK. If it fails, it returns an HRESULT error code.

Return code | Number | Description
E_POINTER | 0x80004003 | The pointer to the port number is NULL.
E_INVALIDARG | 0x80070057 | The protocol is invalid.

Remarks

Only the HTTP protocol can be used. To specify a port number, use the IWMEncBroadcast::put_PortNumber method.

Example

// Include libraries.

#include <windows.h>
#include "wmencode.h"

// Declare variables.

HRESULT hr;
IWMEncoder* pEncoder;
IWMEncBroadcast* pBrdcst;
short PortNum;

// Initialize the COM library and retrieve a pointer to the
// IWMEncoder interface.
hr = CoInitialize(NULL);

CoCreateInstance(CLSID_WMEncoder,
                 NULL,
                 CLSCTX_INPROC_SERVER,
                 IID_IWMEncoder,
                 (void**) &pEncoder);

// Retrieve a pointer to the IWMEncBroadcast interface.
hr = pEncoder->get_Broadcast(&pBrdcst);

// Retrieve the port number. The port number defaults to zero.
hr = pBrdcst->get_PortNumber(WMENC_PROTOCOL_HTTP, &PortNum);

// Set the port number.
PortNum = 2356;
hr = pBrdcst->put_PortNumber(WMENC_PROTOCOL_HTTP, PortNum);

See Also

  • IWMEncBroadcast Interface
  • IWMEncBroadcast::put_PortNumber


IWMEncBroadcast::put_PortNumber

The put_PortNumber method specifies the port number used for broadcasting encoded content.

Syntax

HRESULT put_PortNumber(
  WMENC_BROADCAST_PROTOCOL  enumProtocol,
  short  iPort
);

Parameters

enumProtocol

[in] Specifies the protocol associated with the port number. This must be the following value.

Value | Number | Meaning
WMENC_PROTOCOL_HTTP | 1 | The transmission uses the HTTP Protocol.

iPort

[in] short containing the port number.

Return Values

If the method succeeds, it returns S_OK. If it fails, it returns an HRESULT error code.

Return code | Number | Description
E_POINTER | 0x80004003 | The address of the variable containing the port number is NULL.
E_INVALIDARG | 0x80070057 | The protocol is not valid.
NS_E_IVALIDCALL_WHILE_ENCODER_RUNNING | 0xC00D1B66 | You cannot call this method if the encoder engine is running.

Remarks

Only the HTTP protocol can be used. The default port number is 80. To retrieve the port number, use the IWMEncBroadcast::get_PortNumber method.

Example

// Declare variables.
HRESULT hr;
IWMEncoder* pEncoder;
IWMEncBroadcast* pBrdcst;
short PortNum;

// Initialize the COM library and retrieve a pointer to the
// IWMEncoder interface.
hr = CoInitialize(NULL);

CoCreateInstance(CLSID_WMEncoder,
                 NULL,
                 CLSCTX_INPROC_SERVER,
                 IID_IWMEncoder,
                 (void**) &pEncoder);

// Retrieve a pointer to the IWMEncBroadcast interface.
hr = pEncoder->get_Broadcast(&pBrdcst);

// Retrieve the port number. The port number defaults to zero.
hr = pBrdcst->get_PortNumber(WMENC_PROTOCOL_HTTP, &PortNum);

// Set the port number.
PortNum = 80;
hr = pBrdcst->put_PortNumber(WMENC_PROTOCOL_HTTP, PortNum);

See Also

  • IWMEncBroadcast::get_PortNumber
  • IWMEncBroadcast Interface


IWMEncDataView Interface

The IWMEncDataView interface controls data view objects. You can use this interface to configure the display settings of the stream, and start or stop the rendering process. This is not an Automation-compliant interface.

The current version of Windows Media Encoder supplies only preview and postview data view objects. A preview object displays a specific multimedia stream before it is compressed. A postview object displays the same stream after compression and decompression. Postviews, therefore, more closely resemble the image rendered in Windows Media Player on a client computer.

All of the data view objects associated with a stream are grouped together in a collection. Thus, there can be multiple collections, each associated with a different stream. Collections are managed by the IWMEncDataViewCollection interface.

In addition to the methods inherited from IUnknown, the IWMEncDataView interface exposes the following methods.

Method | Description
AddStream | Adds a specific multimedia stream to a data view object. This method is reserved for future use.
GetMediaFormat | Retrieves format information for a specific input stream. This method is reserved for future use.
GetViewSetting | Retrieves the display settings of a specific input stream.
RemoveStream | Removes a specific stream from a preview or postview object. This method is reserved for future use.
SetMediaFormat | Specifies the format information for a specific input stream. This method is reserved for future use.
SetViewSetting | Specifies the display settings of a specific input stream.
Start | Starts displaying a specific multimedia stream.
StartAll | Starts displaying all multimedia streams.
Stop | Stops displaying a specific multimedia stream.
StopAll | Stops displaying all multimedia streams.

See Also

  • Interfaces (C++)
  • IWMEncDataViewCollection Interface


IWMEncDataView::AddStream

The AddStream method adds a specific multimedia stream to a data view object.

Syntax

HRESULT AddStream(
  DWORD  dwStreamCookie,
  WM_MEDIA_TYPE*  pType
);

Parameters

dwStreamCookie

[in] DWORD containing the ID of the stream being added.

pType

[in] Pointer to a WM_MEDIA_TYPE structure identifying the stream format.

Return Values

If the method succeeds, it returns S_OK. If it fails, it returns an HRESULT error code.

Remarks

If dwStreamCookie already exists, AddStream updates the WM_Media_Type structure for the input stream.

See Also

  • IWMEncDataView Interface
  • IWMEncDataView::RemoveStream
  • WM_MEDIA_TYPE


IWMEncDataView::GetMediaFormat

The GetMediaFormat method retrieves format information for a specific input stream.

Syntax

HRESULT GetMediaFormat(
  DWORD  dwStreamCookie,
  WM_MEDIA_TYPE**  ppType
);

Parameters

dwStreamCookie

[in] DWORD containing the stream ID.

ppType

[out] Pointer to a pointer to a WM_MEDIA_TYPE structure identifying the stream format.

Return Values

If the method succeeds, it returns S_OK. If it fails, it returns an HRESULT error code.

Remarks

The GetMediaFormat method is used internally by the encoder engine to identify the media type of the input samples.

See Also

  • IWMEncDataView::AddStream
  • IWMEncDataView Interface
  • IWMEncDataView::SetMediaFormat
  • WM_MEDIA_TYPE


IWMEncDataView::GetViewSetting

The GetViewSetting method retrieves the display settings of a specific input stream. This method is reserved for future use.

Syntax

HRESULT GetViewSetting(
  DWORD  dwStreamCookie,
  DWORD*  pdwSize,
  byte*  pData
);

Parameters

dwStreamCookie

[in] DWORD containing the stream ID.

pdwSize

[in] Pointer to a DWORD containing the size of the information to which the pData parameter points. This must equal the size of an HWND data type.

pData

[in] Pointer to the data used to specify the display settings. This parameter must point to a window handle (HWND).

Return Values

If the method succeeds, it returns S_OK. If it fails, it returns an HRESULT error code.

See Also

  • IWMEncDataView Interface
  • IWMEncDataView::SetViewSetting


IWMEncDataView::RemoveStream

The RemoveStream method removes a specific stream from a preview or postview object.

Syntax

HRESULT RemoveStream(
  DWORD  dwStreamCookie
);

Parameters

dwStreamCookie

[in] DWORD containing the ID of the stream being removed.

Return Values

If the method succeeds, it returns S_OK. If it fails, it returns an HRESULT error code.

Remarks

The RemoveStream method is used internally by the encoder engine.

See Also

  • IWMEncDataView::AddStream
  • IWMEncDataView Interface


IWMEncDataView::SetMediaFormat

The SetMediaFormat method specifies the format information for a specific input stream. This method is reserved for future use.

Syntax

HRESULT SetMediaFormat(
  DWORD  dwStreamCookie,
  WM_MEDIA_TYPE*  pType
);

Parameters

dwStreamCookie

[in] DWORD containing the stream ID.

pType

[in] Pointer to a WM_MEDIA_TYPE structure identifying the stream format.

Return Values

If the method succeeds, it returns S_OK. If it fails, it returns an HRESULT error code.

Remarks

The SetMediaFormat method is used internally by the encoder engine.

See Also

  • IWMEncDataView::GetMediaFormat
  • IWMEncDataView Interface
  • WM_MEDIA_TYPE


IWMEncDataView::SetViewSetting

The SetViewSetting method specifies the display settings of an input stream.

Syntax

HRESULT SetViewSetting(
  DWORD  dwStreamCookie,
  DWORD  dwSize,
  byte*  pData
);

Parameters

dwStreamCookie

[in] DWORD containing the stream ID.

dwSize

[in] DWORD containing the size, in bytes, of the information stored in the pData parameter. This must equal the size of an HWND data type.

pData

[in] Pointer to the data used to specify the display settings. This parameter must point to a window handle (HWND).

Return Values

If the method succeeds, it returns S_OK. If it fails, it returns an HRESULT error code.

Example Code

// Include libraries.

#include <windows.h>
#include <atlbase.h>
#include "wmencode.h"
#include "wmencvu.h"

// Declare variables.

    HRESULT hr;
    IWMEncoder* pEncoder;
    IWMEncDataView* pPreview;
    IWMEncDataViewCollection* pPreviewColl;
    IWMEncSourceGroupCollection* pSrcGrpColl;
    IWMEncSourceGroup* pSrcGrp;
    IWMEncSource* pAudSrc;
    IWMEncSource* pVidSrc;
    IWMEncProfileCollection* pProColl;
    IWMEncProfile* pPro;

    long lCount;
    int i;

// Initialize the COM library and retrieve a pointer
// to an IWMEncoder interface.

    hr = CoInitialize(NULL);
    CoCreateInstance(CLSID_WMEncoder,
                     NULL,
                     CLSCTX_INPROC_SERVER,
                     IID_IWMEncoder,
                     (void**) &pEncoder);

// Retrieve a pointer to an IWMEncSourceGroupCollection
// interface.

    hr = pEncoder->get_SourceGroupCollection(&pSrcGrpColl);

// Add a source group to the collection.

    hr = pSrcGrpColl->Add(L"SG_1", &pSrcGrp);

// Add a video and audio source to the source group.

    hr = pSrcGrp->AddSource(WMENC_VIDEO, &pVidSrc);
    hr = pSrcGrp->AddSource(WMENC_AUDIO, &pAudSrc);

// Identify the capture cards.

    hr = pVidSrc->SetInput(L"DEVICE://Default_Video_Device");
    hr = pAudSrc->SetInput(L"DEVICE://Default_Audio_Device");

// Choose a profile from the collection.

    CComBSTR bstrName = NULL;
    CComVariant varProfile;
    varProfile.vt = VT_DISPATCH;
    hr = pEncoder->get_ProfileCollection(&pProColl);
    hr = pProColl->get_Count(&lCount);
    for (i=0; i<lCount; i++)
    {
        hr = pProColl->Item(i, &pPro);
        hr = pPro->get_Name(&bstrName);
        if (_wcsicmp(bstrName,L"profile name")==0)
        {
            // Set the profile in the source group.
            varProfile.pdispVal = pPro;
            hr = pSrcGrp->put_Profile(varProfile);
            break;
        }
    }

// Retrieve a pointer to a preview object.

    hr = CoCreateInstance( CLSID_WMEncPreview,
                           NULL,
                           CLSCTX_INPROC_SERVER,
                           IID_IWMEncDataView,
                           (void**)&pPreview);

// Retrieve the preview collection.

    hr = pVidSrc->get_PreviewCollection( &pPreviewColl );

// Add the preview object to the data view collection. If you set the
// cookie to -1, the encoder engine automatically generates a unique
// cookie.

    long lCookie = -1;
    hr = pPreviewColl->Add( pPreview, &lCookie);

// Continue configuring the encoder engine.

// Initialize the encoder engine.

    hr = pEncoder->PrepareToEncode(VARIANT_TRUE);

// Create a parent window for the preview object, and specify the window
// settings for the encoder engine. For instance, you can create a
// window by using the Win32 API function CreateWindow() and pass the
// window handle retrieved from this function to the
// SetViewSetting() method.
// Windows Media Encoder embeds the preview window in the parent window.
// If you do not create a parent window and specify the display
// settings, Windows Media Encoder creates a default window for the
// preview.

    HWND hWnd;
    hr = pPreview->SetViewSetting((DWORD) lCookie,
                                   sizeof(hWnd),
                                  (BYTE*)&hWnd);

// Start the encoder engine.

    hr = pEncoder->Start();

// Start viewing the stream in a pop-up window.

    hr = pPreview->Start(lCookie);

// When finished, stop the preview.

    hr = pPreview->Stop(lCookie);

// Stop the encoder engine.

    hr = pEncoder->Stop();

See Also

  • IWMEncDataView Interface


IWMEncDataView::Start

The Start method starts displaying a specific multimedia stream.

Syntax

HRESULT Start(
  DWORD  dwStreamCookie
);

Parameters

dwStreamCookie

[in] DWORD containing the ID of the stream to be displayed.

Return Values

If the method succeeds, it returns S_OK. If it fails, it returns an HRESULT error code.

Example Code

// Include libraries.

#include <windows.h>
#include <atlbase.h>
#include "wmencode.h"
#include "wmencvu.h"

// Declare variables.

    HRESULT hr;
    IWMEncoder* pEncoder;
    IWMEncDataView* pPreview;
    IWMEncDataViewCollection* pPreviewColl;
    IWMEncSourceGroupCollection* pSrcGrpColl;
    IWMEncSourceGroup* pSrcGrp;
    IWMEncSource* pAudSrc;
    IWMEncSource* pVidSrc;
    IWMEncProfileCollection* pProColl;
    IWMEncProfile* pPro;

    long lCount;
    int i;

// Initialize the COM library and retrieve a pointer
// to an IWMEncoder interface.

    hr = CoInitialize(NULL);
    CoCreateInstance(CLSID_WMEncoder,
                     NULL,
                     CLSCTX_INPROC_SERVER,
                     IID_IWMEncoder,
                     (void**) &pEncoder);

// Retrieve a pointer to an IWMEncSourceGroupCollection
// interface.

    hr = pEncoder->get_SourceGroupCollection(&pSrcGrpColl);

// Add a source group to the collection.

    hr = pSrcGrpColl->Add(L"SG_1", &pSrcGrp);

// Add a video and audio source to the source group.

    hr = pSrcGrp->AddSource(WMENC_VIDEO, &pVidSrc);
    hr = pSrcGrp->AddSource(WMENC_AUDIO, &pAudSrc);

// Identify the capture cards.

    hr = pVidSrc->SetInput(L"DEVICE://Default_Video_Device");
    hr = pAudSrc->SetInput(L"DEVICE://Default_Audio_Device");

// Choose a profile from the collection.

    CComBSTR bstrName = NULL;
    CComVariant varProfile;
    varProfile.vt = VT_DISPATCH;
    hr = pEncoder->get_ProfileCollection(&pProColl);
    hr = pProColl->get_Count(&lCount);
    for (i=0; i<lCount; i++)
    {
        hr = pProColl->Item(i, &pPro);
        hr = pPro->get_Name(&bstrName);
        if (_wcsicmp(bstrName,L"profile name")==0)
        {
            // Set the profile in the source group.
            varProfile.pdispVal = pPro;
            hr = pSrcGrp->put_Profile(varProfile);
            break;
        }
    }

// Retrieve a pointer to a preview object.

    hr = CoCreateInstance( CLSID_WMEncPreview,
                           NULL,
                           CLSCTX_INPROC_SERVER,
                           IID_IWMEncDataView,
                           (void**)&pPreview);

// Retrieve the preview collection.

    hr = pVidSrc->get_PreviewCollection( &pPreviewColl );

// Add the preview object to the data view collection. If you set the
// cookie to -1, the encoder engine automatically generates a unique
// cookie.

    long lCookie = -1;
    hr = pPreviewColl->Add( pPreview, &lCookie);

// Continue configuring the encoder engine.

// Initialize the encoder engine.

    hr = pEncoder->PrepareToEncode(VARIANT_TRUE);

// Create a parent window for the preview object, and specify the window
// settings for the encoder engine. For instance, you can create a
// window by using the Win32 API function CreateWindow() and pass the
// window handle retrieved from this function to the
// SetViewSetting() method.
// Windows Media Encoder embeds the preview window in the parent window.
// If you do not create a parent window and specify the display
// settings, Windows Media Encoder creates a default window for the
// preview.

    HWND hWnd;
    hr = pPreview->SetViewSetting((DWORD) lCookie,
                                   sizeof(hWnd),
                                  (BYTE*)&hWnd);

// Start the encoder engine.

    hr = pEncoder->Start();

// Start viewing the stream in a pop-up window.

    hr = pPreview->Start(lCookie);

// When finished, stop the preview.

    hr = pPreview->Stop(lCookie);

// Stop the encoder engine.

    hr = pEncoder->Stop();

See Also

  • IWMEncDataView Interface
  • IWMEncDataView::Stop


IWMEncDataView::StartAll

The StartAll method starts displaying all multimedia streams.

Syntax

HRESULT StartAll();

Parameters

This method takes no parameters.

Return Values

If the method succeeds, it returns S_OK. If it fails, it returns an HRESULT error code.

Remarks

In the current release of Windows Media Encoder, the StartAll method performs the same action as the IWMEncDataView::Start method. Only one stream can be previewed at a time.

Example Code

// Include libraries.

#include <windows.h>
#include <atlbase.h>
#include "wmencode.h"
#include "wmencvu.h"

// Declare variables.

    HRESULT hr;
    IWMEncoder* pEncoder;
    IWMEncDataView* pPreview;
    IWMEncDataViewCollection* pPreviewColl;
    IWMEncSourceGroupCollection* pSrcGrpColl;
    IWMEncSourceGroup* pSrcGrp;
    IWMEncSource* pAudSrc;
    IWMEncSource* pVidSrc;
    IWMEncProfileCollection* pProColl;
    IWMEncProfile* pPro;

    long lCount;
    int i;

// Initialize the COM library and retrieve a pointer
// to an IWMEncoder interface.

    hr = CoInitialize(NULL);
    CoCreateInstance(CLSID_WMEncoder,
                     NULL,
                     CLSCTX_INPROC_SERVER,
                     IID_IWMEncoder,
                     (void**) &pEncoder);

// Retrieve a pointer to an IWMEncSourceGroupCollection
// interface.

    hr = pEncoder->get_SourceGroupCollection(&pSrcGrpColl);

// Add a source group to the collection.

    hr = pSrcGrpColl->Add(L"SG_1", &pSrcGrp);

// Add a video and audio source to the source group.

    hr = pSrcGrp->AddSource(WMENC_VIDEO, &pVidSrc);
    hr = pSrcGrp->AddSource(WMENC_AUDIO, &pAudSrc);

// Identify the capture cards.

    hr = pVidSrc->SetInput(L"DEVICE://Default_Video_Device");
    hr = pAudSrc->SetInput(L"DEVICE://Default_Audio_Device");

// Choose a profile from the collection.

    CComBSTR bstrName = NULL;
    CComVariant varProfile;
    varProfile.vt = VT_DISPATCH;
    hr = pEncoder->get_ProfileCollection(&pProColl);
    hr = pProColl->get_Count(&lCount);
    for (i=0; i<lCount; i++)
    {
        hr = pProColl->Item(i, &pPro);
        hr = pPro->get_Name(&bstrName);
        if (_wcsicmp(bstrName,L"profile name")==0)
        {
            // Set the profile in the source group.
            varProfile.pdispVal = pPro;
            hr = pSrcGrp->put_Profile(varProfile);
            break;
        }
    }

// Retrieve a pointer to a preview object.

    hr = CoCreateInstance( CLSID_WMEncPreview,
                           NULL,
                           CLSCTX_INPROC_SERVER,
                           IID_IWMEncDataView,
                           (void**)&pPreview);

// Retrieve the preview collection.

    hr = pVidSrc->get_PreviewCollection( &pPreviewColl );

// Add the preview object to the data view collection. If you set the
// cookie to -1, the encoder engine automatically generates a unique
// cookie.

    long lCookie = -1;
    hr = pPreviewColl->Add( pPreview, &lCookie);

// Continue configuring the encoder engine.

// Initialize the encoder engine.

    hr = pEncoder->PrepareToEncode(VARIANT_TRUE);

// Create a parent window for the preview object, and specify the window
// settings for the encoder engine. For instance, you can create a
// window by using the Win32 API function CreateWindow() and pass the
// window handle retrieved from this function to the
// SetViewSetting() method.
// Windows Media Encoder embeds the preview window in the parent window.
// If you do not create a parent window and specify the display
// settings, Windows Media Encoder creates a default window for the
// preview.

    HWND hWnd;
    hr = pPreview->SetViewSetting((DWORD) lCookie,
                                   sizeof(hWnd),
                                  (BYTE*)&hWnd);

// Start the encoder engine.

    hr = pEncoder->Start();

// Start viewing the stream in a pop-up window.

    hr = pPreview->Start(lCookie);

// When finished, stop the preview.

    hr = pPreview->Stop(lCookie);

// Stop the encoder engine.

    hr = pEncoder->Stop();

See Also

  • IWMEncDataView Interface
  • IWMEncDataView::Start
  • IWMEncDataView::StopAll


IWMEncDataView::Stop

The Stop method stops displaying a specific media stream.

Syntax

HRESULT Stop(
  DWORD  dwStreamCookie
);

Parameters

dwStreamCookie

[in] DWORD containing the ID of the stream.

Return Values

If the method succeeds, it returns S_OK. If it fails, it returns an HRESULT error code.

Example Code

// Include libraries.

#include <windows.h>
#include <atlbase.h>
#include "wmencode.h"
#include "wmencvu.h"

// Declare variables.

    HRESULT hr;
    IWMEncoder* pEncoder;
    IWMEncDataView* pPreview;
    IWMEncDataViewCollection* pPreviewColl;
    IWMEncSourceGroupCollection* pSrcGrpColl;
    IWMEncSourceGroup* pSrcGrp;
    IWMEncSource* pAudSrc;
    IWMEncSource* pVidSrc;
    IWMEncProfileCollection* pProColl;
    IWMEncProfile* pPro;

    long lCount;
    int i;

// Initialize the COM library and retrieve a pointer
// to an IWMEncoder interface.

    hr = CoInitialize(NULL);
    CoCreateInstance(CLSID_WMEncoder,
                     NULL,
                     CLSCTX_INPROC_SERVER,
                     IID_IWMEncoder,
                     (void**) &pEncoder);

// Retrieve a pointer to an IWMEncSourceGroupCollection
// interface.

    hr = pEncoder->get_SourceGroupCollection(&pSrcGrpColl);

// Add a source group to the collection.

    hr = pSrcGrpColl->Add(L"SG_1", &pSrcGrp);

// Add a video and audio source to the source group.

    hr = pSrcGrp->AddSource(WMENC_VIDEO, &pVidSrc);
    hr = pSrcGrp->AddSource(WMENC_AUDIO, &pAudSrc);

// Identify the capture cards.

    hr = pVidSrc->SetInput(L"DEVICE://Default_Video_Device");
    hr = pAudSrc->SetInput(L"DEVICE://Default_Audio_Device");

// Choose a profile from the collection.

    CComBSTR bstrName = NULL;
    CComVariant varProfile;
    varProfile.vt = VT_DISPATCH;
    hr = pEncoder->get_ProfileCollection(&pProColl);
    hr = pProColl->get_Count(&lCount);
    for (i=0; i<lCount; i++)
    {
        hr = pProColl->Item(i, &pPro);
        hr = pPro->get_Name(&bstrName);
        if (_wcsicmp(bstrName,L"profile name")==0)
        {
            // Set the profile in the source group.
            varProfile.pdispVal = pPro;
            hr = pSrcGrp->put_Profile(varProfile);
            break;
        }
    }

// Retrieve a pointer to a preview object.

    hr = CoCreateInstance( CLSID_WMEncPreview,
                           NULL,
                           CLSCTX_INPROC_SERVER,
                           IID_IWMEncDataView,
                           (void**)&pPreview);

// Retrieve the preview collection.

    hr = pVidSrc->get_PreviewCollection( &pPreviewColl );

// Add the preview object to the data view collection. If you set the
// cookie to -1, the encoder engine automatically generates a unique
// cookie.

    long lCookie = -1;
    hr = pPreviewColl->Add( pPreview, &lCookie);

// Continue configuring the encoder engine.

// Initialize the encoder engine.

    hr = pEncoder->PrepareToEncode(VARIANT_TRUE);

// Create a parent window for the preview object, and specify the window
// settings for the encoder engine. For instance, you can create a
// window by using the Win32 API function CreateWindow() and pass the
// window handle retrieved from this function to the
// SetViewSetting() method.
// Windows Media Encoder embeds the preview window in the parent window.
// If you do not create a parent window and specify the display
// settings, Windows Media Encoder creates a default window for the
// preview.

    HWND hWnd;
    hr = pPreview->SetViewSetting((DWORD) lCookie,
                                   sizeof(hWnd),
                                  (BYTE*)&hWnd);

// Start the encoder engine.

    hr = pEncoder->Start();

// Start viewing the stream in a pop-up window.

    hr = pPreview->Start(lCookie);

// When finished, stop the preview.

    hr = pPreview->Stop(lCookie);

// Stop the encoder engine.

    hr = pEncoder->Stop();

See Also

  • IWMEncDataView Interface
  • IWMEncDataView::Start


IWMEncDataView::StopAll

The StopAll method stops displaying all multimedia streams.

Syntax

HRESULT StopAll();

Parameters

This method takes no parameters.

Return Values

If the method succeeds, it returns S_OK. If it fails, it returns an HRESULT error code.

Remarks

In the current release of Windows Media Encoder, the StopAll method performs the same action as the IWMEncDataView::Stop method. Only one stream can be previewed at a time.

Example Code

// Include libraries.

#include <windows.h>
#include <atlbase.h>
#include "wmencode.h"
#include "wmencvu.h"

// Declare variables.

    HRESULT hr;
    IWMEncoder* pEncoder;
    IWMEncDataView* pPreview;
    IWMEncDataViewCollection* pPreviewColl;
    IWMEncSourceGroupCollection* pSrcGrpColl;
    IWMEncSourceGroup* pSrcGrp;
    IWMEncSource* pAudSrc;
    IWMEncSource* pVidSrc;
    IWMEncProfileCollection* pProColl;
    IWMEncProfile* pPro;

    long lCount;
    int i;

// Initialize the COM library and retrieve a pointer
// to an IWMEncoder interface.

    hr = CoInitialize(NULL);
    CoCreateInstance(CLSID_WMEncoder,
                     NULL,
                     CLSCTX_INPROC_SERVER,
                     IID_IWMEncoder,
                     (void**) &pEncoder);

// Retrieve a pointer to an IWMEncSourceGroupCollection
// interface.

    hr = pEncoder->get_SourceGroupCollection(&pSrcGrpColl);

// Add a source group to the collection.

    hr = pSrcGrpColl->Add(L"SG_1", &pSrcGrp);

// Add a video and audio source to the source group.

    hr = pSrcGrp->AddSource(WMENC_VIDEO, &pVidSrc);
    hr = pSrcGrp->AddSource(WMENC_AUDIO, &pAudSrc);

// Identify the capture cards.

    hr = pVidSrc->SetInput(L"DEVICE://Default_Video_Device");
    hr = pAudSrc->SetInput(L"DEVICE://Default_Audio_Device");

// Choose a profile from the collection.

    CComBSTR bstrName = NULL;
    CComVariant varProfile;
    varProfile.vt = VT_DISPATCH;
    hr = pEncoder->get_ProfileCollection(&pProColl);
    hr = pProColl->get_Count(&lCount);
    for (i=0; i<lCount; i++)
    {
        hr = pProColl->Item(i, &pPro);
        hr = pPro->get_Name(&bstrName);
        if (_wcsicmp(bstrName,L"profile name")==0)
        {
            // Set the profile in the source group.
            varProfile.pdispVal = pPro;
            hr = pSrcGrp->put_Profile(varProfile);
            break;
        }
    }

// Retrieve a pointer to a preview object.

    hr = CoCreateInstance( CLSID_WMEncPreview,
                           NULL,
                           CLSCTX_INPROC_SERVER,
                           IID_IWMEncDataView,
                           (void**)&pPreview);

// Retrieve the preview collection.

    hr = pVidSrc->get_PreviewCollection( &pPreviewColl );

// Add the preview object to the data view collection. If you set the
// cookie to -1, the encoder engine automatically generates a unique
// cookie.

    long lCookie = -1;
    hr = pPreviewColl->Add( pPreview, &lCookie);

// Continue configuring the encoder engine.

// Initialize the encoder engine.

    hr = pEncoder->PrepareToEncode(VARIANT_TRUE);

// Create a parent window for the preview object, and specify the window
// settings for the encoder engine. For instance, you can create a
// window by using the Win32 API function CreateWindow() and pass the
// window handle retrieved from this function to the
// SetViewSetting() method.
// Windows Media Encoder embeds the preview window in the parent window.
// If you do not create a parent window and specify the display
// settings, Windows Media Encoder creates a default window for the
// preview.

    HWND hWnd;
    hr = pPreview->SetViewSetting((DWORD) lCookie,
                                   sizeof(hWnd),
                                  (BYTE*)&hWnd);

// Start the encoder engine.

    hr = pEncoder->Start();

// Start viewing the stream in a pop-up window.

    hr = pPreview->Start(lCookie);

// When finished, stop the preview.

    hr = pPreview->Stop(lCookie);

// Stop the encoder engine.

    hr = pEncoder->Stop();

See Also

  • IWMEncDataView Interface
  • IWMEncDataView::StartAll
  • IWMEncDataView::Stop


IWMEncDataViewCollection Interface

The IWMEncDataViewCollection interface contains a collection of data view objects used by Windows Media Encoder to display multimedia content. The most common examples are preview and postview objects. A preview object displays a specific multimedia stream before it is compressed. A postview object displays the same stream after compression and decompression. Postviews, therefore, more closely resemble the image rendered in Windows Media Player on a client computer.

A single data view object is generally associated with only one source stream in one source group but can be shared by multiple sources. For example, you can render both a live presentation and a bitmap intermission slide in the same video window by sharing a data view object between the two sources.

You can add multiple data view objects to a single source. For instance, one object might simply render a video or audio stream, and another object might use periods of inactivity in the encoded stream to send an e-mail message.

All of the data view objects associated with a stream are grouped together in a collection. Multiple collections exist if multiple streams are associated with data view objects. A data view collection is acquired from the IWMEncSource interface.

In addition to the methods inherited from IDispatch, the IWMEncDataViewCollection interface exposes the following methods.

Method | Description
Add | Adds an IWMEncDataView object to the collection.
get_Count | Retrieves the number of IWMEncDataView objects in the collection.
get_length | Retrieves the number of IWMEncDataView objects in the collection.
Item | Retrieves a specific IWMEncDataView object from the collection.
Remove | Removes a specific IWMEncDataView object from the collection.
RemoveAll | Removes all IWMEncDataView objects from the collection.

See Also

  • [Visual Basic] IWMEncDataViewCollection Object
  • Interfaces (C++)
  • IWMEncDataView Interface
  • IWMEncSource Interface
  • Windows Media Encoder SDK Interfaces


IWMEncDataViewCollection::Add

The Add method adds an IWMEncDataView object to the collection.

Syntax

HRESULT Add(
  IUnknown*  pDataView,
  long*  plStreamCookie
);

Parameters

pDataView

[in] IUnknown pointer to an IWMEncDataView object.

plStreamCookie

[in, out] Pointer to a long containing the ID of the stream associated with the data view.

Return Values

If the method succeeds, it returns S_OK. If it fails, it supports an IErrorInfo interface and returns an HRESULT error code.

Return code | Number | Description
E_FAIL | 0x80004005 | An error occurred.
E_INVALIDARG | 0x80070057 | A parameter is not valid.
E_OUTOFMEMORY | 0x8007000E | Memory cannot be allocated.
E_POINTER | 0x80004003 | The pointer to the data view object, or the pointer to the stream cookie, or both is NULL.
NS_E_INVALIDCALL_WHILE_ENCODER_RUNNING | 0xC00D1B66 | This method cannot be called if the encoder engine is running.

Remarks

Set plStreamCookie to -1 if the input stream is being associated with a data view object for the first time. The Add method produces a unique cookie for the stream. If plStreamCookie is not -1, the stream shares the preview or postview object with any stream whose ID is plStreamCookie.

Example Code

// Include libraries.

#include <windows.h>
#include <atlbase.h>
#include "wmencode.h"
#include "wmencvu.h"

// Declare variables.

    HRESULT hr;
    IWMEncoder* pEncoder;
    IUnknown* pPreview;
    IWMEncDataView* pPreview_1;
    IWMEncDataView* pPreview_2;
    IWMEncDataView* pPreview_3;
    IWMEncDataViewCollection* pPreviewColl;
    IWMEncSourceGroupCollection* pSrcGrpColl;
    IWMEncSourceGroup* pSrcGrp;
    IWMEncSource* pAudSrc;
    IWMEncSource* pVidSrc;

    long lCount, lCookie, i, lDataViewIndex;

// Initialize the COM library and retrieve a pointer
// to an IWMEncoder interface.

    hr = CoInitialize(NULL);
    CoCreateInstance(CLSID_WMEncoder,
                     NULL,
                     CLSCTX_INPROC_SERVER,
                     IID_IWMEncoder,
                     (void**) &pEncoder);

// Retrieve a pointer to an IWMEncSourceGroupCollection
// interface.

    hr = pEncoder->get_SourceGroupCollection(&pSrcGrpColl);

// Add a source group to the collection.

    hr = pSrcGrpColl->Add(L"SG_1", &pSrcGrp);

// Add a video and audio source to the source group.

    hr = pSrcGrp->AddSource(WMENC_VIDEO, &pVidSrc);
    hr = pSrcGrp->AddSource(WMENC_AUDIO, &pAudSrc);

// Create three preview objects and return pointers.

    hr = CoCreateInstance( CLSID_WMEncPreview,
                           NULL,
                           CLSCTX_INPROC_SERVER,
                           IID_IWMEncDataView,
                           (void**)&pPreview_1);

    hr = CoCreateInstance( CLSID_WMEncPreview,
                           NULL,
                           CLSCTX_INPROC_SERVER,
                           IID_IWMEncDataView,
                           (void**)&pPreview_2);

    hr = CoCreateInstance( CLSID_WMEncPreview,
                           NULL,
                           CLSCTX_INPROC_SERVER,
                           IID_IWMEncDataView,
                           (void**)&pPreview_3);

// Retrieve the preview collection.

    hr = pVidSrc->get_PreviewCollection( &pPreviewColl );

// Add the preview objects to the data view collection. If you set the
// cookie to -1, the encoder engine automatically generates a unique
// cookie.

    long lCookie_1 = -1;
    hr = pPreviewColl->Add( pPreview_1, &lCookie_1);

    long lCookie_2 = -1;
    hr = pPreviewColl->Add( pPreview_2, &lCookie_2);

    long lCookie_3 = -1;
    hr = pPreviewColl->Add( pPreview_3, &lCookie_3);

// Retrieve the cookies for each preview.

    hr = pPreviewColl->get_Count(&lCount);
    for (i=0; i<lCount; i++)
    {
        hr = pPreviewColl->Item(i, &pPreview, &lCookie);
    }

// Remove the second preview object from the collection.
// The index is zero-based.

    lDataViewIndex = 1;
    hr = pPreviewColl->Remove(lDataViewIndex);

// Remove the remaining cookies from the collection.

    hr = pPreviewColl->RemoveAll();

See Also

  • IWMEncDataView Interface
  • IWMEncDataViewCollection Interface
  • IWMEncDataViewCollection::Remove


IWMEncDataViewCollection::get_Count

The get_Count method retrieves the number of IWMEncDataView objects in the collection.

Syntax

HRESULT get_Count(
  long*  plCount
);

Parameters

plCount

[out] Pointer to a long containing the number of objects.

Return Values

If the method succeeds, it returns S_OK. If it fails, it supports an IErrorInfo interface and returns an HRESULT error code.

Return code | Number | Description
E_POINTER | 0x80004003 | The pointer to the data view object count is NULL.

Example Code

// Include libraries.

#include <windows.h>
#include <atlbase.h>
#include "wmencode.h"
#include "wmencvu.h"

// Declare variables.

    HRESULT hr;
    IWMEncoder* pEncoder;
    IUnknown* pPreview;
    IWMEncDataView* pPreview_1;
    IWMEncDataView* pPreview_2;
    IWMEncDataView* pPreview_3;
    IWMEncDataViewCollection* pPreviewColl;
    IWMEncSourceGroupCollection* pSrcGrpColl;
    IWMEncSourceGroup* pSrcGrp;
    IWMEncSource* pAudSrc;
    IWMEncSource* pVidSrc;

    long lCount, lCookie, i, lDataViewIndex;

// Initialize the COM library and retrieve a pointer
// to an IWMEncoder interface.

    hr = CoInitialize(NULL);
    CoCreateInstance(CLSID_WMEncoder,
                     NULL,
                     CLSCTX_INPROC_SERVER,
                     IID_IWMEncoder,
                     (void**) &pEncoder);

// Retrieve a pointer to an IWMEncSourceGroupCollection
// interface.

    hr = pEncoder->get_SourceGroupCollection(&pSrcGrpColl);

// Add a source group to the collection.

    hr = pSrcGrpColl->Add(L"SG_1", &pSrcGrp);

// Add a video and audio source to the source group.

    hr = pSrcGrp->AddSource(WMENC_VIDEO, &pVidSrc);
    hr = pSrcGrp->AddSource(WMENC_AUDIO, &pAudSrc);

// Create three preview objects and return pointers.

    hr = CoCreateInstance( CLSID_WMEncPreview,
                           NULL,
                           CLSCTX_INPROC_SERVER,
                           IID_IWMEncDataView,
                           (void**)&pPreview_1);

    hr = CoCreateInstance( CLSID_WMEncPreview,
                           NULL,
                           CLSCTX_INPROC_SERVER,
                           IID_IWMEncDataView,
                           (void**)&pPreview_2);

    hr = CoCreateInstance( CLSID_WMEncPreview,
                           NULL,
                           CLSCTX_INPROC_SERVER,
                           IID_IWMEncDataView,
                           (void**)&pPreview_3);

// Retrieve the preview collection.

    hr = pVidSrc->get_PreviewCollection( &pPreviewColl );

// Add the preview objects to the data view collection. If you set the
// cookie to -1, the encoder engine automatically generates a unique
// cookie.

    long lCookie_1 = -1;
    hr = pPreviewColl->Add( pPreview_1, &lCookie_1);

    long lCookie_2 = -1;
    hr = pPreviewColl->Add( pPreview_2, &lCookie_2);

    long lCookie_3 = -1;
    hr = pPreviewColl->Add( pPreview_3, &lCookie_3);

// Retrieve the cookies for each preview.

    hr = pPreviewColl->get_Count(&lCount);
    for (i=0; i<lCount; i++)
    {
        hr = pPreviewColl->Item(i, &pPreview, &lCookie);
    }

// Remove the second preview object from the collection.
// The index is zero-based.

    lDataViewIndex = 1;
    hr = pPreviewColl->Remove(lDataViewIndex);

// Remove the remaining cookies from the collection.

    hr = pPreviewColl->RemoveAll();

See Also

  • IWMEncDataView Interface
  • IWMEncDataViewCollection Interface


IWMEncDataViewCollection::get_length

The get_length method retrieves the number of IWMEncDataView objects in the collection.

Syntax

HRESULT get_length(
  long*  plCount
);

Parameters

plCount

[out] Pointer to a long containing the number of objects in the collection.

Return Values

If the method succeeds, it returns S_OK. If it fails, it supports an IErrorInfo interface and returns an HRESULT error code.

Return code | Number | Description
E_POINTER | 0x80004003 | The pointer to the data view object count is NULL.

Remarks

This is the JScript version of the get_Count method. It is included for developers more comfortable with JScript syntax.

Example Code

// Include libraries.

#include <windows.h>
#include <atlbase.h>
#include "wmencode.h"
#include "wmencvu.h"

// Declare variables.

    HRESULT hr;
    IWMEncoder* pEncoder;
    IUnknown* pPreview;
    IWMEncDataView* pPreview_1;
    IWMEncDataView* pPreview_2;
    IWMEncDataView* pPreview_3;
    IWMEncDataViewCollection* pPreviewColl;
    IWMEncSourceGroupCollection* pSrcGrpColl;
    IWMEncSourceGroup* pSrcGrp;
    IWMEncSource* pAudSrc;
    IWMEncSource* pVidSrc;

    long lCount, lCookie, i, lDataViewIndex;

// Initialize the COM library and retrieve a pointer
// to an IWMEncoder interface.

    hr = CoInitialize(NULL);
    CoCreateInstance(CLSID_WMEncoder,
                     NULL,
                     CLSCTX_INPROC_SERVER,
                     IID_IWMEncoder,
                     (void**) &pEncoder);

// Retrieve a pointer to an IWMEncSourceGroupCollection
// interface.

    hr = pEncoder->get_SourceGroupCollection(&pSrcGrpColl);

// Add a source group to the collection.

    hr = pSrcGrpColl->Add(L"SG_1", &pSrcGrp);

// Add a video and audio source to the source group.

    hr = pSrcGrp->AddSource(WMENC_VIDEO, &pVidSrc);
    hr = pSrcGrp->AddSource(WMENC_AUDIO, &pAudSrc);

// Create three preview objects and return pointers.

    hr = CoCreateInstance( CLSID_WMEncPreview,
                           NULL,
                           CLSCTX_INPROC_SERVER,
                           IID_IWMEncDataView,
                           (void**)&pPreview_1);

    hr = CoCreateInstance( CLSID_WMEncPreview,
                           NULL,
                           CLSCTX_INPROC_SERVER,
                           IID_IWMEncDataView,
                           (void**)&pPreview_2);

    hr = CoCreateInstance( CLSID_WMEncPreview,
                           NULL,
                           CLSCTX_INPROC_SERVER,
                           IID_IWMEncDataView,
                           (void**)&pPreview_3);

// Retrieve the preview collection.

    hr = pVidSrc->get_PreviewCollection( &pPreviewColl );

// Add the preview objects to the data view collection. If you set the
// cookie to -1, the encoder engine automatically generates a unique
// cookie.

    long lCookie_1 = -1;
    hr = pPreviewColl->Add( pPreview_1, &lCookie_1);

    long lCookie_2 = -1;
    hr = pPreviewColl->Add( pPreview_2, &lCookie_2);

    long lCookie_3 = -1;
    hr = pPreviewColl->Add( pPreview_3, &lCookie_3);

// Retrieve the cookies for each preview.

    hr = pPreviewColl->get_Count(&lCount);
    for (i=0; i<lCount; i++)
    {
        hr = pPreviewColl->Item(i, &pPreview, &lCookie);
    }

// Remove the second preview object from the collection.
// The index is zero-based.

    lDataViewIndex = 1;
    hr = pPreviewColl->Remove(lDataViewIndex);

// Remove the remaining cookies from the collection.

    hr = pPreviewColl->RemoveAll();

See Also

  • IWMEncDataView Interface
  • IWMEncDataViewCollection Interface


IWMEncDataViewCollection::Item

The Item method retrieves a specific IWMEncDataView object from the collection.

Syntax

HRESULT Item(
  long  lIndex,
  IUnknown**  ppDataView,
  long*  plStreamCookie
);

Parameters

lIndex

[in] long containing the index of the object in the collection.

ppDataView

[out] Pointer to a pointer to a preview or postview object.

plStreamCookie

[out] Pointer to a long containing the ID of the stream associated with the IWMEncDataView object.

Return Values

If the method succeeds, it returns S_OK. If it fails, it supports the IErrorInfo interface and returns an HRESULT error code.

Return code | Number | Description
E_POINTER | 0x80004003 | The indirect pointer to the data view object is NULL.
NS_E_INVALID_INDEX | 0xC00D0011 | Either the index is less than zero or greater than the number of objects in the data view collection.

Example Code

// Include libraries.

#include <windows.h>
#include <atlbase.h>
#include "wmencode.h"
#include "wmencvu.h"

// Declare variables.

    HRESULT hr;
    IWMEncoder* pEncoder;
    IUnknown* pPreview;
    IWMEncDataView* pPreview_1;
    IWMEncDataView* pPreview_2;
    IWMEncDataView* pPreview_3;
    IWMEncDataViewCollection* pPreviewColl;
    IWMEncSourceGroupCollection* pSrcGrpColl;
    IWMEncSourceGroup* pSrcGrp;
    IWMEncSource* pAudSrc;
    IWMEncSource* pVidSrc;

    long lCount, lCookie, i, lDataViewIndex;

// Initialize the COM library and retrieve a pointer
// to an IWMEncoder interface.

    hr = CoInitialize(NULL);
    CoCreateInstance(CLSID_WMEncoder,
                     NULL,
                     CLSCTX_INPROC_SERVER,
                     IID_IWMEncoder,
                     (void**) &pEncoder);

// Retrieve a pointer to an IWMEncSourceGroupCollection
// interface.

    hr = pEncoder->get_SourceGroupCollection(&pSrcGrpColl);

// Add a source group to the collection.

    hr = pSrcGrpColl->Add(L"SG_1", &pSrcGrp);

// Add a video and audio source to the source group.

    hr = pSrcGrp->AddSource(WMENC_VIDEO, &pVidSrc);
    hr = pSrcGrp->AddSource(WMENC_AUDIO, &pAudSrc);

// Create three preview objects and return pointers.

    hr = CoCreateInstance( CLSID_WMEncPreview,
                           NULL,
                           CLSCTX_INPROC_SERVER,
                           IID_IWMEncDataView,
                           (void**)&pPreview_1);

    hr = CoCreateInstance( CLSID_WMEncPreview,
                           NULL,
                           CLSCTX_INPROC_SERVER,
                           IID_IWMEncDataView,
                           (void**)&pPreview_2);

    hr = CoCreateInstance( CLSID_WMEncPreview,
                           NULL,
                           CLSCTX_INPROC_SERVER,
                           IID_IWMEncDataView,
                           (void**)&pPreview_3);

// Retrieve the preview collection.

    hr = pVidSrc->get_PreviewCollection( &pPreviewColl );

// Add the preview objects to the data view collection. If you set the
// cookie to -1, the encoder engine automatically generates a unique
// cookie.

    long lCookie_1 = -1;
    hr = pPreviewColl->Add( pPreview_1, &lCookie_1);

    long lCookie_2 = -1;
    hr = pPreviewColl->Add( pPreview_2, &lCookie_2);

    long lCookie_3 = -1;
    hr = pPreviewColl->Add( pPreview_3, &lCookie_3);

// Retrieve the cookies for each preview.

    hr = pPreviewColl->get_Count(&lCount);
    for (i=0; i<lCount; i++)
    {
        hr = pPreviewColl->Item(i, &pPreview, &lCookie);
    }

// Remove the second preview object from the collection.
// The index is zero-based.

    lDataViewIndex = 1;
    hr = pPreviewColl->Remove(lDataViewIndex);

// Remove the remaining cookies from the collection.

    hr = pPreviewColl->RemoveAll();

See Also

  • IWMEncDataView Interface
  • IWMEncDataViewCollection Interface


IWMEncDataViewCollection::Remove

The Remove method removes a specific IWMEncDataView object from the collection.

Syntax

HRESULT Remove(
  long  lStreamIndex
);

Parameters

lStreamIndex

[in] long containing the index of the stream.

Return Values

If the method succeeds, it returns S_OK. If it fails, it supports the IErrorInfo interface and returns an HRESULT error code.

Return code | Number | Description
NS_E_INVALID_INDEX | 0xC00D1B66 | The index of the data view object to remove is invalid.
NS_E_INVALIDCALL_WHILE_ENCODER_RUNNING | 0xC00D0011 | This method cannot be called if the encoder engine is running.

Example Code

// Include libraries.

#include <windows.h>
#include <atlbase.h>
#include "wmencode.h"
#include "wmencvu.h"

// Declare variables.

    HRESULT hr;
    IWMEncoder* pEncoder;
    IUnknown* pPreview;
    IWMEncDataView* pPreview_1;
    IWMEncDataView* pPreview_2;
    IWMEncDataView* pPreview_3;
    IWMEncDataViewCollection* pPreviewColl;
    IWMEncSourceGroupCollection* pSrcGrpColl;
    IWMEncSourceGroup* pSrcGrp;
    IWMEncSource* pAudSrc;
    IWMEncSource* pVidSrc;

    long lCount, lCookie, i, lDataViewIndex;

// Initialize the COM library and retrieve a pointer
// to an IWMEncoder interface.

    hr = CoInitialize(NULL);
    CoCreateInstance(CLSID_WMEncoder,
                     NULL,
                     CLSCTX_INPROC_SERVER,
                     IID_IWMEncoder,
                     (void**) &pEncoder);

// Retrieve a pointer to an IWMEncSourceGroupCollection
// interface.

    hr = pEncoder->get_SourceGroupCollection(&pSrcGrpColl);

// Add a source group to the collection.

    hr = pSrcGrpColl->Add(L"SG_1", &pSrcGrp);

// Add a video and audio source to the source group.

    hr = pSrcGrp->AddSource(WMENC_VIDEO, &pVidSrc);
    hr = pSrcGrp->AddSource(WMENC_AUDIO, &pAudSrc);

// Create three preview objects and return pointers.

    hr = CoCreateInstance( CLSID_WMEncPreview,
                           NULL,
                           CLSCTX_INPROC_SERVER,
                           IID_IWMEncDataView,
                           (void**)&pPreview_1);

    hr = CoCreateInstance( CLSID_WMEncPreview,
                           NULL,
                           CLSCTX_INPROC_SERVER,
                           IID_IWMEncDataView,
                           (void**)&pPreview_2);

    hr = CoCreateInstance( CLSID_WMEncPreview,
                           NULL,
                           CLSCTX_INPROC_SERVER,
                           IID_IWMEncDataView,
                           (void**)&pPreview_3);

// Retrieve the preview collection.

    hr = pVidSrc->get_PreviewCollection( &pPreviewColl );

// Add the preview objects to the data view collection. If you set the
// cookie to -1, the encoder engine automatically generates a unique
// cookie.

    long lCookie_1 = -1;
    hr = pPreviewColl->Add( pPreview_1, &lCookie_1);

    long lCookie_2 = -1;
    hr = pPreviewColl->Add( pPreview_2, &lCookie_2);

    long lCookie_3 = -1;
    hr = pPreviewColl->Add( pPreview_3, &lCookie_3);

// Retrieve the cookies for each preview.

    hr = pPreviewColl->get_Count(&lCount);
    for (i=0; i<lCount; i++)
    {
        hr = pPreviewColl->Item(i, &pPreview, &lCookie);
    }

// Remove the second preview object from the collection.
// The index is zero-based.

    lDataViewIndex = 1;
    hr = pPreviewColl->Remove(lDataViewIndex);

// Remove the remaining cookies from the collection.

    hr = pPreviewColl->RemoveAll();

See Also

  • IWMEncDataView Interface
  • IWMEncDataViewCollection::Add
  • IWMEncDataViewCollection Interface
  • IWMEncDataViewCollection::RemoveAll


IWMEncDataViewCollection::RemoveAll

The RemoveAll method removes all IWMEncDataView objects from the collection.

Syntax

HRESULT RemoveAll();

Parameters

This method takes no parameters.

Return Values

If the method succeeds, it returns S_OK. If it fails, it supports the IErrorInfo interface and returns an HRESULT error code.

Return code | Number | Description
NS_E_INVALIDCALL_WHILE_ENCODER_RUNNING | 0xC00D0011 | This method cannot be called if the encoder engine is running.

Example Code

// Include libraries.

#include <windows.h>
#include <atlbase.h>
#include "wmencode.h"
#include "wmencvu.h"

// Declare variables.

    HRESULT hr;
    IWMEncoder* pEncoder;
    IUnknown* pPreview;
    IWMEncDataView* pPreview_1;
    IWMEncDataView* pPreview_2;
    IWMEncDataView* pPreview_3;
    IWMEncDataViewCollection* pPreviewColl;
    IWMEncSourceGroupCollection* pSrcGrpColl;
    IWMEncSourceGroup* pSrcGrp;
    IWMEncSource* pAudSrc;
    IWMEncSource* pVidSrc;

    long lCount, lCookie, i, lDataViewIndex;

// Initialize the COM library and retrieve a pointer
// to an IWMEncoder interface.

    hr = CoInitialize(NULL);
    CoCreateInstance(CLSID_WMEncoder,
                     NULL,
                     CLSCTX_INPROC_SERVER,
                     IID_IWMEncoder,
                     (void**) &pEncoder);

// Retrieve a pointer to an IWMEncSourceGroupCollection
// interface.

    hr = pEncoder->get_SourceGroupCollection(&pSrcGrpColl);

// Add a source group to the collection.

    hr = pSrcGrpColl->Add(L"SG_1", &pSrcGrp);

// Add a video and audio source to the source group.

    hr = pSrcGrp->AddSource(WMENC_VIDEO, &pVidSrc);
    hr = pSrcGrp->AddSource(WMENC_AUDIO, &pAudSrc);

// Create three preview objects and return pointers.

    hr = CoCreateInstance( CLSID_WMEncPreview,
                           NULL,
                           CLSCTX_INPROC_SERVER,
                           IID_IWMEncDataView,
                           (void**)&pPreview_1);

    hr = CoCreateInstance( CLSID_WMEncPreview,
                           NULL,
                           CLSCTX_INPROC_SERVER,
                           IID_IWMEncDataView,
                           (void**)&pPreview_2);

    hr = CoCreateInstance( CLSID_WMEncPreview,
                           NULL,
                           CLSCTX_INPROC_SERVER,
                           IID_IWMEncDataView,
                           (void**)&pPreview_3);

// Retrieve the preview collection.

    hr = pVidSrc->get_PreviewCollection( &pPreviewColl );

// Add the preview objects to the data view collection. If you set the
// cookie to -1, the encoder engine automatically generates a unique
// cookie.

    long lCookie_1 = -1;
    hr = pPreviewColl->Add( pPreview_1, &lCookie_1);

    long lCookie_2 = -1;
    hr = pPreviewColl->Add( pPreview_2, &lCookie_2);

    long lCookie_3 = -1;
    hr = pPreviewColl->Add( pPreview_3, &lCookie_3);

// Retrieve the cookies for each preview.

    hr = pPreviewColl->get_Count(&lCount);
    for (i=0; i<lCount; i++)
    {
        hr = pPreviewColl->Item(i, &pPreview, &lCookie);
    }

// Remove the second preview object from the collection.
// The index is zero-based.

    lDataViewIndex = 1;
    hr = pPreviewColl->Remove(lDataViewIndex);

// Remove the remaining cookies from the collection.

    hr = pPreviewColl->RemoveAll();

See Also

  • IWMEncDataView Interface
  • IWMEncDataViewCollection Interface
  • IWMEncDataViewCollection::Remove


IWMEncDisplayInfo Interface

The IWMEncDisplayInfo interface records and retrieves string information about the content being encoded. Typically, this includes the name of the author, the copyright date, the title and rating of the content, and any extra description added by the content author. In addition to the methods inherited from IDispatch, the IWMEncDisplayInfo interface exposes the following methods.

Method | Description
get_Author | Retrieves the name of the content author.
get_Copyright | Retrieves the copyright information for the content being encoded.
get_Description | Retrieves a general description of the multimedia content being encoded.
get_Rating | Retrieves the rating information for the content being encoded.
get_Title | Retrieves the title of the content being encoded.
put_Author | Specifies the name of the content author.
put_Copyright | Specifies copyright information for the content being encoded.
put_Description | Specifies a description of the content being encoded.
put_Rating | Specifies content rating information for the content being encoded.
put_Title | Specifies a title for the content being encoded.

See Also

  • [Visual Basic] IWMEncDisplayInfo Object
  • Interfaces (C++)


IWMEncDisplayInfo::get_Author

The get_Author method retrieves the name of the content author.

Syntax

HRESULT get_Author(
  BSTR*  pbstrAuthor
);

Parameters

pbstrAuthor

[out] Pointer to a BSTR containing the name of the author.

Return Values

If the method succeeds, it returns S_OK. If it fails, it supports the IErrorInfo interface and returns an HRESULT error code.

Return code | Number | Meaning
E_POINTER | 0x80004003 | The pointer to the name of the author is NULL.

Example code

// Include libraries.

#include <windows.h>
#include <atlbase.h>               // Includes CComBSTR.
#include "wmencode.h"

// Declare variables.

HRESULT hr;
IWMEncoder* pEncoder;
IWMEncDisplayInfo* pDispInfo;
CComBSTR m_bstrAuthor("Content Author's name.");
CComBSTR m_bstrCopyright("Copyright 2000. All rights reserved.");
CComBSTR m_bstrDescription("Description of the encoded content.");
CComBSTR m_bstrRating("Content rating.");
CComBSTR m_bstrTitle("Title of the encoded content.");

// Initialize the COM library and retrieve a pointer
// to an IWMEncoder interface.

hr = CoInitialize(NULL);
CoCreateInstance(CLSID_WMEncoder,
                 NULL,
                 CLSCTX_INPROC_SERVER,
                 IID_IWMEncoder,
                 (void**) &pEncoder);

// Retrieve a pointer to an IWMEncDisplayInfo interface.

hr = pEncoder->get_DisplayInfo(&pDispInfo);

// Set the data members of the IWMEncDisplayInfo interface.

hr = pDispInfo->put_Author(m_bstrAuthor);
hr = pDispInfo->put_Copyright(m_bstrCopyright);
hr = pDispInfo->put_Description(m_bstrDescription);
hr = pDispInfo->put_Rating(m_bstrRating);
hr = pDispInfo->put_Title(m_bstrTitle);

// Retrieve the data members of the IWMEncDisplayInfo interface.

hr = pDispInfo->get_Author(&m_bstrAuthor);
hr = pDispInfo->get_Copyright(&m_bstrCopyright);
hr = pDispInfo->get_Description(&m_bstrDescription);
hr = pDispInfo->get_Rating(&m_bstrRating);
hr = pDispInfo->get_Title(&m_bstrTitle);

See Also

  • IWMEncDisplayInfo Interface
  • IWMEncDisplayInfo::put_Author


IWMEncDisplayInfo::get_Copyright

The get_Copyright method retrieves the copyright information for the content being encoded.

Syntax

HRESULT get_Copyright(
  BSTR*  pbstrCopyright
);

Parameters

pbstrCopyright

[out] Pointer to a BSTR containing the copyright information.

Return Values

If the method succeeds, it returns S_OK. If it fails, it supports the IErrorInfo interface and returns an HRESULT error code.

Return code | Number | Meaning
E_POINTER | 0x80004003 | The pointer to the copyright information is NULL.

Example code

// Include libraries.

#include <windows.h>
#include <atlbase.h>               // Includes CComBSTR.
#include "wmencode.h"

// Declare variables.

HRESULT hr;
IWMEncoder* pEncoder;
IWMEncDisplayInfo* pDispInfo;
CComBSTR m_bstrAuthor("Content Author's name.");
CComBSTR m_bstrCopyright("Copyright 2000. All rights reserved.");
CComBSTR m_bstrDescription("Description of the encoded content.");
CComBSTR m_bstrRating("Content rating.");
CComBSTR m_bstrTitle("Title of the encoded content.");

// Initialize the COM library and retrieve a pointer
// to an IWMEncoder interface.

hr = CoInitialize(NULL);
CoCreateInstance(CLSID_WMEncoder,
                 NULL,
                 CLSCTX_INPROC_SERVER,
                 IID_IWMEncoder,
                 (void**) &pEncoder);

// Retrieve a pointer to an IWMEncDisplayInfo interface.

hr = pEncoder->get_DisplayInfo(&pDispInfo);

// Set the data members of the IWMEncDisplayInfo interface.

hr = pDispInfo->put_Author(m_bstrAuthor);
hr = pDispInfo->put_Copyright(m_bstrCopyright);
hr = pDispInfo->put_Description(m_bstrDescription);
hr = pDispInfo->put_Rating(m_bstrRating);
hr = pDispInfo->put_Title(m_bstrTitle);

// Retrieve the data members of the IWMEncDisplayInfo interface.

hr = pDispInfo->get_Author(&m_bstrAuthor);
hr = pDispInfo->get_Copyright(&m_bstrCopyright);
hr = pDispInfo->get_Description(&m_bstrDescription);
hr = pDispInfo->get_Rating(&m_bstrRating);
hr = pDispInfo->get_Title(&m_bstrTitle);

See Also

  • IWMEncDisplayInfo Interface
  • IWMEncDisplayInfo::put_Copyright


IWMEncDisplayInfo::get_Description

The get_Description method retrieves a general description of the multimedia content being encoded.

Syntax

HRESULT get_Description(
  BSTR*  pbstrDesc
);

Parameters

pbstrDesc

[out] Pointer to a BSTR containing a description of the content.

Return Values

If the method succeeds, it returns S_OK. If it fails, it supports the IErrorInfo interface and returns an HRESULT error code.

Return code | Number | Meaning
E_POINTER | 0x80004003 | The pointer to the description is NULL.

Example code

// Include libraries.

#include <windows.h>
#include <atlbase.h>               // Includes CComBSTR.
#include "wmencode.h"

// Declare variables.

HRESULT hr;
IWMEncoder* pEncoder;
IWMEncDisplayInfo* pDispInfo;
CComBSTR m_bstrAuthor("Content Author's name.");
CComBSTR m_bstrCopyright("Copyright 2000. All rights reserved.");
CComBSTR m_bstrDescription("Description of the encoded content.");
CComBSTR m_bstrRating("Content rating.");
CComBSTR m_bstrTitle("Title of the encoded content.");

// Initialize the COM library and retrieve a pointer
// to an IWMEncoder interface.

hr = CoInitialize(NULL);
CoCreateInstance(CLSID_WMEncoder,
                 NULL,
                 CLSCTX_INPROC_SERVER,
                 IID_IWMEncoder,
                 (void**) &pEncoder);

// Retrieve a pointer to an IWMEncDisplayInfo interface.

hr = pEncoder->get_DisplayInfo(&pDispInfo);

// Set the data members of the IWMEncDisplayInfo interface.

hr = pDispInfo->put_Author(m_bstrAuthor);
hr = pDispInfo->put_Copyright(m_bstrCopyright);
hr = pDispInfo->put_Description(m_bstrDescription);
hr = pDispInfo->put_Rating(m_bstrRating);
hr = pDispInfo->put_Title(m_bstrTitle);

// Retrieve the data members of the IWMEncDisplayInfo interface.

hr = pDispInfo->get_Author(&m_bstrAuthor);
hr = pDispInfo->get_Copyright(&m_bstrCopyright);
hr = pDispInfo->get_Description(&m_bstrDescription);
hr = pDispInfo->get_Rating(&m_bstrRating);
hr = pDispInfo->get_Title(&m_bstrTitle);

See Also

  • IWMEncDisplayInfo Interface
  • IWMEncDisplayInfo::put_Description


IWMEncDisplayInfo::get_Rating

The get_Rating method retrieves the rating information for the content being encoded.

Syntax

HRESULT get_Rating(
  BSTR*  pbstrRating
);

Parameters

pbstrRating

[out] Pointer to a BSTR containing the rating information.

Return Values

If the method succeeds, it returns S_OK. If it fails, it supports the IErrorInfo interface and returns an HRESULT error code.

Return code | Number | Meaning
E_POINTER | 0x80004003 | The pointer to the rating information is NULL.

Remarks

Rating information specifies the audience for which the content is suitable.

Example code

// Include libraries.

#include <windows.h>
#include <atlbase.h>               // Includes CComBSTR.
#include "wmencode.h"

// Declare variables.

HRESULT hr;
IWMEncoder* pEncoder;
IWMEncDisplayInfo* pDispInfo;
CComBSTR m_bstrAuthor("Content Author's name.");
CComBSTR m_bstrCopyright("Copyright 2000. All rights reserved.");
CComBSTR m_bstrDescription("Description of the encoded content.");
CComBSTR m_bstrRating("Content rating.");
CComBSTR m_bstrTitle("Title of the encoded content.");

// Initialize the COM library and retrieve a pointer
// to an IWMEncoder interface.

hr = CoInitialize(NULL);
CoCreateInstance(CLSID_WMEncoder,
                 NULL,
                 CLSCTX_INPROC_SERVER,
                 IID_IWMEncoder,
                 (void**) &pEncoder);

// Retrieve a pointer to an IWMEncDisplayInfo interface.

hr = pEncoder->get_DisplayInfo(&pDispInfo);

// Set the data members of the IWMEncDisplayInfo interface.

hr = pDispInfo->put_Author(m_bstrAuthor);
hr = pDispInfo->put_Copyright(m_bstrCopyright);
hr = pDispInfo->put_Description(m_bstrDescription);
hr = pDispInfo->put_Rating(m_bstrRating);
hr = pDispInfo->put_Title(m_bstrTitle);

// Retrieve the data members of the IWMEncDisplayInfo interface.

hr = pDispInfo->get_Author(&m_bstrAuthor);
hr = pDispInfo->get_Copyright(&m_bstrCopyright);
hr = pDispInfo->get_Description(&m_bstrDescription);
hr = pDispInfo->get_Rating(&m_bstrRating);
hr = pDispInfo->get_Title(&m_bstrTitle);

See Also

  • IWMEncDisplayInfo Interface
  • IWMEncDisplayInfo::put_Rating


IWMEncDisplayInfo::get_Title

The get_Title method retrieves the title of the content being encoded.

Syntax

HRESULT get_Title(
  BSTR*  pbstrTitle
);

Parameters

pbstrTitle

[out] Pointer to a BSTR containing the title.

Return Values

If the method succeeds, it returns S_OK. If it fails, it supports the IErrorInfo interface and returns an HRESULT error code.

Return code | Number | Meaning
E_POINTER | 0x80004003 | The pointer to the title is NULL.

Example code

// Include libraries.

#include <windows.h>
#include <atlbase.h>               // Includes CComBSTR.
#include "wmencode.h"

// Declare variables.

HRESULT hr;
IWMEncoder* pEncoder;
IWMEncDisplayInfo* pDispInfo;
CComBSTR m_bstrAuthor("Content Author's name.");
CComBSTR m_bstrCopyright("Copyright 2000. All rights reserved.");
CComBSTR m_bstrDescription("Description of the encoded content.");
CComBSTR m_bstrRating("Content rating.");
CComBSTR m_bstrTitle("Title of the encoded content.");

// Initialize the COM library and retrieve a pointer
// to an IWMEncoder interface.

hr = CoInitialize(NULL);
CoCreateInstance(CLSID_WMEncoder,
                 NULL,
                 CLSCTX_INPROC_SERVER,
                 IID_IWMEncoder,
                 (void**) &pEncoder);

// Retrieve a pointer to an IWMEncDisplayInfo interface.

hr = pEncoder->get_DisplayInfo(&pDispInfo);

// Set the data members of the IWMEncDisplayInfo interface.

hr = pDispInfo->put_Author(m_bstrAuthor);
hr = pDispInfo->put_Copyright(m_bstrCopyright);
hr = pDispInfo->put_Description(m_bstrDescription);
hr = pDispInfo->put_Rating(m_bstrRating);
hr = pDispInfo->put_Title(m_bstrTitle);

// Retrieve the data members of the IWMEncDisplayInfo interface.

hr = pDispInfo->get_Author(&m_bstrAuthor);
hr = pDispInfo->get_Copyright(&m_bstrCopyright);
hr = pDispInfo->get_Description(&m_bstrDescription);
hr = pDispInfo->get_Rating(&m_bstrRating);
hr = pDispInfo->get_Title(&m_bstrTitle);

See Also

  • IWMEncDisplayInfo Interface
  • IWMEncDisplayInfo::put_Title


IWMEncDisplayInfo::put_Author

The put_Author method specifies the name of the content author.

Syntax

HRESULT put_Author(
  BSTR  bstrAuthor
);

Parameters

bstrAuthor

[in] BSTR containing the name of the author.

Return Values

If the method succeeds, it returns S_OK. If it fails, it supports the IErrorInfo interface and returns an HRESULT error code.

Return code | Number | Meaning
NS_E_INVALIDCALL_WHILE_ENCODER_RUNNING | 0xC00D0011 | This method cannot be called if the encoder engine is running.

Example code

// Include libraries.

#include <windows.h>
#include <atlbase.h>               // Includes CComBSTR.
#include "wmencode.h"

// Declare variables.

HRESULT hr;
IWMEncoder* pEncoder;
IWMEncDisplayInfo* pDispInfo;
CComBSTR m_bstrAuthor("Content Author's name.");
CComBSTR m_bstrCopyright("Copyright 2000. All rights reserved.");
CComBSTR m_bstrDescription("Description of the encoded content.");
CComBSTR m_bstrRating("Content rating.");
CComBSTR m_bstrTitle("Title of the encoded content.");

// Initialize the COM library and retrieve a pointer
// to an IWMEncoder interface.

hr = CoInitialize(NULL);
CoCreateInstance(CLSID_WMEncoder,
                 NULL,
                 CLSCTX_INPROC_SERVER,
                 IID_IWMEncoder,
                 (void**) &pEncoder);

// Retrieve a pointer to an IWMEncDisplayInfo interface.

hr = pEncoder->get_DisplayInfo(&pDispInfo);

// Set the data members of the IWMEncDisplayInfo interface.

hr = pDispInfo->put_Author(m_bstrAuthor);
hr = pDispInfo->put_Copyright(m_bstrCopyright);
hr = pDispInfo->put_Description(m_bstrDescription);
hr = pDispInfo->put_Rating(m_bstrRating);
hr = pDispInfo->put_Title(m_bstrTitle);

// Retrieve the data members of the IWMEncDisplayInfo interface.

hr = pDispInfo->get_Author(&m_bstrAuthor);
hr = pDispInfo->get_Copyright(&m_bstrCopyright);
hr = pDispInfo->get_Description(&m_bstrDescription);
hr = pDispInfo->get_Rating(&m_bstrRating);
hr = pDispInfo->get_Title(&m_bstrTitle);

See Also

  • IWMEncDisplayInfo::get_Author
  • IWMEncDisplayInfo Interface


IWMEncDisplayInfo::put_Copyright

The put_Copyright method specifies copyright information for the content being encoded.

Syntax

HRESULT put_Copyright(
  BSTR  bstrCopyright
);

Parameters

bstrCopyright

[in] BSTR containing the copyright information.

Return Values

If the method succeeds, it returns S_OK. If it fails, it supports the IErrorInfo interface and returns an HRESULT error code.

Return code | Number | Meaning
NS_E_INVALIDCALL_WHILE_ENCODER_RUNNING | 0xC00D0011 | This method cannot be called if the encoder engine is running.

Example code

// Include libraries.

#include <windows.h>
#include <atlbase.h>               // Includes CComBSTR.
#include "wmencode.h"

// Declare variables.

HRESULT hr;
IWMEncoder* pEncoder;
IWMEncDisplayInfo* pDispInfo;
CComBSTR m_bstrAuthor("Content Author's name.");
CComBSTR m_bstrCopyright("Copyright 2000. All rights reserved.");
CComBSTR m_bstrDescription("Description of the encoded content.");
CComBSTR m_bstrRating("Content rating.");
CComBSTR m_bstrTitle("Title of the encoded content.");

// Initialize the COM library and retrieve a pointer
// to an IWMEncoder interface.

hr = CoInitialize(NULL);
CoCreateInstance(CLSID_WMEncoder,
                 NULL,
                 CLSCTX_INPROC_SERVER,
                 IID_IWMEncoder,
                 (void**) &pEncoder);

// Retrieve a pointer to an IWMEncDisplayInfo interface.

hr = pEncoder->get_DisplayInfo(&pDispInfo);

// Set the data members of the IWMEncDisplayInfo interface.

hr = pDispInfo->put_Author(m_bstrAuthor);
hr = pDispInfo->put_Copyright(m_bstrCopyright);
hr = pDispInfo->put_Description(m_bstrDescription);
hr = pDispInfo->put_Rating(m_bstrRating);
hr = pDispInfo->put_Title(m_bstrTitle);

// Retrieve the data members of the IWMEncDisplayInfo interface.

hr = pDispInfo->get_Author(&m_bstrAuthor);
hr = pDispInfo->get_Copyright(&m_bstrCopyright);
hr = pDispInfo->get_Description(&m_bstrDescription);
hr = pDispInfo->get_Rating(&m_bstrRating);
hr = pDispInfo->get_Title(&m_bstrTitle);

See Also

  • IWMEncDisplayInfo::get_Copyright
  • IWMEncDisplayInfo Interface


IWMEncDisplayInfo::put_Description

The put_Description method specifies a description of the content being encoded.

Syntax

HRESULT put_Description(
  BSTR  bstrDesc
);

Parameters

bstrDesc

[in] BSTR containing the descriptive information.

Return Values

If the method succeeds, it returns S_OK. If it fails, it supports the IErrorInfo interface and returns an HRESULT error code.

Return code | Number | Meaning
NS_E_INVALIDCALL_WHILE_ENCODER_RUNNING | 0xC00D0011 | This method cannot be called if the encoder engine is running.

Example code

// Include libraries.

#include <windows.h>
#include <atlbase.h>               // Includes CComBSTR.
#include "wmencode.h"

// Declare variables.

HRESULT hr;
IWMEncoder* pEncoder;
IWMEncDisplayInfo* pDispInfo;
CComBSTR m_bstrAuthor("Content Author's name.");
CComBSTR m_bstrCopyright("Copyright 2000. All rights reserved.");
CComBSTR m_bstrDescription("Description of the encoded content.");
CComBSTR m_bstrRating("Content rating.");
CComBSTR m_bstrTitle("Title of the encoded content.");

// Initialize the COM library and retrieve a pointer
// to an IWMEncoder interface.

hr = CoInitialize(NULL);
CoCreateInstance(CLSID_WMEncoder,
                 NULL,
                 CLSCTX_INPROC_SERVER,
                 IID_IWMEncoder,
                 (void**) &pEncoder);

// Retrieve a pointer to an IWMEncDisplayInfo interface.

hr = pEncoder->get_DisplayInfo(&pDispInfo);

// Set the data members of the IWMEncDisplayInfo interface.

hr = pDispInfo->put_Author(m_bstrAuthor);
hr = pDispInfo->put_Copyright(m_bstrCopyright);
hr = pDispInfo->put_Description(m_bstrDescription);
hr = pDispInfo->put_Rating(m_bstrRating);
hr = pDispInfo->put_Title(m_bstrTitle);

// Retrieve the data members of the IWMEncDisplayInfo interface.

hr = pDispInfo->get_Author(&m_bstrAuthor);
hr = pDispInfo->get_Copyright(&m_bstrCopyright);
hr = pDispInfo->get_Description(&m_bstrDescription);
hr = pDispInfo->get_Rating(&m_bstrRating);
hr = pDispInfo->get_Title(&m_bstrTitle);

See Also

  • IWMEncDisplayInfo::get_Description
  • IWMEncDisplayInfo Interface


IWMEncDisplayInfo::put_Rating

The put_Rating method specifies rating information for the content being encoded.

Syntax

HRESULT put_Rating(
  BSTR  bstrRating
);

Parameters

bstrRating

[in] BSTR containing the rating information.

Return Values

If the method succeeds, it returns S_OK. If it fails, it supports the IErrorInfo interface and returns an HRESULT error code.

Return code | Number | Meaning
NS_E_INVALIDCALL_WHILE_ENCODER_RUNNING | 0xC00D0011 | This method cannot be called if the encoder engine is running.

Example code

// Include libraries.

#include <windows.h>
#include <atlbase.h>               // Includes CComBSTR.
#include "wmencode.h"

// Declare variables.

HRESULT hr;
IWMEncoder* pEncoder;
IWMEncDisplayInfo* pDispInfo;
CComBSTR m_bstrAuthor("Content Author's name.");
CComBSTR m_bstrCopyright("Copyright 2000. All rights reserved.");
CComBSTR m_bstrDescription("Description of the encoded content.");
CComBSTR m_bstrRating("Content rating.");
CComBSTR m_bstrTitle("Title of the encoded content.");

// Initialize the COM library and retrieve a pointer
// to an IWMEncoder interface.

hr = CoInitialize(NULL);
CoCreateInstance(CLSID_WMEncoder,
                 NULL,
                 CLSCTX_INPROC_SERVER,
                 IID_IWMEncoder,
                 (void**) &pEncoder);

// Retrieve a pointer to an IWMEncDisplayInfo interface.

hr = pEncoder->get_DisplayInfo(&pDispInfo);

// Set the data members of the IWMEncDisplayInfo interface.

hr = pDispInfo->put_Author(m_bstrAuthor);
hr = pDispInfo->put_Copyright(m_bstrCopyright);
hr = pDispInfo->put_Description(m_bstrDescription);
hr = pDispInfo->put_Rating(m_bstrRating);
hr = pDispInfo->put_Title(m_bstrTitle);

// Retrieve the data members of the IWMEncDisplayInfo interface.

hr = pDispInfo->get_Author(&m_bstrAuthor);
hr = pDispInfo->get_Copyright(&m_bstrCopyright);
hr = pDispInfo->get_Description(&m_bstrDescription);
hr = pDispInfo->get_Rating(&m_bstrRating);
hr = pDispInfo->get_Title(&m_bstrTitle);

See Also

  • IWMEncDisplayInfo::get_Rating
  • IWMEncDisplayInfo Interface


IWMEncDisplayInfo::put_Title

The put_Title method specifies a title for the content being encoded.

Syntax

HRESULT put_Title(
  BSTR  bstrTitle
);

Parameters

bstrTitle

[in] BSTR containing the title.

Return Values

If the method succeeds, it returns S_OK. If it fails, it supports the IErrorInfo interface and returns an HRESULT error code.

Return code | Number | Meaning
NS_E_INVALIDCALL_WHILE_ENCODER_RUNNING | 0xC00D0011 | This method cannot be called if the encoder engine is running.

Example code

// Include libraries.

#include <windows.h>
#include <atlbase.h>               // Includes CComBSTR.
#include "wmencode.h"

// Declare variables.

HRESULT hr;
IWMEncoder* pEncoder;
IWMEncDisplayInfo* pDispInfo;
CComBSTR m_bstrAuthor("Content Author's name.");
CComBSTR m_bstrCopyright("Copyright 2000. All rights reserved.");
CComBSTR m_bstrDescription("Description of the encoded content.");
CComBSTR m_bstrRating("Content rating.");
CComBSTR m_bstrTitle("Title of the encoded content.");

// Initialize the COM library and retrieve a pointer
// to an IWMEncoder interface.

hr = CoInitialize(NULL);
CoCreateInstance(CLSID_WMEncoder,
                 NULL,
                 CLSCTX_INPROC_SERVER,
                 IID_IWMEncoder,
                 (void**) &pEncoder);

// Retrieve a pointer to an IWMEncDisplayInfo interface.

hr = pEncoder->get_DisplayInfo(&pDispInfo);

// Set the data members of the IWMEncDisplayInfo interface.

hr = pDispInfo->put_Author(m_bstrAuthor);
hr = pDispInfo->put_Copyright(m_bstrCopyright);
hr = pDispInfo->put_Description(m_bstrDescription);
hr = pDispInfo->put_Rating(m_bstrRating);
hr = pDispInfo->put_Title(m_bstrTitle);

// Retrieve the data members of the IWMEncDisplayInfo interface.

hr = pDispInfo->get_Author(&m_bstrAuthor);
hr = pDispInfo->get_Copyright(&m_bstrCopyright);
hr = pDispInfo->get_Description(&m_bstrDescription);
hr = pDispInfo->get_Rating(&m_bstrRating);
hr = pDispInfo->get_Title(&m_bstrTitle);

See Also

  • IWMEncDisplayInfo::get_Title
  • IWMEncDisplayInfo Interface


IWMEncFile Interface

The IWMEncFile interface manages the name of the file used for archiving encoded content. In addition to the methods inherited from IDispatch, the IWMEncFile interface exposes the following methods.

Method | Description
get_LocalFileName | Retrieves the full path of the file used for archiving encoded content.
put_LocalFileName | Specifies the full path of the file used for archiving encoded content.

See Also

  • [Visual Basic] IWMEncFile Object
  • Interfaces (C++)


IWMEncFile::get_LocalFileName

The get_LocalFileName method retrieves the full path of the file used for archiving encoded content.

Syntax

HRESULT get_LocalFileName(
  BSTR*  pbstrFileName
);

Parameters

pbstrFileName

[out] Pointer to a BSTR containing the file name.

Return Values

If the method succeeds, it returns S_OK. If it fails, it returns an HRESULT error code.

Return code | Number | Meaning
E_POINTER | 0x80004003 | The pointer to the file name is NULL.

Remarks

The file being used for archiving encoded content must reside on either the computer that is broadcasting the content or the local network to which that computer is connected.

Example Code

// Include libraries.

#include <windows.h>
#include <atlbase.h>
#include "wmencode.h"

// Declare variables.

   HRESULT hr;
   IWMEncoder* pEncoder;
   IWMEncSourceGroupCollection* pSrcGrpColl;
   IWMEncSourceGroup* pSrcGrp;
   IWMEncSource* pAudSrc;
   IWMEncSource* pVidSrc;
   IWMEncProfileCollection* pProColl;
   IWMEncProfile* pPro;
   IWMEncFile* pFile;
   long lCount;
   int i;

// Initialize the COM library and retrieve a pointer
// to an IWMEncoder interface.

   hr = CoInitialize(NULL);
   CoCreateInstance(CLSID_WMEncoder,
                    NULL,
                    CLSCTX_INPROC_SERVER,
                    IID_IWMEncoder,
                   (void**) &pEncoder);

// Retrieve a pointer to an IWMEncSourceGroupCollection
// interface.

   hr = pEncoder->get_SourceGroupCollection(&pSrcGrpColl);

// Add an empty source group to the collection.

   hr = pSrcGrpColl->Add(L"SG_1", &pSrcGrp);

// Add an audio and video stream to the source group.

   hr = pSrcGrp->AddSource(WMENC_AUDIO, &pAudSrc);
   hr = pSrcGrp->AddSource(WMENC_VIDEO, &pVidSrc);

// Retrieve a pointer to an IWMEncFile interface.

   hr = pEncoder->get_File( &pFile );

// Specify an .avi source file and a Windows Media file with a .wmv extension for the output.

   CComBSTR m_bstrInFile(L"C:\\file_name");
   CComBSTR m_bstrOutFile(L"C:\\file_name");

   hr = pAudSrc->SetInput(m_bstrInFile);
   hr = pVidSrc->SetInput(m_bstrInFile);
   hr = pFile->put_LocalFileName(m_bstrOutFile);

// Retrieve the name of the output file.

   CComBSTR m_bstrFileName(L" ");
   hr = pFile->get_LocalFileName(&m_bstrFileName);

// Loop through the profile collection and retrieve a specific
// profile. You can find the profile name in the Profile Manager.

   hr = pEncoder->get_ProfileCollection(&pProColl);
   CComBSTR m_bstrName(L" ");
   CComVariant m_varProfile;
   m_varProfile.vt = VT_DISPATCH;
   hr = pProColl->get_Count(&lCount);
   or (i=0; i<lCount; i++)
   {
      hr = pProColl->Item(i, &pPro);
      hr = pPro->get_Name(&m_bstrName);
      if (_wcsicmp(m_bstrName, L"profile_name")==0)
      {
         m_varProfile.pdispVal = pPro;
         pSrcGrp->put_Profile(m_varProfile);
         break;
      }
   }

// Start archiving when the encoder engine starts. This is the default.

   hr = pEncoder->put_EnableAutoArchive(VARIANT_TRUE);

// Initialize and start the encoder engine. To determine when the
// encoding and archiving process has ended, you must implement the
// OnArchiveStateChange event in the _IWMEncoderEvents interface.

   hr = pEncoder->PrepareToEncode(VARIANT_TRUE);
   hr = pEncoder->Start();

// To determine when the encoding and archiving process has ended,
// you must implement the OnArchiveStateChange event in the
// _IWMEncoderEvents interface.

See Also

  • IWMEncFile Interface
  • IWMEncoder Interface
  • IWMEncProfile Interface
  • IWMEncProfileCollection Interface
  • IWMEncSource Interface
  • IWMEncSourceGroup Interface
  • IWMEncSourceGroupCollection Interface
  • IWMEncFile::put_LocalFileName


IWMEncFile::put_LocalFileName

The put_LocalFileName method specifies the full path of the file used for archiving encoded content.

Syntax

HRESULT put_LocalFileName(
  BSTR  bstrFileName
);

Parameters

bstrFileName

[in] BSTR containing the file name.

Return Values

If the method succeeds, it returns S_OK. If it fails, it returns an HRESULT error code.

Return code | Number | Meaning
NS_E_INVALIDCALL_WHILE_ENCODER_RUNNING | 0xC00D0011 | This method cannot be called if the encoder engine is running.

Remarks

Currently, the file being used for archiving must reside on either the computer that is broadcasting the content or the local network to which that computer is connected.

Example Code

// Include libraries.

#include <windows.h>
#include <wchar.h>
#include <atlbase.h>
#include "wmencode.h"

// Declare variables.

   HRESULT hr;
   IWMEncoder* pEncoder;
   IWMEncSourceGroupCollection* pSrcGrpColl;
   IWMEncSourceGroup* pSrcGrp;
   IWMEncSource* pAudSrc;
   IWMEncSource* pVidSrc;
   IWMEncProfileCollection* pProColl;
   IWMEncProfile* pPro;
   IWMEncFile* pFile;
   long lCount;
   int i;

// Initialize the COM library and retrieve a pointer
// to an IWMEncoder interface.

   hr = CoInitialize(NULL);
   CoCreateInstance(CLSID_WMEncoder,
                    NULL,
                    CLSCTX_INPROC_SERVER,
                    IID_IWMEncoder,
                   (void**) &pEncoder);

// Retrieve a pointer to an IWMEncSourceGroupCollection
// interface.

   hr = pEncoder->get_SourceGroupCollection(&pSrcGrpColl);

// Add an empty source group to the collection.

   hr = pSrcGrpColl->Add(L"SG_1", &pSrcGrp);

// Add an audio and video stream to the source group.

   hr = pSrcGrp->AddSource(WMENC_AUDIO, &pAudSrc);
   hr = pSrcGrp->AddSource(WMENC_VIDEO, &pVidSrc);

// Retrieve a pointer to an IWMEncFile interface.

   hr = pEncoder->get_File( &pFile );

// Specify an .avi source file and a Windows Media file with a .wmv extension for the output.

   CComBSTR m_bstrInFile(L"C:\\file_name");
   CComBSTR m_bstrOutFile(L"C:\\file_name");

   hr = pAudSrc->SetInput(m_bstrInFile);
   hr = pVidSrc->SetInput(m_bstrInFile);
   hr = pFile->put_LocalFileName(m_bstrOutFile);

// Retrieve the name of the output file.

   CComBSTR m_bstrFileName(L" ");
   hr = pFile->get_LocalFileName(&m_bstrFileName);

// Loop through the profile collection and retrieve a specific
// profile. You can find the profile name in the Profile MAnager.

   hr = pEncoder->get_ProfileCollection(&pProColl);
   CComBSTR m_bstrName(L" ");
   CComVariant m_varProfile;
   m_varProfile.vt = VT_DISPATCH;
   hr = pProColl->get_Count(&lCount);
   or (i=0; i<lCount; i++)
   {
      hr = pProColl->Item(i, &pPro);
      hr = pPro->get_Name(&m_bstrName);
      if (_wcsicmp(m_bstrName, L"profile_name")==0)
      {
         m_varProfile.pdispVal = pPro;
         pSrcGrp->put_Profile(m_varProfile);
         break;
      }
   }

// Start archiving when the encoder engine starts. This is the default.

   hr = pEncoder->put_EnableAutoArchive(VARIANT_TRUE);

// Initialize and start the encoder engine.

   hr = pEncoder->PrepareToEncode(VARIANT_TRUE);
   hr = pEncoder->Start();

// To determine when the encoding and archiving process has ended,
// you must implement the OnArchiveStateChange event in the
// _IWMEncoderEvents interface.

See Also

  • IWMEncFile::get_LocalFileName
  • IWMEncFile Interface
  • IWMEncoder Interface
  • IWMEncProfile Interface
  • IWMEncProfileCollection Interface
  • IWMEncSource Interface
  • IWMEncSourceGroup Interface
  • IWMEncSourceGroupCollection Interface


IWMEncFileArchiveStats Interface

The IWMEncFileArchiveStats interface retrieves the size, in bytes, of the archive file and the duration, in milliseconds, of the encoded content stored in the file. In addition to the methods inherited from IDispatch, the IWMEncFileArchiveStats interface exposes the following methods.

Interface | Description
get_FileDuration | Retrieves the duration, in milliseconds, of the encoded content stored in an archive file.
get_FileSize | Retrieves the size, in bytes, of the archive file.

See Also

  • [Visual Basic] IWMEncFileArchiveStats Object
  • Interfaces (C++)


IWMEncFileArchiveStats::get_FileDuration

The get_FileDuration method retrieves the duration, in milliseconds, of the encoded content stored in an archive file.

Syntax

HRESULT get_FileDuration(
  WMENC_longlong*  pqwDuration
);

Parameters

pqwDuration

[out] Pointer to a QWORD containing the output file duration.

Return Values

If the method succeeds, it returns S_OK. If it fails, it returns E_FAIL.

Remarks

The WMENC_longlong data type is a typedef from the CURRENCY type. A 64-bit integer is needed to hold the duration, and CURRENCY is the only 64-bit integer type that Automation supports. To manipulate the value, you can use the following:

    qwDuration.int64

File duration information does not persist after the encoding process has stopped.

Example code

// For an example that explains how to
// create and use an archive file, see the IWMEncFile object.
// The following example shows how to capture archiving statistics
// during the encoding process.

// Include libraries.

#include <windows.h>
#include "..\wmencode.h"

// Declare variables.

    HRESULT hr;
    IWMEncoder* pEncoder;
    IWMEncStatistics* pStatistics;
    IWMEncFileArchiveStats* pFileArchiveStats;
    IDispatch* pDispFileArchiveStats;
    WMENC_longlong qwDuration, qwSize;

// Initialize the COM library and retrieve a pointer
// to an IWMEncoder interface.

    hr = CoInitialize(NULL);
    CoCreateInstance(CLSID_WMEncoder,
                     NULL,
                     CLSCTX_INPROC_SERVER,
                     IID_IWMEncoder,
                    (void**) &pEncoder);

// Retrieve an IWMEncStatistics interface pointer.

    hr = pEncoder->get_Statistics(&pStatistics);

// Retrieve an IDispatch pointer for the IWMEncOutputStats
// interface.

    hr = pStatistics->get_FileArchiveStats(&pDispFileArchiveStats);

// Call QueryInterface for the IWMEncNetConnectionStats
// interface pointer.

    hr = pDispFileArchiveStats->QueryInterface(
                      IID_IWMEncFileArchiveStats,
                      (void**)&pFileArchiveStats);

// Manually configure the encoder engine or load
// a configuration from a file. For an example, see the
// IWMEncFile object.

// Create a timer to retrieve the statistics
// after you start the encoder engine.

    pFileArchiveStats->get_FileDuration(&qwDuration);
    pFileArchiveStats->get_FileSize(&qwSize);

See Also

  • IWMEncFile Interface
  • IWMEncFileArchiveStats Interface


IWMEncFileArchiveStats::get_FileSize

The get_FileSize method retrieves the size, in bytes, of the archive file.

Syntax

HRESULT get_FileSize(
  WMENC_longlong*  pqwSize
);

Parameters

pqwSize

[out] Pointer to a QWORD containing the output file size.

Return Values

If the method succeeds, it returns S_OK. If it fails, it returns E_FAIL.

Remarks

The WMENC_longlong data type is a typedef from the CURRENCY type. A 64-bit integer is needed to hold the file size, and CURRENCY is the only 64-bit integer type that Automation supports. To manipulate the value, you can use the following:

    qwSize.int64

File size information does not persist after the encoding process has stopped.

Example code

// For an example that explains how to
// create and use an archive file, see the IWMEncFile object.
// The following example shows how to capture archiving statistics
// during the encoding process.

// Include libraries.

#include <windows.h>
#include "..\wmencode.h"

// Declare variables.

    HRESULT hr;
    IWMEncoder* pEncoder;
    IWMEncStatistics* pStatistics;
    IWMEncFileArchiveStats* pFileArchiveStats;
    IDispatch* pDispFileArchiveStats;
    WMENC_longlong qwDuration, qwSize;

// Initialize the COM library and retrieve a pointer
// to an IWMEncoder interface.

    hr = CoInitialize(NULL);
    CoCreateInstance(CLSID_WMEncoder,
                     NULL,
                     CLSCTX_INPROC_SERVER,
                     IID_IWMEncoder,
                    (void**) &pEncoder);

// Retrieve an IWMEncStatistics interface pointer.

    hr = pEncoder->get_Statistics(&pStatistics);

// Retrieve an IDispatch pointer for the IWMEncOutputStats
// interface.

    hr = pStatistics->get_FileArchiveStats(&pDispFileArchiveStats);

// Call QueryInterface for the IWMEncNetConnectionStats
// interface pointer.

    hr = pDispFileArchiveStats->QueryInterface(
                      IID_IWMEncFileArchiveStats,
                      (void**)&pFileArchiveStats);

// Manually configure the encoder engine or load
// a configuration from a file. For an example that illustrates
// how to configure the encoder engine, see the IWMEncFile object.

// Create a timer to retrieve the statistics
// after you start the encoder engine.

    pFileArchiveStats->get_FileDuration(&qwDuration);
    pFileArchiveStats->get_FileSize(&qwSize);

See Also

  • IWMEncFile Interface
  • IWMEncFileArchiveStats Interface


IWMEncIndexerStats Interface

The IWMEncIndexerStats interface monitors the indexing process for a Windows Media file. A file index enables operations, such as fast-forwarding, that must seek to specific time offsets in the file. If you specify an archive file and the AutoIndex property of the WMEncoder object is True, Windows Media Encoder automatically starts the indexing process on a separate thread in the background of the encoder engine. The indexing process stops at the end of the file or at the destruction of the WMEncoder object.

In addition to the methods inherited from IDispatch, the IWMEncIndexerStats interface exposes the following methods.

Method | Description
get_FileCount | Retrieves the number of files remaining in the indexing queue, including the file currently being indexed.
get_FileName | Retrieves the name of a specific file in the indexing queue.
get_PercentComplete | Retrieves the percentage of indexing completed for the file currently being indexed.

See Also

  • [Visual Basic] IWMEncIndexerStats Object
  • Interfaces (C++)


IWMEncIndexerStats::get_FileCount

The get_FileCount method retrieves the number of files remaining in the indexing queue, including the file currently being indexed.

Syntax

HRESULT get_FileCount(
  long*  plCount
);

Parameters

plCount

[out] Pointer to a long containing the number of files.

Return Values

If the method succeeds, it returns S_OK. If it fails, it returns an HRESULT error code.

Return code | Number | Meaning
E_FAIL | 0x80004005 | An unspecified error occurred.
E_POINTER | 0x80004003 | The pointer is NULL.

Example Code

// Include libraries.

#include <windows.h>
#include "wmencode.h"
#include <atlbase.h>

// Declare variables.

    HRESULT hr;
    IWMEncoder* pEncoder;
    IWMEncStatistics* pStats;
    IDispatch* pDispIndex;
    IWMEncIndexerStats* pIndexStats;
    long lFileCount, lPercent;
    CComBSTR bstrFileName;

// Initialize the COM library and retrieve a pointer
// to an IWMEncoder interface.

    hr = CoInitialize(NULL);
    CoCreateInstance(CLSID_WMEncoder,
                     NULL,
                     CLSCTX_INPROC_SERVER,
                     IID_IWMEncoder,
                     (void**) &pEncoder);

// Retrieve a pointer to an IWMEncAttributes interface.

    hr = pEncoder->get_Statistics(&pStats);

// Retrieve an IDispatch pointer to IWMEncIndexerStats interface.

    hr = pStats->get_IndexerStats(&pDispIndex);

// Call QueryInterface() to retrieve a pointer to the
// IWMEncIndexerStats interface.

    hr = pDispIndex->QueryInterface(IID_IWMEncIndexerStats,
                                    (void**) &pIndexStats);

// Retrieve information about the indexing process.

    hr = pIndexStats->get_FileCount(&lFileCount);
    hr = pIndexStats->get_FileName(0, &bstrFileName);
    hr = pIndexStats->get_PercentComplete(&lPercent);

See Also

  • IWMEncoder Interface
  • IWMEncIndexerStats Interface
  • IWMEncStatistics Interface


IWMEncIndexerStats::get_FileName

The get_FileName method retrieves the name of a specific file in the indexing queue.

Syntax

HRESULT get_FileName(
  long  lIndex,
  BSTR*  pbstrFileName
);

Parameters

lIndex

[in] long containing the index into the queue. The index is zero-based.

pbstrFileName

[out] Pointer to a BSTR containing the file name.

Return Values

If the method succeeds, it returns S_OK. If it fails, it returns an HRESULT error code.

Return code | Number | Meaning
E_FAIL | 0x80004005 | An unspecified error occurred.
E_POINTER | 0x80004003 | The pointer is NULL.
NS_E_INVALID_INDEX | 0xC00D1B66 | The index is invalid.

Example Code

// Include libraries.

#include <windows.h>
#include "..\\wmencode.h"
#include <atlbase.h>

// Declare variables.

    HRESULT hr;
    IWMEncoder* pEncoder;
    IWMEncStatistics* pStats;
    IDispatch* pDispIndex;
    IWMEncIndexerStats* pIndexStats;
    long lFileCount, lPercent;
    CComBSTR bstrFileName;

// Initialize the COM library and retrieve a pointer
// to an IWMEncoder interface.

    hr = CoInitialize(NULL);
    CoCreateInstance(CLSID_WMEncoder,
                     NULL,
                     CLSCTX_INPROC_SERVER,
                     IID_IWMEncoder,
                     (void**) &pEncoder);

// Retrieve a pointer to an IWMEncAttributes interface.

    hr = pEncoder->get_Statistics(&pStats);

// Retrieve an IDispatch pointer to IWMEncIndexerStats interface.

    hr = pStats->get_IndexerStats(&pDispIndex);

// Call QueryInterface() to retrieve a pointer to the
// IWMEncIndexerStats interface.

    hr = pDispIndex->QueryInterface(IID_IWMEncIndexerStats,
                                    (void**) &pIndexStats);

// Retrieve information about the indexing process.

    hr = pIndexStats->get_FileCount(&lFileCount);
    hr = pIndexStats->get_FileName(0, &bstrFileName);
    hr = pIndexStats->get_PercentComplete(&lPercent);

See Also

  • IWMEncoder Interface
  • IWMEncIndexerStats Interface
  • IWMEncStatistics Interface


IWMEncIndexerStats::get_PercentComplete

The get_PercentComplete method retrieves the percentage of indexing completed for the file currently being indexed.

Syntax

HRESULT get_PercentComplete(
  long*  plPercent
);

Parameters

plPercent

[out] Pointer to a long containing the percentage of indexing completed.

Return Values

If the method succeeds, it returns S_OK. If it fails, it returns an HRESULT error code.

Return code | Number | Meaning
E_FAIL | 0x80004005 | An unspecified error occurred.
E_POINTER | 0x80004003 | The pointer is NULL.

Example Code

// Include libraries.

#include <windows.h>
#include "..\\wmencode.h"
#include <atlbase.h>

// Declare variables.

    HRESULT hr;
    IWMEncoder* pEncoder;
    IWMEncStatistics* pStats;
    IDispatch* pDispIndex;
    IWMEncIndexerStats* pIndexStats;
    long lFileCount, lPercent;
    CComBSTR bstrFileName;

// Initialize the COM library and retrieve a pointer
// to an IWMEncoder interface.

    hr = CoInitialize(NULL);
    CoCreateInstance(CLSID_WMEncoder,
                     NULL,
                     CLSCTX_INPROC_SERVER,
                     IID_IWMEncoder,
                     (void**) &pEncoder);

// Retrieve a pointer to an IWMEncAttributes interface.

    hr = pEncoder->get_Statistics(&pStats);

// Retrieve an IDispatch pointer to IWMEncIndexerStats interface.

    hr = pStats->get_IndexerStats(&pDispIndex);

// Call QueryInterface() to retrieve a pointer to the
// IWMEncIndexerStats interface.

    hr = pDispIndex->QueryInterface(IID_IWMEncIndexerStats,
                                    (void**) &pIndexStats);

// Retrieve information about the indexing process.

    hr = pIndexStats->get_FileCount(&lFileCount);
    hr = pIndexStats->get_FileName(0, &bstrFileName);
    hr = pIndexStats->get_PercentComplete(&lPercent);

See Also

  • IWMEncoder Interface
  • IWMEncIndexerStats Interface
  • IWMEncStatistics Interface


IWMEncNetConnectionStats Interface

The IWMEncNetConnectionStats interface identifies the number of clients connected to the computer that is hosting Windows Media Encoder, and the protocol and IP address of a specific client. In addition to the methods inherited from IDispatch, the IWMEncNetConnectionStats interface exposes the following methods.

Method | Interface
get_ClientCount | Retrieves the number of clients connected to Windows Media Encoder.
get_ClientInfo | Retrieves the protocol and IP address of a specific client.

See Also

  • [Visual Basic] IWMEncNetConnectionStats Object
  • Interfaces (C++)


IWMEncNetConnectionStats::get_ClientCount

The get_ClientCount method retrieves the number of clients connected to Windows Media Encoder.

Syntax

HRESULT get_ClientCount(
  long*  plCount
);

Parameters

plCount

[out] Pointer to a long containing the number of connected clients.

Return Values

If the method succeeds, it returns S_OK. If it fails, it returns an HRESULT error code.

Return code | Number | Meaning
E_FAIL | 0x80004005 | An unspecified error occurred.
E_POINTER | 0x80004003 | The pointer is NULL.

Remarks

Windows Media Encoder can unicast and multicast from a Windows Media server, and up to 50 clients can connect directly to the computer hosting Windows Media Encoder. You must start the encoder engine before calling get_ClientCount.

Example Code

// Include libraries.

#include <windows.h>
#include <atlbase.h>   // Includes CComBSTR.
#include "wmencode.h"

// Declare variables.

    HRESULT hr;
    IWMEncoder* pEncoder;
    IWMEncStatistics* pStatistics;
    IWMEncNetConnectionStats* pNetConnStats;
    IDispatch* pDispNetConnStats;

    long lCount;
    int i;

// Initialize the COM library and retrieve a pointer
// to an IWMEncoder interface.

    hr = CoInitialize(NULL);
    CoCreateInstance(CLSID_WMEncoder,
                     NULL,
                     CLSCTX_INPROC_SERVER,
                     IID_IWMEncoder,
                    (void**) &pEncoder);

// Load a pre-defined configuration from a .wme file

    CComBSTR bstrFileName(L"file_name");
    hr = pEncoder->Load(bstrFileName);

// Start the encoder engine.

    hr = pEncoder->Start();

// Retrieve an IWMEncStatistics interface pointer.

    hr = pEncoder->get_Statistics(&pStatistics);

// Retrieve an IDispatch pointer for the IWMEncNetConnectionStats
// interface.

    hr = pStatistics->get_NetConnectionStats(&pDispNetConnStats);

// Call QueryInterface for the IWMEncNetConnectionStats
// interface pointer.

    hr = pDispNetConnStats->QueryInterface(IID_IWMEncNetConnectionStats,
                                          (void**)&pNetConnStats);

// Retrieve the number of connected clients.

    hr = pNetConnStats->get_ClientCount(&lCount);

// Retrieve the IP address of each client.

    WMENC_BROADCAST_PROTOCOL wmeProtocol;
    for (i=1; i=lCount; i++)
    {
        CComBSTR bstrIPAddr;
        hr = pNetConnStats->get_ClientInfo(i, &wmeProtocol, &bstrIPAddr);
    }

See Also

  • IWMEncNetConnectionStats Interface


IWMEncNetConnectionStats::get_ClientInfo

The get_ClientInfo method retrieves the protocol and IP address of a specific client.

Syntax

HRESULT get_ClientInfo(
  long  lIndex,
  WMENC_BROADCAST_PROTOCOL*  pProtocal,
  BSTR*  pbstrIP
);

Parameters

lIndex

[in] long containing the index identifying the client.

pProtocal

[out] Pointer to a member of a WMENC_BROADCAST_PROTOCOL enumeration type indicating the type of protocol through which the client is connected. This must be the following value.

Value | Number | Description
HTTP | 1 | The transmission uses the HTTP protocol.

pbstrIP

[out] Pointer to a BSTR containing the IP address of the client.

Return Values

If the method succeeds, it returns S_OK. If it fails, it returns an HRESULT error code.

Return code | Number | Meaning
E_FAIL | 0x80004005 | An unspecified error occurred.
E_POINTER | 0x80004003 | The pointer is NULL.

Remarks

You can use this method to monitor client connections. For instance, you can determine how many clients are connected from a specific range of IP addresses. You must start the encoder engine before calling get_ClientInfo.

Example Code

// Include libraries.

#include <windows.h>
#include <atlbase.h>   // Includes CComBSTR.
#include "wmencode.h"

// Declare variables.

    HRESULT hr;
    IWMEncoder* pEncoder;
    IWMEncStatistics* pStatistics;
    IWMEncNetConnectionStats* pNetConnStats;
    IDispatch* pDispNetConnStats;

    long lCount;
    int i;

// Initialize the COM library and retrieve a pointer
// to an IWMEncoder interface.

    hr = CoInitialize(NULL);
    CoCreateInstance(CLSID_WMEncoder,
                     NULL,
                     CLSCTX_INPROC_SERVER,
                     IID_IWMEncoder,
                    (void**) &pEncoder);

// Load a predefined configuration from a .wme file

    CComBSTR bstrFileName(L"file_name");
    hr = pEncoder->Load(bstrFileName);

// Start the encoder engine.

    hr = pEncoder->Start();

// Retrieve an IWMEncStatistics interface pointer.

    hr = pEncoder->get_Statistics(&pStatistics);

// Retrieve an IDispatch pointer for the IWMEncNetConnectionStats
// interface.

    hr = pStatistics->get_NetConnectionStats(&pDispNetConnStats);

// You must callQueryInterface for the IWMEncNetConnectionStats
// interface pointer.

    hr = pDispNetConnStats->QueryInterface(IID_IWMEncNetConnectionStats,
                                          (void**)&pNetConnStats);

// Retrieve the number of connected clients.

    hr = pNetConnStats->get_ClientCount(&lCount);

// Retrieve the IP address of each client.

    CComBSTR bstrIPAddr = NULL;
    WMENC_BROADCAST_PROTOCOL wmeProtocol;
    for (i=1; i=lCount; i++)
    {
        hr = pNetConnStats->get_ClientInfo(i, &wmeProtocol, &bstrIPAddr);
    }

See Also

  • IWMEncNetConnectionStats Interface


IWMEncoder Interface

The IWMEncoder interface runs Windows Media Encoder. If you are implementing the predefined user interface, you must acquire IWMEncoder through a WMEncoderApp object. If you are not implementing a UI or are implementing a custom UI, acquire IWMEncoder through a WMEncoder object.

In addition to the methods inherited from IDispatch, the IWMEncoder interface exposes the following methods.

Method | Description
Archive | Starts, pauses, or stops the archiving process.
GenerateBroadcastInfo | Configures the encoder engine so that a multicast publishing point can be created.
get_ArchiveState | Retrieves a member of an enumeration type indicating whether the archiving process is running.
get_Attributes | Retrieves a pointer to a collection of user-defined name-value pairs.
GetAudioLevel | Retrieves the minimum, average, and maximum volume for the left and right channels of an audio source stream.
get_AutoIndex | Retrieves a Boolean value indicating whether the archive file will be indexed after the archiving process is completed.
get_Autostop | Retrieves a Boolean value that indicates whether the encoding process will be automatically stopped after source content from an audio/visual file has been completely encoded to a Windows Media file.
get_Broadcast | Retrieves the port number and protocol for broadcasting encoded content.
get_DisplayInfo | Retrieves a description of the encoded content. Typically this includes author, copyright, rating, and title information.
get_EnableAutoArchive | Retrieves a Boolean value indicating whether the archiving process will start automatically when the encoder engine starts.
get_ErrorState | Retrieves Windows Media Encoder run-time errors.
get_File | Retrieves an IWMEncFile interface that can be used to specify the name of an archive file.
get_IndexerState | Retrieves the state of the indexing process.
get_Name | Retrieves the unique name of a WMEncoder object for remote administration.
get_ProfileCollection | Retrieves the collection of profiles.
get_RecordingLevel | Retrieves the volume level of a specific audio stream.
get_RecordingMute | Retrieves a Boolean value indicating whether a specific audio stream is muted.
get_RemoteAdmin | Retrieves a Boolean value indicating whether Windows Media Encoder can be remotely controlled.
get_RunState | Retrieves a member of an enumeration type indicating whether the encoder is running.
get_SourceGroupCollection | Retrieves the collection of source groups.
get_SourcePluginInfoManager | Retrieves a collection of objects containing source plug-in information.
get_Statistics | Retrieves a statistics interface that can be used to provide status information about the encoding session.
get_TransformPluginInfoManager | Retrieves a collection of objects containing transform plug-in information.
Indexer | Cancels the indexing process before it is completed.
Load | Loads an existing configuration from a file.
PrepareToEncode | Prepares the encoder engine for starting.
put_AutoIndex | Specifies a Boolean value indicating whether the archive file will be indexed after the archiving process is completed.
put_AutoStop | Specifies a Boolean value that automatically stops the encoding process after source content from an audio/visual file has been completely encoded to a Windows Media file.
put_EnableAutoArchive | Specifies a Boolean value indicating whether the archiving process will start automatically when the encoder engine starts.
put_Name | Specifies the unique name of a WMEncoder object for remote administration.
put_RecordingLevel | Specifies the volume level of a specific audio stream.
put_RecordingMute | Mutes an audio stream.
put_RemoteAdmin | Specifies a Boolean value indicating whether Windows Media Encoder can be remotely controlled
Reset | Removes the current configuration settings.
Save | Saves the current configuration to a file.
SendScript | Sends script to Windows Media Encoder.
SetLocaleID | Specifies the national language used by Windows Media Encoder.
Start | Starts Windows Media Encoder.
Stop | Stops Windows Media Encoder.

See Also

  • [Visual Basic] WMEncoder Object
  • IWMEncoderApp Interface
  • Interfaces (C++)


IWMEncoder::Archive

The Archive method starts,pauses, or stops the archiving process.

Syntax

HRESULT Archive(
  WMENC_ARCHIVE_TYPE  enumArchiveType,
  WMENC_ARCHIVE_OPERATION  enumArchiveOp
);

Parameters

enumArchiveType

[in] Member of an enumeration type indicating where encoded content is stored. This parameter must be the following value.

Value | Number | Meaning
WMENC_ARCHIVE_LOCAL | 1 | Encoded content is saved on the computer performing the encoding or on the local network to which that computer is attached.

enumArchiveOp

[in] Member of a WMENC_ARCHIVE_OPERATION enumeration type indicating the archiving state. This parameter must be one of the following values.

Value | Number | Meaning
WMENC_ARCHIVE_START | 1 | Start archiving.
WMENC_ARCHIVE_STOP | 2 | Stop archiving.
WMENC_ARCHIVE_PAUSE | 3 | Pause archiving.

Return Values

If the method succeeds, it returns S_OK. If it fails, it supports the IErrorInfo interface and returns an HRESULT error code.

Return code | Number | Meaning
NS_E_INVALIDCALL_WHILE_ENCODER_STOPPED | 0xC00D1B7F | This method cannot be called if the encoder engine is stopped.
NS_E_UNSUPPORTED_ARCHIVETYPE | 0xC00D1B77 | You can only save encoded content to a local file.
NS_E_UNSUPPORTED_ARCHIVEOPERATION | 0xC00D1B78 | You can only start, stop, or pause the archiving process.

Remarks

You can use the Archive method to override the IWMEncoder::put_EnableAutoArchive and IWMEncSourceGroup::put_AutoArchive methods. If both of these are set to VARIANT_TRUE, archiving automatically starts when encoding of the relevant source group starts.

Example Code

// Include libraries.

#include <windows.h>
#include "wmencode.h"

// Declare variables.

    HRESULT hr;
    IWMEncoder* pEncoder;

// Initialize the COM library and retrieve a pointer
// to an IWMEncoder interface.

    hr = CoInitialize(NULL);
    CoCreateInstance(CLSID_WMEncoder,
                     NULL,
                     CLSCTX_INPROC_SERVER,
                     IID_IWMEncoder,
                    (void**) &pEncoder);

// Load a predefined configuration. The file name extension must
// be .wme.

    hr = pEncoder->Load(L"C:\\file_name.wme");

// Start the encoder engine.

    hr = pEncoder->Start();

// Start the archiving process.

    hr = pEncoder->Archive(WMENC_ARCHIVE_LOCAL, WMENC_ARCHIVE_START);

See Also

  • IWMEncoder Interface
  • IWMEncSourceGroup::put_AutoArchive
  • IWMEncoder::put_EnableAutoArchive


IWMEncoder::GenerateBroadcastInfo

The GenerateBroadcastInfo method configures the encoder engine so that you can easily create a multicast publishing point.

Syntax

HRESULT GenerateBroadcastInfo(
  BSTR  bstrFileName
);

Parameters

bstrFileName

[in] BSTR specifying the name of the Windows Media file that contains the configuration information.

Return Values

If the method succeeds, it returns S_OK. If it fails, it supports the IErrorInfo interface and returns an HRESULT error code.

Return code | Number | Meaning
NS_E_NOSOURCEGROUPS | 0xC00D1B72 | No source group is active.

Remarks

This GenerateBroadcastInfo method automatically generates a Windows Media file containing the current configuration but no multimedia content. You can use this file to set up a broadcast publishing point on the Windows Media server. At a minimum you must define both a profile and a source group. You can also specify attributes, an archive file, descriptive information and a broadcast port number.

See Also

  • IWMencBroadcast Interface
  • IWMEncDisplayInfo Interface
  • IWMEncFile Interface
  • IWMEncoder Interface
  • IWMEncProfile Interface
  • IWMEncSourceGroup Interface


IWMEncoder::get_ArchiveState

The get_ArchiveState method retrieves a member of an enumeration type indicating whether content is being archived.

Syntax

HRESULT get_ArchiveState(
  WMENC_ARCHIVE_TYPE  enumType,
  WMENC_ARCHIVE_OPERATION*  penumArchiveState
);

Parameters

enumType

[in] Member of a WMENC_ARCHIVE_TYPE enumeration type indicating where encoded content is stored. This parameter must be the following value.

Value | Number | Meaning
WMENC_ARCHIVE_LOCAL | 1 | Encoded content is saved on the computer performing the encoding or the local network to which that computer is connected.

penumArchiveState

[out] Member of a WMENC_ARCHIVE_OPERATION enumeration type indicating whether the archiving process has been started or stopped. This parameter must be one of the following values.

Value | Number | Meaning
WMENC_ARCHIVE_RUNNING | 1 | The archiving process is running.
WMENC_ARCHIVE_PAUSED | 2 | The archiving process has paused.
WMENC_ARCHIVE_STOPPED | 3 | The archiving process has stopped.

Return Values

If the method succeeds, it returns S_OK. If it fails, it supports the IErrorInfo interface and returns an HRESULT error code.

Return code | Number | Meaning
E_POINTER | 0x80004003 | The pointer to the archive state is NULL.
NS_E_UNSUPPORTED_ARCHIVETYPE | 0xC00D1B77 | You can only specify WMENC_ARCHIVE_LOCAL as the archive type.

Example code

// Configure Windows Media Encoder to archive encoded content.
// For a complete example, see either the IWMEncFile object or the
// IWMEncFileArchiveStats object.

WMENC_ARCHIVE_STATE enumArchiveState;
hr = pEncoder->get_ArchiveState(WMENC_ARCHIVE_LOCAL,
                                &enumArchiveState);

switch ( enumArchiveState )
{
    case WMENC_ARCHIVE_RUNNING:
        // Process the case.
        break;
    case WMENC_ARCHIVE_PAUSED:
        // Process the case.
        break;
    case WMENC_ARCHIVE_STOPPED:
        // Process the case.
        break;
    default:
        break;
}

See Also

  • IWMEncFile Interface
  • IWMEncFileArchiveStats Interface
  • IWMEncoder Interface


IWMEncoder::get_Attributes

The get_Attributes method retrieves a pointer to a collection of user-defined name-value pairs.

Syntax

HRESULT get_Attributes(
  IWMEncAttributes**  ppAttributes
);

Parameters

ppAttributes

[out] Pointer to a pointer to an IWMEncAttributes interface containing a collection of attributes.

Return Values

If the method succeeds, it returns S_OK. If it fails, it supports the IErrorInfo interface and returns an HRESULT error code.

Return code | Number | Meaning
E_FAIL | 0x80004005 | An unspecified error occurred.
E_POINTER | 0x80004003 | The indirect pointer to the attributes object is NULL.

Remarks

Attributes are name-value pairs representing extra information about the output of the encoder or the encoding session. They are defined by the author and stored in an attributes collection. Both the name and the value are BSTR types.

Example Code

// Include libraries.

#include <windows.h>
#include "wmencode.h"

// Declare variables.

HRESULT hr;
IWMEncoder* pEncoder;
IWMEncAttributes* pAttr;

// Initialize the COM library and retrieve a pointer
// to an IWMEncoder interface.

hr = CoInitialize(NULL);
CoCreateInstance(CLSID_WMEncoder,
                 NULL,
                 CLSCTX_INPROC_SERVER,
                 IID_IWMEncoder,
                (void**) &pEncoder);

// Retrieve a pointer to an IWMEncAttributes interface.

hr = pEncoder->get_Attributes(&pAttr);

See Also

  • IWMEncAttributes Interface
  • IWMEncoder Interface


IWMEncoder::GetAudioLevel

The GetAudioLevel method retrieves the minimum, average, and maximum volume for the left and right channels of an audio source stream.

Syntax

HRESULT get_AudioLevel(
  short  iIndex,
  long*  plDuration,
  DOUBLE*  pdLMin,
  DOUBLE*  pdLAvg,
  DOUBLE*  pdLMax,
  DOUBLE*  pdRMin,
  DOUBLE*  pdRAvg,
  DOUBLE*  pdRMax
);

Parameters

units

[in] Member of a WMENC_AUDIOLEVEL_UNITS enumeration type indicating the type of units for the volume. This must be one of the following values.

Value | Description
WMENC_AUDIOLEVEL_DB | This is not implemented in the current release of Windows Media Encoder. Specifying this type returns E_NOTIMPL.
WMENC_AUDIOLEVEL_LINEAR | The volume units are expressed on a linear scale.

iIndex

[in] short containing the index of the source stream. In the current Windows Media Encoder, you must specify zero. If you specify a nonzero index, the get_AudioLevel method returns an error code.

plDuration

[in, out] On input, pointer to a long containing the length of time, in milliseconds, for which you want to retrieve an average volume level. On output, this parameter contains the length of time for which volume information was retrieved. If you specify a duration that exceeds the duration of the stream, the stream duration is retrieved.

pdLMin

[out] Pointer to a DOUBLE containing the minimum volume, in decibels, in the left audio channel over the specified time period.

pdLAvg

[out] Pointer to a DOUBLE containing the average volume, in decibels, in the left audio channel over the specified time period.

pdLMax

[out] Pointer to a DOUBLE containing the maximum volume, in decibels, in the left audio channel over the specified time period.

pdRMin

[out] Pointer to a DOUBLE containing the minimum volume, in decibels, in the right audio channel over the specified time period.

plRAvg

[out] Pointer to a DOUBLE containing the average volume, in decibels, in the right audio channel over the specified time period.

pdRMax

[out] Pointer to a DOUBLE containing the maximum volume, in decibels, in the right audio channel over the specified time period.

Return Values

If the method succeeds, it returns S_OK. If it fails, it supports the IErrorInfo interface and returns an HRESULT error code.

Return code | Number | Meaning
E_FAIL | 0x80004005 | An unspecified error occurred.
E_INVALIDARG | 0x80070057 | A parameter is not valid.

See Also

  • IWMEncoder Interface


IWMEncoder::get_AutoIndex

The get_AutoIndex method retrieves a Boolean value indicating whether the archive file will be indexed after the archiving process is completed.

Syntax

HRESULT get_AutoIndex(
  VARIANT_BOOL*  pbAutoIndex
);

Parameters

pbAutoIndex

[out] Pointer to a VARIANT_BOOL indicating whether the encoded content will be automatically indexed after it is archived.

Return Values

If the method succeeds, it returns S_OK. If it fails, it supports the IErrorInfo interface and returns an HRESULT error code.

Return code | Number | Meaning
E_POINTER | 0x80004003 | The pointer to the Boolean value is NULL.

Remarks

Use the IWMEncoder::put_AutoIndex method to specify the Boolean value.

Example Code

// Include libraries.

#include <windows.h>
#include "wmencode.h"

// Declare variables.

    HRESULT hr;
    IWMEncoder* pEncoder;
    VARIANT_BOOL* vbAutoIndex = 0;

// Initialize the COM library and retrieve a pointer
// to an IWMEncoder interface.

    hr = CoInitialize(NULL);
    CoCreateInstance(CLSID_WMEncoder,
                     NULL,
                     CLSCTX_INPROC_SERVER,
                     IID_IWMEncoder,
                     (void**) &pEncoder);

// Configure Windows Media Encoder to archive encoded content.
// For a complete example, see either the IWMEncFile object or the
// IWMEncFileArchiveStats object.

// Specify automatic indexing.

    pEncoder->put_AutoIndex(VARIANT_TRUE);

// Retrieve the automatic indexing state.

    pEncoder->get_AutoIndex(vbAutoIndex);

See Also

  • IWMEncFile Interface
  • IWMEncFileArchiveStats Interface
  • IWMEncoder Interface
  • IWMEncoder::put_AutoIndex


IWMEncoder::get_AutoStop

The get_AutoStop method retrieves a Boolean value that indicates whether the encoding process will be automatically stopped after source content from an audio/visual file has been completely encoded to a Windows Media file.

Syntax

HRESULT get_AutoStop(
  VARIANT_BOOL*  pbStop
);

Parameters

pbStop

[out] Pointer to a VARIANT_BOOL identifying whether the encoder engine automatically stops.

Return Values

If the method succeeds, it returns S_OK. If it fails, it supports the IErrorInfo interface and returns an HRESULT error code.

Return code | Number | Meaning
E_POINTER | 0x80004003 | The pointer to the Boolean value is NULL.

Remarks

The get_AutoStop method defaults to VARIANT_TRUE. The value of pbStop can be changed while Windows Media Encoder is running. Use the IWMEncoder::put_AutoStop method to set the value.

Example Code

// Include libraries.

#include <windows.h>
#include "wmencode.h"

// Declare variables.

    HRESULT hr;
    IWMEncoder* pEncoder;
   VARIANT_BOOL* vbAutoStop = 0;

// Initialize the COM library and retrieve a pointer
// to an IWMEncoder interface.

    hr = CoInitialize(NULL);
    CoCreateInstance(CLSID_WMEncoder,
                     NULL,
                     CLSCTX_INPROC_SERVER,
                     IID_IWMEncoder,
                     (void**) &pEncoder);

// Configure Windows Media Encoder to archive encoded content.
// For a complete example, see either the IWMEncFile object or the
// IWMEncFileArchiveStats object.

// Specify automatic stopping.

    pEncoder->put_AutoStop(VARIANT_TRUE);

// Retrieve the Boolean value.

    pEncoder->get_AutoIndex(vbAutoStop);

See Also

  • IWMEncFile Interface
  • IWMEncFileArchiveStats Interface
  • IWMEncoder Interface
  • IWMEncoder::put_AutoStop


IWMEncoder::get_Broadcast

The get_Broadcast method retrieves the port number and protocol for broadcasting encoded content.

Syntax

HRESULT get_Broadcast(
  IWMEncBroadcast**  ppBroadcast
);

Parameters

ppBroadcast

[out] Pointer to a pointer to an IWMEncBroadcast interface.

Return Values

If the method succeeds, it returns S_OK. If it fails, it supports the IErrorInfo interface and returns an HRESULT error code.

Return code | Number | Meaning
E_FAIL | 0x80004005 | An unspecified error occurred.
E_POINTER | 0x80004003 | The indirect pointer to the broadcast object is NULL.

Remarks

Use this method to acquire a broadcast object so that you can specify and retrieve the port number and protocol used for transmitting encoded content. Currently, only HTTP can be used. The default port number is 80, but other ports can be used.

Example Code

// Include libraries.

#include <windows.h>
#include "wmencode.h"

// Declare variables.

    HRESULT hr;
    IWMEncoder* pEncoder;
    IWMEncBroadcast* pBroadcast;
    long lPortNmbr = 2356;

// Initialize the COM library and retrieve a pointer
// to an IWMEncoder interface.

    hr = CoInitialize(NULL);
    CoCreateInstance(CLSID_WMEncoder,
                     NULL,
                     CLSCTX_INPROC_SERVER,
                     IID_IWMEncoder,
                     (void**) &pEncoder);

// Configure Windows Media Encoder to archive encoded content.
// For a complete example see either the IWMEncFile object or the
// IWMEncFileArchiveStats object.

// Retrieve a pointer to an IWMEncBroadcast interface.

    pEncoder->get_Broadcast(&pBroadcast);

// Specify the port number.

    pBroadcast->put_PortNumber(WMENC_PROTOCOL_HTTP, lPortNmbr);

// Retrieve the port number.

    pBroadcast->get_PortNumber(WMENC_PROTOCOL_HTTP, &lPortNmbr);

See Also

  • IWMEncBroadcast Interface
  • IWMEncoder Interface


IWMEncoder::get_DisplayInfo

The get_DisplayInfo method retrieves a description of the encoded content. Typically this includes author, copyright, rating and title information.

Syntax

HRESULT get_DisplayInfo(
  IWMEncDisplayInfo**  ppDisplayInfo
);

Parameters

ppDisplayInfo

[out] Pointer to a pointer to an IWMEncDisplayInfo interface containing string descriptions of the encoded content.

Return Values

If the method succeeds, it returns S_OK. If it fails, it supports the IErrorInfo interface and returns an HRESULT error code.

Return code | Number | Meaning
E_FAIL | 0x80004005 | An unspecified error occurred.
E_POINTER | 0x80004003 | The indirect pointer to the display information object is NULL.

Remarks

Use the acquired IWMEncDisplayInfo Interface interface to set or retrieve the name of the author, copyright data, a general content description, a rating and a title.

Example Code

// Include libraries.

#include <windows.h>
#include <atlbase.h>               // Includes CComBSTR.
#include "wmencode.h"

// Declare variables.

HRESULT hr;
IWMEncoder* pEncoder;
IWMEncDisplayInfo* pDispInfo;
CComBSTR m_bstrAuthor("Content Author's name.");
CComBSTR m_bstrCopyright("Copyright 2000. All rights reserved.");
CComBSTR m_bstrDescription("Description of the encoded content.");
CComBSTR m_bstrRating("Content rating.");
CComBSTR m_bstrTitle("Title of the encoded content.");

// Initialize the COM library and retrieve a pointer
// to an IWMEncoder interface.

hr = CoInitialize(NULL);
CoCreateInstance(CLSID_WMEncoder,
                 NULL,
                 CLSCTX_INPROC_SERVER,
                 IID_IWMEncoder,
                 (void**) &pEncoder);

// Retrieve a pointer to an IWMEncDisplayInfo interface.

hr = pEncoder->get_DisplayInfo(&pDispInfo);

// Set the data members of the IWMEncDisplayInfo interface.

hr = pDispInfo->put_Author(m_bstrAuthor);
hr = pDispInfo->put_Copyright(m_bstrCopyright);
hr = pDispInfo->put_Description(m_bstrDescription);
hr = pDispInfo->put_Rating(m_bstrRating);
hr = pDispInfo->put_Title(m_bstrTitle);

// Retrieve the data members of the IWMEncDisplayInfo interface.

hr = pDispInfo->get_Author(&m_bstrAuthor);
hr = pDispInfo->get_Copyright(&m_bstrCopyright);
hr = pDispInfo->get_Description(&m_bstrDescription);
hr = pDispInfo->get_Rating(&m_bstrRating);
hr = pDispInfo->get_Title(&m_bstrTitle);

See Also

  • IWMEncDisplayInfo Interface
  • IWMEncoder Interface


IWMEncoder::get_EnableAutoArchive

The get_EnableAutoArchive method retrieves a Boolean value indicating whether the archiving process will start automatically when the encoder engine starts.

Syntax

HRESULT get_EnableAutoArchive(
  VARIANT_BOOL*  pbEnableAutoArchive
);

Parameters

pbEnableAutoArchive

[out] Pointer to a VARIANT_BOOL indicating whether archiving is automatic.

Return Values

If the method succeeds, it returns S_OK. If it fails, it supports the IErrorInfo interface and returns an HRESULT error code.

Return code | Number | Meaning
E_POINTER | 0x80004003 | The pointer to the Boolean value is NULL.

Remarks

Use the IWMEncSourceGroup::put_AutoArchive method to automatically control source group archiving. Use the IWMEncoder::put_EnableAutoArchive method to specify whether archiving can be automatically controlled.

Example Code

// Include libraries.

#include <windows.h>
#include <atlbase.h>
#include "wmencode.h"

// Declare variables.

   HRESULT hr;
   IWMEncoder* pEncoder;
   IWMEncSourceGroupCollection* pSrcGrpColl;
   IWMEncSourceGroup* pSrcGrp;
   IWMEncSource* pAudSrc;
   IWMEncSource* pVidSrc;
   IWMEncProfileCollection* pProColl;
   IWMEncProfile* pPro;
   IWMEncFile* pFile;
   long lCount;
   int i;

// Initialize the COM library and retrieve a pointer
// to an IWMEncoder interface.

   hr = CoInitialize(NULL);
   CoCreateInstance(CLSID_WMEncoder,
                    NULL,
                    CLSCTX_INPROC_SERVER,
                    IID_IWMEncoder,
                   (void**) &pEncoder);

// Retrieve a pointer to an IWMEncSourceGroupCollection
// interface.

   hr = pEncoder->get_SourceGroupCollection(&pSrcGrpColl);

// Add an empty source group to the collection.

   hr = pSrcGrpColl->Add(L"SG_1", &pSrcGrp);

// Add an audio and video stream to the source group.

   hr = pSrcGrp->AddSource(WMENC_AUDIO, &pAudSrc);
   hr = pSrcGrp->AddSource(WMENC_VIDEO, &pVidSrc);

// Retrieve a pointer to an IWMEncFile interface.

   hr = pEncoder->get_File( &pFile );

// Specify an .avi source file and a Windows Media file with a .wmv extension for the output.

   CComBSTR m_bstrInFile(L"C:\\file_name");
   CComBSTR m_bstrOutFile(L"C:\\file_name");

   hr = pAudSrc->SetInput(m_bstrInFile);
   hr = pVidSrc->SetInput(m_bstrInFile);
   hr = pFile->put_LocalFileName(m_bstrOutFile);

// Retrieve the name of the output file.

   CComBSTR m_bstrFileName(L" ");
   hr = pFile->get_LocalFileName(&m_bstrFileName);

// Loop through the profile collection and retrieve a specific
// profile. You can find the profile name in the Profile Manager.

   hr = pEncoder->get_ProfileCollection(&pProColl);
   CComBSTR m_bstrName(L" ");
   CComVariant m_varProfile;
   m_varProfile.vt = VT_DISPATCH;
   hr = pProColl->get_Count(&lCount);
   for (i=0; i<lCount; i++)
   {
      hr = pProColl->Item(i, &pPro);
      hr = pPro->get_Name(&m_bstrName);
      if (_wcsicmp(m_bstrName, L"profile_name")==0)
      {
         m_varProfile.pdispVal = pPro;
         pSrcGrp->put_Profile(m_varProfile);
         break;
      }
   }

// Start archiving when the encoder engine starts. This is the default.

   hr = pEncoder->put_EnableAutoArchive(VARIANT_TRUE);

// Retrieve the automatic archiving state

   VARIANT_BOOL vbAutoArchive;
   hr = pEncoder->get_EnableAutoArchive(&vbAutoArchive);

// Initialize and start the encoder engine. To determine when the
// encoding and archiving process has ended, you must implement the
// OnArchiveStateChange event in the _IWMEncoderEvents interface.

   hr = pEncoder->PrepareToEncode(VARIANT_TRUE);
   hr = pEncoder->Start();

See Also

  • IWMEncFile Interface
  • IWMEncFileArchiveStats Interface
  • IWMEncoder Interface
  • IWMEncoder::put_EnableAutoArchive
  • IWMEncSourceGroup::put_AutoArchive


IWMEncoder::get_ErrorState

The get_ErrorState method retrieves Windows Media Encoder run-time errors.

Syntax

HRESULT get_ErrorState(
  long*  plResult
);

Parameters

plResult

[out] Pointer to a long containing the error value.

Return Values

If the method succeeds, it returns S_OK.

Remarks

Use this method to retrieve errors that occur while Windows Media Encoder is running. The OnError method in the _IWMEncoderEvents interface also provides similar functionality. Use the IWMEncoder::getRunState method to determine if Windows Media Encoder is stopped or started.

Example Code

// Include libraries.

#include <windows.h>
#include "wmencode.h"

// Declare variables.

    HRESULT hr;
    IWMEncoder* pEncoder;
    long lError;

// Initialize the COM library and retrieve a pointer
// to an IWMEncoder interface.

    hr = CoInitialize(NULL);
    CoCreateInstance(CLSID_WMEncoder,
                     NULL,
                     CLSCTX_INPROC_SERVER,
                     IID_IWMEncoder,
                    (void**) &pEncoder);

// Load a predefined configuration. The file name extension must
// be .wme.

    hr = pEncoder->Load(L"C:\\file_name.wme");

// Initialize and start the encoder engine.

    hr = pEncoder->PrepareToEncode(VARIANT_TRUE);
    hr = pEncoder->Start();

// Retrieve errors.

    hr = pEncoder->get_ErrorState(&lError);

    if (lError = 123456)
    {
         // Process the error.
    }

// Stop the encoder engine.

    hr = pEncoder->Stop();

See Also

  • _IWMEncoderEvents Interface
  • _IWMEncoderEvents::OnError
  • IWMEncoder::getRunState
  • IWMEncoder Interface


IWMEncoder::get_File

The get_File method retrieves an IWMEncFile interface that can be used to specify the name of an archive file.

Syntax

HRESULT get_File(
  IWMEncFile**  ppFile
);

Parameters

ppFile

[out] Pointer to a pointer to an IWMEncFile interface containing the full path of the file.

Return Values

If the method succeeds, it returns S_OK. If it fails, it supports the IErrorInfo interface and returns an HRESULT error code.

Return code | Number | Meaning
E_FAIL | 0x80004005 | An unspecified error occurred.
E_POINTER | 0x80004003 | The indirect pointer to the file object is NULL.

Remarks

Use the acquired IWMEncFile interface to specify and retrieve the file name, directory, and extension.

Example Code

// Include libraries.

#include <windows.h>
#include <atlbase.h>
#include "wmencode.h"

// Declare variables.

    HRESULT hr;
    IWMEncoder* pEncoder;
    IWMEncFile* pFile;
    long lError;

// Initialize the COM library and retrieve a pointer
// to an IWMEncoder interface.

    hr = CoInitialize(NULL);
    CoCreateInstance(CLSID_WMEncoder,
                    NULL,
                    CLSCTX_INPROC_SERVER,
                    IID_IWMEncoder,
                   (void**) &pEncoder);

// Load a predefined configuration. Configuration files
// have a .wme file name extension.

    hr = pEncoder->Load(L"C:\\file_name.wme");

// Retrieve an IWMEncFile interface and override the name
// of the archiving file in the configuration.

    hr = pEncoder->get_File(&pFile);
    hr = pFile->put_LocalFileName(L"C:\\archive_file_name.avi");

// Initialize and start the encoder engine. To determine when the
// encoding and archiving process has ended, you must implement the
// OnArchiveStateChange event in the _IWMEncoderEvents interface.

   hr = pEncoder->PrepareToEncode(VARIANT_TRUE);
   hr = pEncoder->Start();

See Also

  • IWMEncoder Interface
  • IWMEncFile Interface


IWMEncoder::get_IndexerState

The get_IndexerState method retrieves the state of the indexing process.

Syntax

HRESULT get_IndexerState(
  WMENC_INDEXER_STATE*  penumIndexerState
);

Parameters

penumIndexerState

[in] Member of a WMENC_INDEXER_STATE enumeration type that specifies the state of the indexing process. This must be one of the following values

Value | Number | Description
WMENC_INDEXER_RUNNING | 1 | The indexing process has been started.
WMENC_INDEXER_STOPPED | 2 | The indexing process has been stopped.

Return Values

If the method succeeds, it returns S_OK.

Remarks

A file index enables operations, such as fast forwarding, that must seek to specific time offsets in a stream. If you specify an archive file, Windows Media Encoder automatically indexes that file on a separate, low priority thread running in the background immediately after the archiving process stops. You can use this property in a timer, or you can create an event sink and use the OnIndexerStateChange method in the _IWMEncoderEvents Interface object.

Example Code

    WMENC_INDEXER_STATE enumIndexerState;
    hr = pEncoder->get_IndexerState(&enumIndexerState);
    if (enumIndexerState = WMENC_INDEXER_RUNNING)
    {
        // Stop the indexing process.
        hr = pEncoder->Indexer(WMENC_INDEXER_STOP);
    }

See Also

  • _IWMEncoderEvents Interface
  • _IWMEncoderEvents::OnIndexerStateChange
  • IWMEncIndexerStats Interface
  • IWMEncoder Interface


IWMEncoder::get_Name

The get_Name method retrieves the unique name of a WMEncoder object for remote administration.

Syntax

HRESULT get_Name(
  BSTR*  pbstrName
);

Parameters

pbstrName

[out] Pointer to a BSTR containing the name.

Return Values

If the method succeeds, it returns S_OK. If it fails, it supports the IErrorInfo interface and returns an HRESULT error code.

Return code | Number | Meaning
E_POINTER | 0x80004003 | The pointer to the name is NULL.

Remarks

Each instance of the encoder engine can be assigned a name to facilitate remote administration. The name must be unique. If you create a WMEncoder object with a duplicate name, a new name is assigned. Use the IWMEncoder::put_Name method to specify the name.

See Also

  • IWMEncoder Interface
  • IWMEncoder::put_Name
  • Remote Administration Interfaces (C++)


IWMEncoder::get_ProfileCollection

The get_ProfileCollection method retrieves the collection of profiles.

Syntax

HRESULT get_ProfileCollection(
  IWMEncProfileCollection**  ppProfileCollection
);

Parameters

ppProfileCollection

[out] Pointer to a pointer to the profile collection.

Return Values

If the method succeeds, it returns S_OK. If it fails, it supports the IErrorInfo interface and returns an HRESULT error code.

Return code | Number | Meaning
E_POINTER | 0x80004003 | The indirect pointer to the profile collection is NULL.

Remarks

Use this method to acquire an IWMEncProfileCollection interface. Use the IWMEncProfileCollection interface to iterate through the profile collection and retrieve a specific profile. Use the IWMEncProfile interface to retrieve the description of a profile.

See Also

  • IWMEncoder Interface
  • IWMEncProfile Interface
  • IWMEncProfileCollection Interface


IWMEncoder::get_RecordingLevel

The get_RecordingLevel method retrieves the volume level of a specific audio stream.

Syntax

HRESULT get_RecordingLevel(
  short  iIndex,
  long*  plLevel
);

Parameters

iIndex

[in] short containing the index of the audio stream.

plLevel

[out] pointer to a long containing the volume level of the audio stream.

Return Values

If the method succeeds, it returns S_OK. If it fails, it supports the IErrorInfo interface and returns an HRESULT error code.

Return code | Number | Meaning
E_FAIL | 0x80004005 | An unspecified error occurred.
E_INVALIDARG | 0x80070057 | The index is not valid.

Remarks

You must set the iIndex parameter to zero because Windows Media Encoder does not currently support multiple audio streams. The volume level is scaled to the actual level supported by the audio card, and must be between 0 and 100 inclusive. A value of 0 is the minimum volume the audio card supports, and 100 is the maximum.

Note You can use this method only for audio devices.

See Also

  • IWMEncoder::get_RecordingMute
  • IWMEncoder Interface
  • IWMEncoder::put_RecordingLevel
  • IWMEncoder::put_RecordingMute


IWMEncoder::get_RecordingMute

The get_RecordingMute method retrieves a Boolean value indicating whether a specific audio stream is muted.

Syntax

HRESULT get_RecordingMute(
  short  iIndex,
  VARIANT_BOOL*  pbRecordMute
);

Parameters

iIndex

[in] short containing the index of the audio stream.

pbRecordMute

[out] VARIANT_BOOL indicating whether the audio stream is muted.

Return Values

If the method succeeds, it returns S_OK. If it fails, it supports the IErrorInfo interface and returns an HRESULT error code.

Return code | Number | Meaning
E_FAIL | 0x80004005 | An unspecified error occurred.
E_INVALIDARG | 0x80070057 | The index is not valid.
E_POINTER | 0x80004003 | The pointer to the Boolean value is NULL.

Remarks

You must set the iIndex parameter to zero because Windows Media Encoder does not currently support multiple audio streams.

Example Code

// Include libraries.

#include <windows.h>
#include <wchar.h>
#include <atlbase.h>
#include "wmencode.h"

// Declare variables.

    HRESULT hr;
    IWMEncoder* pEncoder;
    IWMEncSourceGroupCollection* pSrcGrpColl;
    IWMEncSourceGroup* pSrcGrp;
    IWMEncSource* pAudSrc;
    IWMEncSource* pVidSrc;
    VARIANT_BOOL vbRecordMute;

// Initialize the COM library and retrieve a pointer
// to an IWMEncoder interface.

    hr = CoInitialize(NULL);
    CoCreateInstance(CLSID_WMEncoder,
                     NULL,
                     CLSCTX_INPROC_SERVER,
                     IID_IWMEncoder,
                     (void**) &pEncoder);

// Retrieve a pointer to an IWMEncSourceGroupCollection
// interface.

    hr = pEncoder->get_SourceGroupCollection(&pSrcGrpColl);

// Add an empty source group to the collection.

    hr = pSrcGrpColl->Add(L"SG_1", &pSrcGrp);

// Add an audio and video stream to the source group.

    hr = pSrcGrp->AddSource(WMENC_AUDIO, &pAudSrc);
    hr = pSrcGrp->AddSource(WMENC_VIDEO, &pVidSrc);

// Specify an .avi source file and a .wmv output file.

    CComBSTR m_bstrInFile(L"C:\\filename.avi");
    CComBSTR m_bstrOutFile(L"C:\\filename.wmv");

    hr = pAudSrc->SetInput(m_bstrInFile);
    hr = pVidSrc->SetInput(m_bstrInFile);

// Determine whether the audio stream is muted. If it is not
// muted, then mute it.

    hr = pEncoder->get_RecordingMute(0,&vbRecordMute);
    if (vbRecordMute = VARIANT_FALSE)
    {
        vbRecordMute = VARIANT_TRUE;
    }

// Choose a profile and finish configuring the encoder engine.
// Start the encoder. When the encoding session is finished,
// release the pointers and close the COM library.

See Also

  • IWMEncoder::get_RecordingLevel
  • IWMEncoder Interface
  • IWMEncoder::put_RecordingLevel
  • IWMEncoder::put_RecordingMute


IWMEncoder::get_RemoteAdmin

The get_RemoteAdmin method retrieves a Boolean value indicating whether Windows Media Encoder can be controlled over a network.

Syntax

HRESULT get_RemoteAdmin(
  VARIANT_BOOL*  pbRemoteAdmin
);

Parameters

pbRemoteAdmin

[out] Pointer to a VARIANT_BOOL indicating whether the encoder engine can be remotely controlled.

Return Values

If the method succeeds, it returns S_OK. If it fails, it supports the IErrorInfo interface and returns an HRESULT error code.

Return code | Number | Meaning
E_POINTER | 0x80004003 | The pointer to the Boolean value is NULL.

Remarks

The Boolean value defaults to TRUE, indicating that the encoder engine supports remote administration. Use the IWMEncoder::put_RemoteAdmin method to specify the Boolean value.

See Also

  • IWMEncoder Interface
  • IWMEncoder::put_RemoteAdmin
  • Remote Administration Interfaces (C++)


IWMEncoder::get_RunState

The get_RunState method retrieves a member of an enumeration type indicating whether the encoder is running.

Syntax

HRESULT get_RunState(
  WMENC_ENCODER_STATE*  penumState
);

Parameters

penumState

[out] Member of a WMENC_ENCODER_STATE enumeration type indicating the current operating state of the encoder. This parameter must be one of the following values.

Value | Number | Meaning
WMENC_ENCODER_STARTING | 1 | Windows Media Encoder is starting.
WMENC_ENCODER_RUNNING | 2 | Windows Media Encoder is running.
WMENC_ENCODER_STOPPING | 4 | Windows Media Encoder is stopping.
WMENC_ENCODER_STOPPED | 5 | Windows Media Encoder has been stopped.

Return Values

If the method succeeds, it returns S_OK. If it fails, it supports the IErrorInfo interface and returns an HRESULT error code.

Return code | Number | Meaning
E_POINTER | 0x80004003 | The pointer to the state of the encoder engine is NULL.

Remarks

This property is read-only. You can use this property in a timer control, or you can create an event sink and use the OnStateChange method in the _IWMEncoderEvents interface.

Example Code

    WMENC_ENCODER_STATE enumEncoderState;
    hr = pEncoder->get_RunState(&enumEncoderState);
    if (enumEncoderState = WMENC_ENCODER_RUNNING)
    {
        // Stop the indexing process.
        hr = pEncoder->Stop();
    }

See Also

  • _IWMEncoderEvents Interface
  • _IWMEncoderEvents::OnStateChange
  • IWMEncoder Interface


IWMEncoder::get_SourceGroupCollection

The get_SourceGroupCollection method retrieves the collection of source groups.

Syntax

HRESULT get_SourceGroupCollection(
  IWMEncSourceGroupCollection**  ppSourceGroupCollection
);

Parameters

ppSourceGroupCollection

[out] Pointer to a pointer to the source group collection.

Return Values

If the method succeeds, it returns S_OK. If it fails, it supports the IErrorInfo interface and returns an HRESULT error code.

Return code | Number | Meaning
E_FAIL | 0x80004005 | An unspecified error occurred.
E_POINTER | 0x80004003 | The indirect pointer to the source group collection is NULL.

Remarks

Use this method to acquire an IWMEncSourceGroupCollection interface. You can then iterate through the collection to find a specific source group, or create a group and add it to the collection.

Example Code

// Include libraries.

#include <windows.h>
#include <atlbase.h>
#include "wmencode.h"

// Declare variables.

    HRESULT hr;
    IWMEncoder* pEncoder;
    IWMEncSourceGroupCollection* pSrcGrpColl;
    IWMEncSourceGroup* pSrcGrp;
    IWMEncSource* pAudSrc;
    IWMEncSource* pVidSrc;

// Initialize the COM library and retrieve a pointer
// to an IWMEncoder interface.

    hr = CoInitialize(NULL);
    CoCreateInstance(CLSID_WMEncoder,
                     NULL,
                     CLSCTX_INPROC_SERVER,
                     IID_IWMEncoder,
                    (void**) &pEncoder);

// Retrieve a pointer to an IWMEncSourceGroupCollection
// interface.

    hr = pEncoder->get_SourceGroupCollection(&pSrcGrpColl);

// Add an empty source group to the collection.

    hr = pSrcGrpColl->Add(L"SG_1", &pSrcGrp);

// Add an audio and video stream to the source group.

    hr = pSrcGrp->AddSource(WMENC_AUDIO, &pAudSrc);
    hr = pSrcGrp->AddSource(WMENC_VIDEO, &pVidSrc);

// Specify an .avi source file and a .wmv output file.

    CComBSTR m_bstrInFile(L"C:\\filename.avi");

    hr = pAudSrc->SetInput(m_bstrInFile);
    hr = pVidSrc->SetInput(m_bstrInFile);

// Choose a profile and finish configuring the encoder engine.
// Start the encoder. When the encoding session is finished,
// release the pointers and close the COM library.

See Also

  • IWMEncoder Interface
  • IWMEncSourceGroupCollection


IWMEncoder::get_SourcePluginInfoManager

The get_SourcePluginInfoManager method retrieves a collection of objects containing source plug-in information.

Syntax

HRESULT get_SourcePluginInfoManager(
  IWMEncSourcePluginInfoManager**  ppSourcePluginInfoManager
);

Parameters

ppSourcePluginInfoManager

[out] Pointer to a pointer to an IWMEncSourcePluginInfoManager interface.

Return Values

If the method succeeds, it returns S_OK. If it fails, it supports the IErrorInfo interface and returns an HRESULT error code.

Return code | Number | Meaning
E_FAIL | 0x80004005 | An unspecified error occurred.
E_POINTER | 0x80004003 | The indirect pointer to the source plug-in manager object is NULL.

Remarks

See the IWMEncPluginInfo interface to examine the available registry information.

Example Code

// Include libraries.

#include <windows.h>
#include <atlbase.h>
#include "wmencode.h"

// Declare variables.

    HRESULT hr;
    IWMEncoder* pEncoder;
    IWMEncSourcePluginInfoManager* pSrcPlugMgr;
    IWMEncPluginInfo* pPlugInfo;
    CComBSTR bstrScheme(L"");
    CComBSTR bstrResource(L"");
    VARIANT_BOOL vbResources;
    long lPlugCount, lResourceCount;
    int i, j;

// Initialize the COM library and retrieve a pointer
// to an IWMEncoder interface.

    hr = CoInitialize(NULL);
    CoCreateInstance(CLSID_WMEncoder,
                     NULL,
                     CLSCTX_INPROC_SERVER,
                     IID_IWMEncoder,
                     (void**) &pEncoder);

// Retrieve a pointer to an IWMEncSourcePluginInfoManager
// interface.

    hr = pEncoder->get_SourcePluginInfoManager(&pSrcPlugMgr);

// Loop through the source plug-ins. Call the Item method on each
// plug-in to retrieve an IWMEncPluginInfo object. Use the
// SchemeType property to retrieve a string containing the scheme
// type of the plug-in. If the scheme type is "DEVICE" and if the
// plug-in supports resources, call the Item method to retrieve a
// string identifying the resource.
// To capture streams from an attached device, you must choose a
// specific device plug-in.

    hr = pSrcPlugMgr->get_Count(&lPlugCount);

    for (i = 0; i<lPlugCount; i++)
    {
        hr = pSrcPlugMgr->Item(i, &pPlugInfo);
        hr = pPlugInfo->get_SchemeType(&bstrScheme);
        if (_wcsicmp(bstrScheme, L"DEVICE")==0)
        {
            hr = pPlugInfo->get_Resources(&vbResources);
            hr = pPlugInfo->get_Count(&lResourceCount);
            if ( vbResources = VARIANT_TRUE)
            {
                for (j = 0; j < lResourceCount; j++)
                {
                    hr = pPlugInfo->Item(j, &bstrResource);
                }
            }
        }
    }

See Also

  • IWMEncoder Interface
  • IWMEncPluginInfo Interface
  • IWMEncSourcePluginInfoManager Interface
  • Plug-ins


IWMEncoder::get_Statistics

The get_Statistics method retrieves a statistics interface that can be used to provide status information about the encoding session.

Syntax

HRESULT get_Statistics(
  IWMEncStatistics**  ppStatistics
);

Parameters

ppStatistics

[out] Pointer to a pointer to a IWMEncStatistics interface.

Return Values

If the method succeeds, it returns S_OK. If it fails, it supports the IErrorInfo interface and returns an HRESULT error code.

Return code | Number | Meaning
E_FAIL | 0x80004005 | An unspecified error occurred.
E_POINTER | 0x80004003 | The indirect pointer to the statistics object is NULL.

Example Code

// Include libraries.

#include <windows.h>
#include <atlbase.h>    // Includes CComBSTR.
#include "wmencode.h"

// Declare variables.

    HRESULT hr;
    IWMEncoder* pEncoder;
    IWMEncStatistics* pStatistics;
    IWMEncNetConnectionStats* pNetConnStats;
    IDispatch* pDispNetConnStats;

    long lCount;
    int i;

// Initialize the COM library and retrieve a pointer
// to an IWMEncoder interface.

    hr = CoInitialize(NULL);
    CoCreateInstance(CLSID_WMEncoder,
                     NULL,
                     CLSCTX_INPROC_SERVER,
                     IID_IWMEncoder,
                    (void**) &pEncoder);

// Load a pre-defined configuration. The file name extension must
// be .wme.

    CComBSTR bstrFileName(L"file_name.wme");
    hr = pEncoder->Load(bstrFileName);

// Start the encoder engine.

    hr = pEncoder->Start();

// Retrieve an IWMEncStatistics interface pointer.

    hr = pEncoder->get_Statistics(&pStatistics);

// Retrieve an IDispatch pointer for the IWMEncNetConnectionStats
// interface.

    hr = pStatistics->get_NetConnectionStats(&pDispNetConnStats);

// Call QueryInterface for the IWMEncNetConnectionStats
// interface pointer.

    hr = pDispNetConnStats->QueryInterface(IID_IWMEncNetConnectionStats,
                                          (void**)&pNetConnStats);

// Retrieve the number of connected clients.

    hr = pNetConnStats->get_ClientCount(&lCount);

// Retrieve the IP address of each client.

    CComBSTR bstrIPAddr = NULL;
    WMENC_BROADCAST_PROTOCOL wmeProtocol;
    for (i=1; i=lCount; i++)
    {
        hr = pNetConnStats->get_ClientInfo(i, &wmeProtocol, &bstrIPAddr);
    }

See Also

  • IWMEncNetConnectionStats Interface
  • IWMEncoder Interface
  • IWMEncStatistics Interface


IWMEncoder::get_TransformPluginInfoManager

The get_TransformPluginInfoManager method retrieves a collection of objects containing transform plug-in information.

Syntax

HRESULT get_TransformPluginInfoManager(
  IWMEncTransformPluginInfoManager**  ppTransformPluginInfoManager
);

Parameters

ppTransformPluginInfoManager

[out] Pointer to a pointer to an IWMEncTransformPluginInfoManager interface.

Return Values

If the method succeeds, it returns S_OK. If it fails, it supports the IErrorInfo interface and returns an HRESULT error code.

Return code | Number | Meaning
E_FAIL | 0x80004005 | An unspecified error occurred.
E_POINTER | 0x80004003 | The indirect pointer to the transform plug-in manager object is NULL.

Remarks

See the IWMEncPluginInfo interface to examine the available registry information.

Example Code

// Include libraries.

#include <windows.h>
#include <atlbase.h>
#include "wmencode.h"

// Declare variables.

    HRESULT hr;
    IWMEncoder* pEncoder;
    IWMEncSourcePluginInfoManager* pTransPlugMgr;
    IWMEncPluginInfo* pPlugInfo;

// Initialize the COM library and retrieve a pointer
// to an IWMEncoder interface.

    hr = CoInitialize(NULL);
    CoCreateInstance(CLSID_WMEncoder,
                     NULL,
                     CLSCTX_INPROC_SERVER,
                     IID_IWMEncoder,
                     (void**) &pEncoder);

// Retrieve a pointer to an IWMEncTransformPluginInfoManager
// interface.

    hr = pEncoder->get_TransformPluginInfoManager(&pTransPlugMgr);

See Also

  • IWMEncoder Interface
  • IWMEncPluginInfo Interface
  • IWMEncTransformPluginInfoManager Interface


IWMEncoder::Indexer

The Indexer method cancels the indexing process before it is completed.

Syntax

HRESULT Indexer(
  WMENC_INDEXER_OPERATION  enumIndexerOp
);

enumIndexerOp

[in] Member of an enumeration type that indicates whether the indexing process will be cancelled. This must be the following value.

Value | Number | Meaning
WMENC_INDEXER_STOP | 1 | The indexing process is stopped.

Return Values

If the method succeeds, it returns S_OK. If it fails, it returns an HRESULT error code.

Return code | Number | Meaning
E_INVALIDARG | 0x80070057 | You can only specify WMENC_INDEXER_STOP.

Remarks

Stopping the indexing process before completion may corrupt the Windows Media file, and is not recommended.

Example Code

    WMENC_INDEXER_STATE enumIndexerState;
    hr = pEncoder->get_IndexerState(&enumIndexerState);
    if (enumIndexerState = WMENC_INDEXER_RUNNING)
    {
        // Stop the indexing process.
        hr = pEncoder->Indexer(WMENC_INDEXER_STOP);
    }

See Also

  • IWMEncoder::get_IndexerState
  • IWMEncoder Interface


IWMEncoder::Load

The Load method loads an existing configuration from a file.

Syntax

HRESULT Load(
  BSTR  bstrFileName
);

Parameters

bstrFileName

[in] BSTR containing the name of the configuration file.

Return Values

If the method succeeds, it returns S_OK. If it fails, it supports the IErrorInfo interface and returns an HRESULT error code.

Return code | Number | Meaning
E_OUTOFMEMORY | 0x8007000E | Memory cannot be allocated.

Remarks

A configuration contains the data needed by the encoder engine. The file name extension for a configuration file is .wme. To save a configuration, use the IWMEncoder::Save method.

Example Code

// Include libraries.

#include <windows.h>
#include <atlbase.h>    // Includes CComBSTR.
#include "wmencode.h"

// Declare variables.

    HRESULT hr;
    IWMEncoder* pEncoder;

// Initialize the COM library and retrieve a pointer
// to an IWMEncoder interface.

    hr = CoInitialize(NULL);
    CoCreateInstance(CLSID_WMEncoder,
                     NULL,
                     CLSCTX_INPROC_SERVER,
                     IID_IWMEncoder,
                    (void**) &pEncoder);

// Load a pre-defined configuration. The file name extension must
// be .wme.

    CComBSTR bstrFileName(L"file_name.wme");
    hr = pEncoder->Load(bstrFileName);

// Start the encoder engine.

    hr = pEncoder->Start();

See Also

  • IWMEncoder Interface
  • IWMEncoder::Save
  • IWMEncoder::Start
  • IWMEncoder::Stop


IWMEncoder::PrepareToEncode

The PrepareToEncode method prepares the encoder engine for starting.

Syntax

HRESULT PrepareToEncode(
  VARIANT_BOOL  bPrepare
);

Parameters

bPrepare

[in] VARIANT_BOOL indicating whether to initiate a Windows Media Encoder session.

Return Values

If the method succeeds, it returns S_OK. If it fails, it supports the IErrorInfo interface.

Remarks

The IWMEncoder::Start method calls PrepareToEncode before running Windows Media Encoder. If the bPrepare parameter is VARIANT_TRUE, a new encoding session is created for the defined configuration. If bPrepare is VARIANT_FALSE, all opened source streams are closed and the encoding session is ended.

You can use the PrepareToEncode method to verify that the encoder engine is ready before you call the Start method. For example, PrepareToEncode will indicate if the specified port is not available, or a device is not ready, and so on. You can also use this method to prepare the encoder engine before switching between source groups, thereby minimizing rendering delays for the end user.

Example Code

// Include libraries.

#include <windows.h>
#include "wmencode.h"

// Declare variables.

    HRESULT hr;
    IWMEncoder* pEncoder;

// Initialize the COM library and retrieve a pointer
// to an IWMEncoder interface.

    hr = CoInitialize(NULL);
    CoCreateInstance(CLSID_WMEncoder,
                    NULL,
                    CLSCTX_INPROC_SERVER,
                    IID_IWMEncoder,
                   (void**) &pEncoder);

// Load a predefined configuration. Configuration files
// have a .wme file name extension.

    hr = pEncoder->Load(L"C:\\file_name.wme");

// Initialize the encoding session.

    hr = pEncoder->PrepareToEncode(VARIANT_TRUE)

// Close any active source streams and end the
// encoding session.

   hr = pEncoder->PrepareToEncode(VARIANT_FALSE)

See Also

  • IWMEncoder Interface
  • IWMEncoder::Start


IWMEncoder::put_AutoIndex

The put_AutoIndex method specifies a Boolean value indicating whether the archive file will be indexed after the archiving process is completed.

Syntax

HRESULT put_AutoIndex(
  VARIANT_BOOL  bAutoIndex
);

Parameters

bAutoIndex

[in] VARIANT_BOOL indicating whether the encoded content will be automatically indexed after it is archived.

Return Values

If the method succeeds, it returns S_OK.

Remarks

Use the IWMEncoder::get_AutoIndex method to retrieve the Boolean value.

Example Code

// Include libraries.

#include <windows.h>
#include "wmencode.h"

// Declare variables.

    HRESULT hr;
    IWMEncoder* pEncoder;
    VARIANT_BOOL* vbAutoIndex = 0;

// Initialize the COM library and retrieve a pointer
// to an IWMEncoder interface.

    hr = CoInitialize(NULL);
    CoCreateInstance(CLSID_WMEncoder,
                     NULL,
                     CLSCTX_INPROC_SERVER,
                     IID_IWMEncoder,
                     (void**) &pEncoder);

// Configure Windows Media Encoder to archive encoded content.
// For a complete example see either the IWMEncFile object or the
// IWMEncFileArchiveStats object.

// Specify automatic indexing.

    pEncoder->put_AutoIndex(VARIANT_TRUE);

//Retrieve the automatic indexing state.

    pEncoder->get_AutoIndex(&vbAutoIndex);

See Also

  • IWMEncoder::get_AutoIndex
  • IWMEncoder Interface


IWMEncoder::put_AutoStop

The put_AutoStop method specifies a Boolean value that automatically stops the encoding process after source content from an audio-visual file has been completely encoded to a Windows Media file.

Syntax

HRESULT put_AutoStop(
  VARIANT_BOOL  bStop
);

Parameters

bStop

[in] VARIANT_BOOL indicating whether the encoder engine should automatically stop.

Return Values

If the method succeeds, it returns S_OK.

Remarks

The put_AutoStop method defaults to VARIANT_TRUE. The value of pbStop can be changed while Windows Media Encoder is running. Use the IWMEncoder::get_AutoStop method to retrieve the value.

Example Code

// Include libraries.

#include <windows.h>
#include "wmencode.h"

// Declare variables.

    HRESULT hr;
    IWMEncoder* pEncoder;
    VARIANT_BOOL* vbAutoStop = 0;

// Initialize the COM library and retrieve a pointer
// to an IWMEncoder interface.

    hr = CoInitialize(NULL);
    CoCreateInstance(CLSID_WMEncoder,
                     NULL,
                     CLSCTX_INPROC_SERVER,
                     IID_IWMEncoder,
                     (void**) &pEncoder);

// Configure Windows Media Encoder to archive encoded content.
// For a complete example see either the IWMEncFile object or the
// IWMEncFileArchiveStats object.

// Specify automatic stopping.

    pEncoder->put_AutoStop(VARIANT_TRUE);

// Retrieve the Boolean value.

    pEncoder->get_AutoIndex(&vbAutoStop);

See Also

  • IWMEncoder::get_AutoStop
  • IWMEncoder Interface


IWMEncoder::put_EnableAutoArchive

The put_EnableAutoArchive method specifies a Boolean value indicating whether the archiving process will start automatically when the encoder engine starts.

Syntax

HRESULT put_EnableAutoArchive(
  VARIANT_BOOL  bEnableAutoArchive
);

Parameters

bEnableAutoArchive

[in] VARIANT_BOOL indicating whether archiving is automatic.

Return Values

If the method succeeds, it returns S_OK.

Remarks

Use the IWMEncSourceGroup::put_AutoArchive method to automatically control source group archiving. Use the IWMEncoder::get_EnableAutoArchive method to specify whether archiving can be automatically controlled.

Example Code

// Include libraries.

#include <windows.h>
#include <wchar.h>
#include <atlbase.h>
#include "wmencode.h"

// Declare variables.

   HRESULT hr;
   IWMEncoder* pEncoder;
   IWMEncSourceGroupCollection* pSrcGrpColl;
   IWMEncSourceGroup* pSrcGrp;
   IWMEncSource* pAudSrc;
   IWMEncSource* pVidSrc;
   IWMEncProfileCollection* pProColl;
   IWMEncProfile* pPro;
   IWMEncFile* pFile;
   long lCount;
   int i;

// Initialize the COM library and retrieve a pointer
// to an IWMEncoder interface.

   hr = CoInitialize(NULL);
   CoCreateInstance(CLSID_WMEncoder,
                    NULL,
                    CLSCTX_INPROC_SERVER,
                    IID_IWMEncoder,
                   (void**) &pEncoder);

// Retrieve a pointer to an IWMEncSourceGroupCollection
// interface.

   hr = pEncoder->get_SourceGroupCollection(&pSrcGrpColl);

// Add an empty source group to the collection.

   hr = pSrcGrpColl->Add(L"SG_1", &pSrcGrp);

// Add an audio and video stream to the source group.

   hr = pSrcGrp->AddSource(WMENC_AUDIO, &pAudSrc);
   hr = pSrcGrp->AddSource(WMENC_VIDEO, &pVidSrc);

// Retrieve a pointer to an IWMEncFile interface.

   hr = pEncoder->get_File( &pFile );

// Specify an .avi source file and a Windows Media file with a .wmv extension for the output.

   CComBSTR m_bstrInFile(L"C:\\file_name");
   CComBSTR m_bstrOutFile(L"C:\\file_name");

   hr = pAudSrc->SetInput(m_bstrInFile);
   hr = pVidSrc->SetInput(m_bstrInFile);
   hr = pFile->put_LocalFileName(m_bstrOutFile);

// Retrieve the name of the output file.

   CComBSTR m_bstrFileName;
   hr = pFile->get_LocalFileName(&m_bstrFileName);

// Loop through the profile collection and retrieve a specific
// profile. You can find the profile name in the Profile Manager.

   hr = pEncoder->get_ProfileCollection(&pProColl);
   CComVariant m_varProfile;
   m_varProfile.vt = VT_DISPATCH;
   hr = pProColl->get_Count(&lCount);
   for (i=0; i<lCount; i++)
   {
      CComBSTR m_bstrName;
      hr = pProColl->Item(i, &pPro);
      hr = pPro->get_Name(&m_bstrName);
      if (_wcsicmp(m_bstrName, L"profile_name")==0)
      {
         m_varProfile.pdispVal = pPro;
         pSrcGrp->put_Profile(m_varProfile);
         break;
      }
   }

// Start archiving when the encoder engine starts. This is the default.

   hr = pEncoder->put_EnableAutoArchive(VARIANT_TRUE);

// Retrieve the automatic archiving state

   VARIANT_BOOL vbAutoArchive;
   hr = pEncoder->get_EnableAutoArchive(&vbAutoArchive);

// Initialize and start the encoder engine. To determine when the
// encoding and archiving process has ended, you must implement the
// OnArchiveStateChange event in the _IWMEncoderEvents interface.

   hr = pEncoder->PrepareToEncode(VARIANT_TRUE);
   hr = pEncoder->Start();

See Also

  • IWMEncFile Interface
  • IWMEncFileArchiveStats Interface
  • IWMEncoder::get_EnableAutoArchive
  • IWMEncoder Interface
  • IWMEncSourceGroup::put_AutoArchive


IWMEncoder::put_Name

The put_Name method specifies the unique name of a WMEncoder object for remote administration.

Syntax

HRESULT put_Name(
  BSTR  bstrName
);

Parameters

bstrName

[in] BSTR containing the name.

Return Values

If the method succeeds, it returns S_OK. If it fails, it supports the IErrorInfo interface and returns an HRESULT error code.

Return code | Number | Meaning
E_FAIL | 0x80004005 | An unspecified error occurred.
NS_E_DUPLICATENAME | pending | pending

Remarks

Each instance of the encoder engine can be assigned a name to facilitate remote communication. The name must be unique. If you create a WMEncoder object with a duplicate name, a new name is assigned. Use the IWMEncoder::get_Name method to retrieve the name

See Also

  • IWMEncoder::get_Name
  • IWMEncoder Interface
  • Remote Administration Interfaces (C++)


IWMEncoder::put_RecordingLevel

The put_RecordingLevel method specifies the volume level of a specific audio stream.

Syntax

HRESULT put_RecordingLevel(
  short  iIndex,
  long  lLevel
);

Parameters

iIndex

[in] short containing the index of an audio stream.

lLevel

[in] long containing the volume level.

Return Values

If the method succeeds, it returns S_OK. If it fails, it supports the IErrorInfo interface and returns an HRESULT error code.

Return code | Number | Meaning
E_FAIL | 0x80004005 | An unspecified error occurred.
E_INVALIDARG | 0x80070057 | Either the index is greater than 0, or the recording level is less than 0 or greater than 100.

Remarks

You must set the iIndex parameter to zero because Windows Media Encoder does not currently support multiple audio streams. The volume level is scaled to the actual level supported by the audio card, and must be between 0 and 100 inclusive. A value of 0 is the minimum volume the audio card supports, and 100 is the maximum.

Note You can use this method only for audio devices.

Example Code

// Include libraries.

#include <windows.h>
#include <atlbase.h>
#include "wmencode.h"

// Declare variables.

    HRESULT hr;
    IWMEncoder* pEncoder;
    IWMEncSourceGroupCollection* pSrcGrpColl;
    IWMEncSourceGroup* pSrcGrp;
    IWMEncSource* pAudSrc;
    long lAudioLevel;

// Initialize the COM library and retrieve a pointer
// to an IWMEncoder interface.

    hr = CoInitialize(NULL);
    CoCreateInstance(CLSID_WMEncoder,
                     NULL,
                     CLSCTX_INPROC_SERVER,
                     IID_IWMEncoder,
                     (void**) &pEncoder);

// Retrieve a pointer to an IWMEncSourceGroupCollection
// interface.

    hr = pEncoder->get_SourceGroupCollection(&pSrcGrpColl);

// Add an empty source group to the collection.

    hr = pSrcGrpColl->Add(L"SG_1", &pSrcGrp);

// Add an audio and video stream to the source group.

    hr = pSrcGrp->AddSource(WMENC_AUDIO, &pAudSrc);

// Specify an .avi source file.

    CComBSTR m_bstrInFile(L"C:\\filename.avi");
    hr = pAudSrc->SetInput(m_bstrInFile);

// Retrieve the initial recording level from the device.

    hr = pEncoder->get_RecordingLevel(0,&lAudioLevel);

// Specify the recording volume level.

    hr = pEncoder->put_RecordingLevel(0,50);

See Also

  • IWMEncoder::get_RecordingLevel
  • IWMEncoder Interface


IWMEncoder::put_RecordingMute

The put_RecordingMute method mutes an audio stream.

Syntax

HRESULT put_RecordingMute(
  short  iIndex,
  VARIANT_BOOL  bRecordMute
);

Parameters

iIndex

[in] short containing the time index, in seconds.

bRecordMute

[in] VARIANT_BOOL indicating whether the audio stream is muted.

Return Values

If the method succeeds, it returns S_OK. If it fails, it supports the IErrorInfo interface and returns an HRESULT error code.

Return code | Number | Meaning
E_FAIL | 0x80004005 | An unspecified error occurred.
E_INVALIDARG | 0x80070057 | The index must equal zero.

Example Code

// Include libraries.

#include <windows.h>
#include <wchar.h>
#include <atlbase.h>
#include "wmencode.h"

// Declare variables.

    HRESULT hr;
    IWMEncoder* pEncoder;
    IWMEncSourceGroupCollection* pSrcGrpColl;
    IWMEncSourceGroup* pSrcGrp;
    IWMEncSource* pAudSrc;
    IWMEncSource* pVidSrc;
    VARIANT_BOOL vbRecordMute;

// Initialize the COM library and retrieve a pointer
// to an IWMEncoder interface.

    hr = CoInitialize(NULL);
    CoCreateInstance(CLSID_WMEncoder,
                     NULL,
                     CLSCTX_INPROC_SERVER,
                     IID_IWMEncoder,
                     (void**) &pEncoder);

// Retrieve a pointer to an IWMEncSourceGroupCollection
// interface.

    hr = pEncoder->get_SourceGroupCollection(&pSrcGrpColl);

// Add an empty source group to the collection.

    hr = pSrcGrpColl->Add(L"SG_1", &pSrcGrp);

// Add an audio and video stream to the source group.

    hr = pSrcGrp->AddSource(WMENC_AUDIO, &pAudSrc);
    hr = pSrcGrp->AddSource(WMENC_VIDEO, &pVidSrc);

// Specify an .avi source file and a .wmv output file.

    CComBSTR m_bstrInFile(L"C:\\filename.avi");
    CComBSTR m_bstrOutFile(L"C:\\filename.wmv");

    hr = pAudSrc->SetInput(m_bstrInFile);
    hr = pVidSrc->SetInput(m_bstrInFile);

// Determine whether the audio stream is muted. If it is not
// muted, then mute it.

    hr = pEncoder->get_RecordingMute(0,&vbRecordMute);
    if (vbRecordMute = VARIANT_FALSE)
    {
        vbRecordMute = VARIANT_TRUE;
    }

See Also

  • IWMEncoder::get_RecordingMute
  • IWMEncoder Interface


IWMEncoder::put_RemoteAdmin

The put_RemoteAdmin method specifies a Boolean value indicating whether Windows Media Encoder can be remotely controlled.

Syntax

HRESULT put_RemoteAdmin(
  VARIANT_BOOL  bRemoteAdmin
);

Parameters

bRemoteAdmin

[in] VARIANT_BOOL indicating whether the encoder engine can be remotely controlled.

Return Values

If the method succeeds, it returns S_OK. If it fails, it supports the IErrorInfo interface.

Remarks

The Boolean value defaults to TRUE, indicating that the encoder engine supports network administration. Use the IWMEncoder::get_RemoteAdmin method to retrieve the Boolean value.

See Also

  • IWMEncoder::get_RemoteAdmin
  • IWMEncoder Interface
  • Remote Administration Interfaces (C++)


IWMEncoder::Reset

The Reset method removes the current configuration settings.

Syntax

HRESULT Reset();

Parameters

This method takes no parameters.

Return Values

If the method succeeds, it returns S_OK. If it fails, it supports the IErrorInfo interface and returns an HRESULT error code.

Return code | Number | Meaning
NS_E_INVALIDCALL_WHILE_ENCODER_RUNNING | 0xC00D0011 | This method cannot be called if the encoder engine is running.

Remarks

This function reinitializes the configuration data members to the values that are set for a new Windows Media Encoder object.

See Also

  • IWMEncoder Interface


IWMEncoder::Save

The Save method saves the current configuration to a file.

Syntax

HRESULT Save(
  BSTR  bstrFileName
);

Parameters

bstrFileName

[in] BSTR containing the name of the configuration file.

Return Values

If the method succeeds, it returns S_OK. If it fails, it supports the IErrorInfo interface and returns an HRESULT error code.

Return code | Number | Meaning
E_OUTOFMEMORY | 0x8007000E | Memory cannot be allocated

Remarks

To load a configuration, use the IWMEncoder::Load method.

Example Code

// Include libraries.

#include <windows.h>
#include <atlbase.h>               // Includes CComBSTR.
#include "wmencode.h"

// Declare variables.

HRESULT hr;
IWMEncoder* pEncoder;
IWMEncDisplayInfo* pDispInfo;
CComBSTR m_bstrAuthor("Content Author's name.");
CComBSTR m_bstrCopyright("Copyright 2000. All rights reserved.");
CComBSTR m_bstrDescription("Description of the encoded content.");
CComBSTR m_bstrRating("Content rating.");
CComBSTR m_bstrTitle("Title of the encoded content.");

// Initialize the COM library and retrieve a pointer
// to an IWMEncoder interface.

hr = CoInitialize(NULL);
CoCreateInstance(CLSID_WMEncoder,
                 NULL,
                 CLSCTX_INPROC_SERVER,
                 IID_IWMEncoder,
                 (void**) &pEncoder);

// Load a predefined configuration. The file name extension must
// be .wme.

hr = pEncoder->Load(L"C:\\filename.wme");

// Retrieve a pointer to an IWMEncDisplayInfo interface.

hr = pEncoder->get_DisplayInfo(&pDispInfo);

// Set the data members of the IWMEncDisplayInfo interface.

hr = pDispInfo->put_Author(m_bstrAuthor);
hr = pDispInfo->put_Copyright(m_bstrCopyright);
hr = pDispInfo->put_Description(m_bstrDescription);
hr = pDispInfo->put_Rating(m_bstrRating);
hr = pDispInfo->put_Title(m_bstrTitle);

// Save the changed configuration

hr = pEncoder->Save(L"C:\\filename.wme");

// Start the encoder engine.

hr = pEncoder->Start();

See Also

  • IWMEncDisplayInfo Interface
  • IWMEncoder Interface
  • IWMEncoder::Load


IWMEncoder::SendScript

The SendScript method sends script to Windows Media Encoder.

Syntax

HRESULT SendScript(
  short  iIndex,
  BSTR  bstrType,
  BSTR  bstrData
);

Parameters

iIndex

[in] short containing the index of the script to send.

bstrType

[in] BSTR containing the type of script to send.

bstrData

[in] BSTR containing the script content.

Return Values

If the method succeeds, it returns S_OK. If it fails, it supports the IErrorInfo interface.

Remarks

Because Windows Media Encoder does not currently support multiple text streams, you must set the iIndex parameter to zero. To broadcast text, you must send a type/data string pair to the encoder. When Windows Media Player receives the "TEXT" type, it interprets the data string as captioned text and displays it in the caption window. When Windows Media Player receives a "URL" type, it interprets the data string as a URL and opens the URL in a browser.

Example Code

// Include libraries.

#include <windows.h>
#include <atlbase.h>
#include "wmencode.h"

// Declare variables.

    HRESULT hr;
    IWMEncoder* pEncoder;
    IWMEncSourceGroupCollection* pSrcGrpColl;
    IWMEncSourceGroup* pSrcGrp;
    IWMEncSource* pAudSrc;
    IWMEncSource* pVidSrc;
    IWMEncSource* pScriptSrc;

// Initialize the COM library and retrieve a pointer
// to an IWMEncoder interface.

    hr = CoInitialize(NULL);
    CoCreateInstance(CLSID_WMEncoder,
                     NULL,
                     CLSCTX_INPROC_SERVER,
                     IID_IWMEncoder,
                     (void**) &pEncoder);

// Retrieve a pointer to an IWMEncSourceGroupCollection
// interface.

    hr = pEncoder->get_SourceGroupCollection(&pSrcGrpColl);

// Add an empty source group to the collection.

    hr = pSrcGrpColl->Add(L"SG_1", &pSrcGrp);

// Add audio, video, and script streams to the source group.

    hr = pSrcGrp->AddSource(WMENC_AUDIO, &pAudSrc);
    hr = pSrcGrp->AddSource(WMENC_VIDEO, &pVidSrc);
    hr = pSrcGrp->AddSource(WMENC_SCRIPT, &pScriptSrc);

// Specify the plug-in to use for capturing audio and video
// streams from the capture card

    hr = pAudSrc->SetInput(L"DEVICE://Default_Audio_Device");
    hr = pVidSrc->SetInput(L"DEVICE://Default_Video_Device");

// Specify the script plug-in.

    CComBSTR bstrScript(L"UserScript://");
    hr = pScriptSrc->SetInput(bstrScript);

// Select a custom profile for the source group. The profile must be
// defined for script streams. You can use either the Windows
// Media Format SDK or the Profile Manager to create the
// profile. Because this is a custom profile, you can
// associate it with a source group by specifying the path and
// name.

    CComVariant varProfile(L"profile name");
    hr = pSrcGrp->put_Profile(varProfile);

// Initialize and start the encoder engine.

    hr = pEncoder->Start();

// Broadcast a text string. The string is displayed in the Windows
// Media Player caption window.

    CComBSTR bstrType(L"TEXT");
    CComBSTR bstrData(L"This is a test.");
    hr = pEncoder->SendScript(0, bstrType, bstrData);

See Also

  • IWMEncoder Interface
  • IWMEncSource Interface
  • IWMEncSourceGroup Interface
  • IWMEncSourceGroupCollection Interface


IWMEncoder::SetLocaleID

The SetLocaleID method specifies the national language used by Windows Media Encoder.

Syntax

HRESULT SetLocaleID(
  long  lLocaleID
);

Parameters

lLocaleID

[in] long containing the language ID.

Return Values

If the method succeeds, it returns S_OK. If it fails, it supports the IErrorInfo interface.

Remarks

For more information about locale IDs, see the Microsoft Developer Network page at the Microsoft Web site. Search for localeID, "Table for Language, Locale Names, and Correponding LCIDs (Three-Letter Abbreviations)", the MAKELANGID macro, or the MAKELCID macro.

Example Code

// Include libraries.

#include <windows.h>
#include "wmencode.h"

// Declare variables.

    HRESULT hr;
    IWMEncoder* pEncoder;

// Initialize the COM library and retrieve a pointer
// to an IWMEncoder interface.

    hr = CoInitialize(NULL);
    CoCreateInstance(CLSID_WMEncoder,
                     NULL,
                     CLSCTX_INPROC_SERVER,
                     IID_IWMEncoder,
                     (void**) &pEncoder);

// Specify the locale ID for Canadian English.

    hr = pEncoder->SetLocaleID(0x1009);

See Also

  • IWMEncoder Interface


IWMEncoder::Start

The Start method starts Windows Media Encoder.

Syntax

HRESULT Start();

Parameters

This method takes no parameters.

Return Values

If the method succeeds, it returns S_OK. If it fails, it supports the IErrorInfo interface.

Remarks

The Start method calls IWMEncoder::PrepareToEncode if you have not already done so. It is recommended that you call PrepareToEncode so that resources will be reserved and the configuration verified. This minimizes delay when starting the encoder engine

See Also

  • IWMEncoder Interface
  • IWMEncoder::Load
  • IWMEncoder::PrepareToEncode
  • IWMEncoder::Save
  • IWMEncoder::Stop


IWMEncoder::Stop

The Stop method stops Windows Media Encoder.

Syntax

HRESULT Stop();

Parameters

This method takes no parameters.

Return Values

If the method succeeds, it returns S_OK.

See Also

  • IWMEncoder Interface
  • IWMEncoder::Load
  • IWMEncoder::Save


IWMEncoderApp Interface

The IWMEncoderApp interface displays the primary Windows Media Encoder user interface and accesses the Windows Media Encoder engine. In addition to the methods inherited from IDispatch, the IWMEncoderApp interface exposes the following methods.

Method | Description
get_Encoder | Creates an instance of Windows Media Encoder.
get_Height | Retrieves the height of the UI, in pixels.
get_Left | Retrieves the offset of the UI, in pixels, from the left side of the screen.
GetProperty | Retrieves a property that identifies the display state of a UI panel, property page, or window.
get_Top | Retrieves the offset of the UI, in pixels, from the top of the screen.
get_UILock | Retrieves the lock state of the UI.
get_Visible | Retrieves the display state of the UI.
get_Width | Retrieves the width of the UI, in pixels.
put_Height | Specifies the height of the UI, in pixels.
put_Left | Specifies the offset of the UI, in pixels, from the left side of the screen.
put_Top | Specifies the offset of the UI, in pixels, from the top of the screen.
put_UILock | Specifies the lock state of the UI.
put_Visible | Specifies the display state of the UI.
put_Width | Specifies the width of the UI, in pixels.
SaveProperties | Saves changes to the UI properties.
SetProperty | Specifies a property that identifies the display state of a UI panel, property page, or window.

See Also

  • [Visual Basic] WMEncoderApp Object
  • Interfaces (C++)


IWMEncoderApp::get_Encoder

The get_Encoder method creates an instance of Windows Media Encoder.

Syntax

HRESULT get_Encoder(
  IWMEncoder**  ppVal
);

Parameters

pVal

[out] Pointer to a pointer to an instance of Windows Media Encoder.

Return Values

If the method succeeds, it returns S_OK. If it fails, it returns an HRESULT error code.

Return code | Number | Meaning
E_POINTER | 0x80004003 | The indirect pointer to the encoder object is NULL.

Remarks

Use this method to acquire an IWMEncoder interface and run Windows Media Encoder. This method is useful when applications must both run the engine and show the predefined user interface.

Example Code

// Include libraries.

#include <windows.h>
#include "wmencode.h"

// Declare variables.

    HRESULT hr;
    IWMEncoder* pEncoder;
    IWMEncoderApp* pEncoderApp;

// Initialize the COM library and retrieve a pointer
// to an IWMEncoderApp interface.

    hr = CoInitialize(NULL);
    hr = CoCreateInstance( CLSID_WMEncoderApp,
                           NULL,
                           CLSCTX_LOCAL_SERVER,
                           IID_IWMEncoderApp,
                           (void**) (&pEncoderApp));

// Acquire an IWMEncoder interface.

    hr = pEncoderApp->get_Encoder(&pEncoder);

See Also

  • IWMEncoder Interface
  • IWMEncoderApp Interface


IWMEncoderApp::get_Height

The get_Height method retrieves the height of the UI, in pixels.

Syntax

HRESULT get_Height(
  long*  pVal
);

Parameters

pVal

[out] Pointer to a long containing the height of the UI, in pixels.

Return Values

If the method succeeds, it returns S_OK. If it fails, it returns an HRESULT error code.

Return code | Number | Meaning
E_POINTER | 0x80004003 | The pointer to the height is NULL.

Remarks

Use the IWMEncoderApp::put_Height method to specify the height of the UI.

Example Code

// Include libraries.

#include <windows.h>
#include <atlbase.h>
#include "wmencode.h"

// Declare variables.

    HRESULT hr;
    IWMEncoderApp* pEncoderApp;
    long lHeight, lWidth, lTop, lLeft;
    VARIANT_BOOL vbUILock;
    CComVariant varSourceState = NULL;

// Initialize the COM library and retrieve a pointer
// to an IWMEncoderApp interface.

    hr = CoInitialize(NULL);
    CoCreateInstance(CLSID_WMEncoderApp,
                     NULL,
                     CLSCTX_LOCAL_SERVER,
                     IID_IWMEncoderApp,
                     (void**) &pEncoderApp);

// Display the predefined user interface (UI).

    hr = pEncoderApp->put_Visible(VARIANT_TRUE);

// Retrieve the height and width, in pixels, of the UI.

    hr = pEncoderApp->get_Height(&lHeight);
    hr = pEncoderApp->get_Width(&lWidth);

// Retrieve the top offset of the UI.

    hr = pEncoderApp->get_Top(&lTop);
    if (lTop != 0) lTop = 0;

// Retrieve the left offset of the UI.

    hr = pEncoderApp->get_Left(&lLeft);
    if (lLeft != 0) lLeft = 0;

// Determine whether the UI is locked.

    hr = pEncoderApp->get_UILock(&vbUILock);

// Determine whether the Sources panel is displayed.

    CComBSTR bstrSourceProp(L"View\\Sources");
    CComVariant varBool = NULL;
    hr = pEncoderApp->GetProperty(WMENCAPP_PROP_USER,
                                  bstrSourceProp,
                                  &varBool);

// Display the Sources panel.

    hr = pEncoderApp->SetProperty(WMENCAPP_PROP_USER,
                                  bstrSourceProp,
                                  VARIANT_TRUE);

See Also

  • IWMEncoderApp Interface
  • IWMEncoderApp::put_Height


IWMEncoderApp::get_Left

The get_Left method retrieves the offset of the UI, in pixels, from the left side of the screen.

Syntax

HRESULT get_Left(
  long*  pVal
);

Parameters

pVal

[out] Pointer to a long containing the offset of the UI, in pixels, from the left side of the screen.

Return Values

If the method succeeds, it returns S_OK. If it fails, it returns an HRESULT error code.

Return code | Number | Meaning
E_POINTER | 0x80004003 | The pointer to the left offset is NULL.

Remarks

Use the IWMEncoderApp::put_Left method to specify the left offset of the UI.

Example Code

// Include libraries.

#include <windows.h>
#include <atlbase.h>
#include "wmencode.h"

// Declare variables.

    HRESULT hr;
    IWMEncoderApp* pEncoderApp;
    long lHeight, lWidth, lTop, lLeft;
    VARIANT_BOOL vbUILock;
    CComVariant varSourceState = NULL;

// Initialize the COM library and retrieve a pointer
// to an IWMEncoderApp interface.

    hr = CoInitialize(NULL);
    CoCreateInstance(CLSID_WMEncoderApp,
                     NULL,
                     CLSCTX_LOCAL_SERVER,
                     IID_IWMEncoderApp,
                     (void**) &pEncoderApp);

// Display the predefined user interface (UI).

    hr = pEncoderApp->put_Visible(VARIANT_TRUE);

// Retrieve the height and width, in pixels, of the UI.

    hr = pEncoderApp->get_Height(&lHeight);
    hr = pEncoderApp->get_Width(&lWidth);

// Retrieve the top offset of the UI.

    hr = pEncoderApp->get_Top(&lTop);
    if (lTop != 0) lTop = 0;

// Retrieve the left offset of the UI.

    hr = pEncoderApp->get_Left(&lLeft);
    if (lLeft != 0) lLeft = 0;

// Determine whether the UI is locked.

    hr = pEncoderApp->get_UILock(&vbUILock);

// Determine whether the Sources panel is displayed.

    CComBSTR bstrSourceProp(L"View\\Sources");
    CComVariant varBool = NULL;
    hr = pEncoderApp->GetProperty(WMENCAPP_PROP_USER,
                                  bstrSourceProp,
                                  &varBool);

// Display the Sources panel.

    hr = pEncoderApp->SetProperty(WMENCAPP_PROP_USER,
                                  bstrSourceProp,
                                  VARIANT_TRUE);

See Also

  • IWMEncoderApp Interface
  • IWMEncoderApp::put_Left


IWMEncoderApp::GetProperty

The GetProperty method retrieves a property that identifies the display state of a UI panel, property page, or window.

Syntax

HRESULT GetProperty(
  WMENCAPP_PROP_CLASS  enumClass,
  BSTR  bstrProperty,
  VARIANT*  pValue
);

Parameters

enumClass

[in] Member of a WMENCAPP_PROP_CLASS enumeration type identifying the property class. Currently, this must be the following value.

Value | Number | Meaning
WMENC_PROP_USER | 1 | Identifies the end-user class.

bstrProperty

[in] BSTR containing the property.

pValue

[out] Pointer to a VARIANT containing the property state.

Return Values

If the method succeeds, it returns S_OK. If it fails, it returns an HRESULT error code.

Return code | Number | Meaning
E_INVALIDARG | 0x80070057 | You must specify the property class as WMENC_PROP_USER.
E_OUTOFMEMORY | 0x8007000E | Memory cannot be allocated.
E_POINTER | 0x80004003 | The pointer to the property state is NULL.

Remarks

Any change to the UI by an end user causes the property to change appropriately. The following table lists the properties that are currently defined for Windows Media Encoder.

Property | Description
View\Sources | Retrieves the display state of the Sources panel.
View\Audio | Retrieves the display state of the Audio panel.
View\Monitor | Retrieves the display state of the Monitor panel.
View\Control | Retrieves the display state of the Control panel.
View\Script | Retrieves the display state of the Annotation panel.
View\Archive | Retrieves the display state of the Archive panel.
View\Video1 | Retrieves the display state of the Video window.
View\MonitorPage | Retrieves the ID of a property page in the Monitor panel: 100 = General page. 300 = Display Information page. 600 = Connections page.
Video1\Zoom | Retrieves the zoom factor for the video window. For example, a value of 200 means that the zoom factor is 200%.
Video1\Display | Retrieves the display style of the video window: 0 = input. 1 = Output. 2 = Both. 3 = Next. 4 = Split.

Example Code

// Include libraries.

#include <windows.h>
#include <atlbase.h>
#include "wmencode.h"

// Declare variables.

    HRESULT hr;
    IWMEncoderApp* pEncoderApp;
    long lHeight, lWidth, lTop, lLeft;
    VARIANT_BOOL vbUILock;
    CComVariant varSourceState = NULL;

// Initialize the COM library and retrieve a pointer
// to an IWMEncoderApp interface.

    hr = CoInitialize(NULL);
    CoCreateInstance(CLSID_WMEncoderApp,
                     NULL,
                     CLSCTX_LOCAL_SERVER,
                     IID_IWMEncoderApp,
                     (void**) &pEncoderApp);

// Display the predefined user interface (UI).

    hr = pEncoderApp->put_Visible(VARIANT_TRUE);

// Retrieve the height and width, in pixels, of the UI.

    hr = pEncoderApp->get_Height(&lHeight);
    hr = pEncoderApp->get_Width(&lWidth);

// Retrieve the top offset of the UI.

    hr = pEncoderApp->get_Top(&lTop);
    if (lTop != 0) lTop = 0;

// Retrieve the left offset of the UI.

    hr = pEncoderApp->get_Left(&lLeft);
    if (lLeft != 0) lLeft = 0;

// Determine whether the UI is locked.

    hr = pEncoderApp->get_UILock(&vbUILock);

// Determine whether the Sources panel is displayed.

    CComBSTR bstrSourceProp(L"View\\Sources");
    CComVariant varBool = NULL;
    hr = pEncoderApp->GetProperty(WMENCAPP_PROP_USER,
                                  bstrSourceProp,
                                  &varBool);

// Display the Sources panel.

    hr = pEncoderApp->SetProperty(WMENCAPP_PROP_USER,
                                  bstrSourceProp,
                                  VARIANT_TRUE);

See Also

  • IWMEncoderApp Interface
  • IWMEncoderApp::SetProperty


IWMEncoderApp::get_Top

The get_Top method retrieves the offset of the UI, in pixels, from the top of the screen.

Syntax

HRESULT get_Top(
  long*  pVal
);

Parameters

pVal

[out] Pointer to a long containing the offset of the UI, in pixels.

Return Values

If the method succeeds, it returns S_OK. If it fails, it returns an HRESULT error code.

Return code | Number | Meaning
E_POINTER | 0x80004003 | The pointer to the top offset is NULL.

Remarks

Use the IWMEncoderApp::put_Top method to specify the offset.

Example Code

// Include libraries.

#include <windows.h>
#include <atlbase.h>
#include "wmencode.h"

// Declare variables.

    HRESULT hr;
    IWMEncoderApp* pEncoderApp;
    long lHeight, lWidth, lTop, lLeft;
    VARIANT_BOOL vbUILock;
    CComVariant varSourceState = NULL;

// Initialize the COM library and retrieve a pointer
// to an IWMEncoderApp interface.

    hr = CoInitialize(NULL);
    CoCreateInstance(CLSID_WMEncoderApp,
                     NULL,
                     CLSCTX_LOCAL_SERVER,
                     IID_IWMEncoderApp,
                     (void**) &pEncoderApp);

// Display the predefined user interface (UI).

    hr = pEncoderApp->put_Visible(VARIANT_TRUE);

// Retrieve the height and width, in pixels, of the UI.

    hr = pEncoderApp->get_Height(&lHeight);
    hr = pEncoderApp->get_Width(&lWidth);

// Retrieve the top offset of the UI.

    hr = pEncoderApp->get_Top(&lTop);
    if (lTop != 0) lTop = 0;

// Retrieve the left offset of the UI.

    hr = pEncoderApp->get_Left(&lLeft);
    if (lLeft != 0) lLeft = 0;

// Determine whether the UI is locked.

    hr = pEncoderApp->get_UILock(&vbUILock);

// Determine whether the Sources panel is displayed.

    CComBSTR bstrSourceProp(L"View\\Sources");
    CComVariant varBool = NULL;
    hr = pEncoderApp->GetProperty(WMENCAPP_PROP_USER,
                                  bstrSourceProp,
                                  &varBool);

// Display the Sources panel.

    hr = pEncoderApp->SetProperty(WMENCAPP_PROP_USER,
                                  bstrSourceProp,
                                  VARIANT_TRUE);

See Also

  • IWMEncoderApp Interface
  • IWMEncoderApp::put_Top


IWMEncoderApp::get_UILock

The get_UILock method retrieves the lock state of the UI.

Syntax

HRESULT get_UILock(
  VARIANT_BOOL*  pVal
);

Parameters

pVal

[out] Pointer to a VARIANT_BOOL indicating whether the UI is locked.

Return Values

If the method succeeds, it returns S_OK. If it fails, it returns an HRESULT error code.

Return code | Number | Meaning
E_POINTER | 0x80004003 | The pointer to the lock state of the UI is NULL.

Remarks

If the UI is locked from the local computer running Windows Media Encoder, it cannot be unlocked from a remote computer.

Example Code

// Include libraries.

#include <windows.h>
#include <atlbase.h>
#include "wmencode.h"

// Declare variables.

    HRESULT hr;
    IWMEncoderApp* pEncoderApp;
    long lHeight, lWidth, lTop, lLeft;
    VARIANT_BOOL vbUILock;
    CComVariant varSourceState = NULL;

// Initialize the COM library and retrieve a pointer
// to an IWMEncoderApp interface.

    hr = CoInitialize(NULL);
    CoCreateInstance(CLSID_WMEncoderApp,
                     NULL,
                     CLSCTX_LOCAL_SERVER,
                     IID_IWMEncoderApp,
                     (void**) &pEncoderApp);

// Display the predefined user interface.

    hr = pEncoderApp->put_Visible(VARIANT_TRUE);

// Retrieve the height and width, in pixels, of the UI.

    hr = pEncoderApp->get_Height(&lHeight);
    hr = pEncoderApp->get_Width(&lWidth);

// Retrieve the top offset of the UI.

    hr = pEncoderApp->get_Top(&lTop);
    if (lTop != 0) lTop = 0;

// Retrieve the left offset of the UI.

    hr = pEncoderApp->get_Left(&lLeft);
    if (lLeft != 0) lLeft = 0;

// Determine whether the UI is locked.

    hr = pEncoderApp->get_UILock(&vbUILock);

// Determine whether the Sources panel is displayed.

    CComBSTR bstrSourceProp(L"View\\Sources");
    CComVariant varBool = NULL;
    hr = pEncoderApp->GetProperty(WMENCAPP_PROP_USER,
                                  bstrSourceProp,
                                  &varBool);

// Display the Sources panel.

    hr = pEncoderApp->SetProperty(WMENCAPP_PROP_USER,
                                  bstrSourceProp,
                                  VARIANT_TRUE);

See Also

  • IWMEncoderApp Interface
  • IWMEncoderApp::put_UILock


IWMEncoderApp::get_Visible

The get_Visible method retrieves the display state of the UI.

Syntax

HRESULT get_Visible(
  VARIANT_BOOL*  pVal
);

Parameters

pVal

[out] Pointer to a VARIANT_BOOL indicating whether the UI is enabled.

Return Values

If the method succeeds, it returns S_OK. If it fails, it returns an HRESULT error code.

Return code | Number | Meaning
E_POINTER | 0x80004003 | The pointer to the Boolean value is NULL.

Remarks

Before you can display any panels, you must make the UI visible. Use the IWMEncoderApp::put_Visible method to specify the display state.

Example Code

// Include libraries.

#include <windows.h>
#include <atlbase.h>
#include "wmencode.h"

// Declare variables.

    HRESULT hr;
    IWMEncoderApp* pEncoderApp;
    long lHeight, lWidth, lTop, lLeft;
    VARIANT_BOOL vbUILock;
    CComVariant varSourceState = NULL;

// Initialize the COM library and retrieve a pointer
// to an IWMEncoderApp interface.

    hr = CoInitialize(NULL);
    CoCreateInstance(CLSID_WMEncoderApp,
                     NULL,
                     CLSCTX_LOCAL_SERVER,
                     IID_IWMEncoderApp,
                     (void**) &pEncoderApp);

// Display the predefined user interface (UI).

    hr = pEncoderApp->put_Visible(VARIANT_TRUE);

// Retrieve the height and width, in pixels, of the UI.

    hr = pEncoderApp->get_Height(&lHeight);
    hr = pEncoderApp->get_Width(&lWidth);

// Retrieve the top offset of the UI.

    hr = pEncoderApp->get_Top(&lTop);
    if (lTop != 0) lTop = 0;

// Retrieve the left offset of the UI.

    hr = pEncoderApp->get_Left(&lLeft);
    if (lLeft != 0) lLeft = 0;

// Determine whether the UI is locked.

    hr = pEncoderApp->get_UILock(&vbUILock);

// Determine whether the Sources panel is displayed.

    CComBSTR bstrSourceProp(L"View\\Sources");
    CComVariant varBool = NULL;
    hr = pEncoderApp->GetProperty(WMENCAPP_PROP_USER,
                                  bstrSourceProp,
                                  &varBool);

// Display the Sources panel.

    hr = pEncoderApp->SetProperty(WMENCAPP_PROP_USER,
                                  bstrSourceProp,
                                  VARIANT_TRUE);

See Also

  • IWMEncoderApp Interface
  • IWMEncoderApp::put_Visible


IWMEncoderApp::get_Width

The get_Width method retrieves the width of the UI, in pixels.

Syntax

HRESULT get_Width(
  long*  pVal
);

Parameters

pVal

[out] Pointer to a long containing the width of the UI, in pixels.

Return Values

If the method succeeds, it returns S_OK. If it fails, it returns an HRESULT error code.

Return code | Number | Meaning
E_POINTER | 0x80004003 | The pointer to the width is NULL.

Remarks

Use the IWMEncoderApp::put_Width method to specify the UI width.

Example Code

// Include libraries.

#include <windows.h>
#include <atlbase.h>
#include "wmencode.h"

// Declare variables.

    HRESULT hr;
    IWMEncoderApp* pEncoderApp;
    long lHeight, lWidth, lTop, lLeft;
    VARIANT_BOOL vbUILock;
    CComVariant varSourceState = NULL;

// Initialize the COM library and retrieve a pointer
// to an IWMEncoderApp interface.

    hr = CoInitialize(NULL);
    CoCreateInstance(CLSID_WMEncoderApp,
                     NULL,
                     CLSCTX_LOCAL_SERVER,
                     IID_IWMEncoderApp,
                     (void**) &pEncoderApp);

// Display the predefined user interface (UI).

    hr = pEncoderApp->put_Visible(VARIANT_TRUE);

// Retrieve the height and width, in pixels, of the UI.

    hr = pEncoderApp->get_Height(&lHeight);
    hr = pEncoderApp->get_Width(&lWidth);

// Retrieve the top offset of the UI.

    hr = pEncoderApp->get_Top(&lTop);
    if (lTop != 0) lTop = 0;

// Retrieve the left offset of the UI.

    hr = pEncoderApp->get_Left(&lLeft);
    if (lLeft != 0) lLeft = 0;

// Determine whether the UI is locked.

    hr = pEncoderApp->get_UILock(&vbUILock);

// Determine whether the Sources panel is displayed.

    CComBSTR bstrSourceProp(L"View\\Sources");
    CComVariant varBool = NULL;
    hr = pEncoderApp->GetProperty(WMENCAPP_PROP_USER,
                                  bstrSourceProp,
                                  &varBool);

// Display the Sources panel.

    hr = pEncoderApp->SetProperty(WMENCAPP_PROP_USER,
                                  bstrSourceProp,
                                  VARIANT_TRUE);

See Also

  • IWMEncoderApp Interface
  • IWMEncoderApp::put_Width


IWMEncoderApp::put_Height

The put_Height method specifies the height of the UI, in pixels.

Syntax

HRESULT put_Height(
  long  newVal
);

Parameters

newVal

[in] long containing the height of the UI, in pixels.

Return Values

If the method succeeds, it returns S_OK.

Remarks

Use the IWMEncoderApp::get_Height method to retrieve the height of the UI.

Example Code

// Include libraries.

#include <windows.h>
#include <atlbase.h>
#include "wmencode.h"

// Declare variables.

    HRESULT hr;
    IWMEncoderApp* pEncoderApp;
    long lHeight, lWidth, lTop, lLeft;
    VARIANT_BOOL vbUILock;
    CComVariant varSourceState = NULL;

// Initialize the COM library and retrieve a pointer
// to an IWMEncoderApp interface.

    hr = CoInitialize(NULL);
    CoCreateInstance(CLSID_WMEncoderApp,
                     NULL,
                     CLSCTX_LOCAL_SERVER,
                     IID_IWMEncoderApp,
                     (void**) &pEncoderApp);

// Display the predefined user interface (UI).

    hr = pEncoderApp->put_Visible(VARIANT_TRUE);

// Retrieve the height and width, in pixels, of the UI.

    hr = pEncoderApp->get_Height(&lHeight);
    hr = pEncoderApp->get_Width(&lWidth);

// Retrieve the top offset of the UI.

    hr = pEncoderApp->get_Top(&lTop);
    if (lTop != 0) lTop = 0;

// Retrieve the left offset of the UI.

    hr = pEncoderApp->get_Left(&lLeft);
    if (lLeft != 0) lLeft = 0;

// Determine whether the UI is locked.

    hr = pEncoderApp->get_UILock(&vbUILock);

// Determine whether the Sources panel is displayed.

    CComBSTR bstrSourceProp(L"View\\Sources");
    CComVariant varBool = NULL;
    hr = pEncoderApp->GetProperty(WMENCAPP_PROP_USER,
                                  bstrSourceProp,
                                  &varBool);

// Display the Sources panel.

    hr = pEncoderApp->SetProperty(WMENCAPP_PROP_USER,
                                  bstrSourceProp,
                                  VARIANT_TRUE);

See Also

  • IWMEncoderApp::get_Height
  • IWMEncoderApp Interface


IWMEncoderApp::put_Left

The put_Left method specifies the offset of the UI, in pixels, from the left side of the screen.

Syntax

HRESULT put_Left(
  long  newVal
);

Parameters

newVal

[in] long containing the offset of the UI, in pixels, from the left side of the screen.

Return Values

If the method succeeds, it returns S_OK.

Remarks

Use the IWMEncoderApp::get_Left method to retrieve the left offset of the UI.

Example Code

// Include libraries.

#include <windows.h>
#include <atlbase.h>
#include "wmencode.h"

// Declare variables.

    HRESULT hr;
    IWMEncoderApp* pEncoderApp;
    long lHeight, lWidth, lTop, lLeft;
    VARIANT_BOOL vbUILock;
    CComVariant varSourceState = NULL;

// Initialize the COM library and retrieve a pointer
// to an IWMEncoderApp interface.

    hr = CoInitialize(NULL);
    CoCreateInstance(CLSID_WMEncoderApp,
                     NULL,
                     CLSCTX_LOCAL_SERVER,
                     IID_IWMEncoderApp,
                     (void**) &pEncoderApp);

// Display the predefined user interface(UI).

    hr = pEncoderApp->put_Visible(VARIANT_TRUE);

// Retrieve the height and width, in pixels, of the UI.

    hr = pEncoderApp->get_Height(&lHeight);
    hr = pEncoderApp->get_Width(&lWidth);

// Retrieve the top offset of the UI.

    hr = pEncoderApp->get_Top(&lTop);
    if (lTop != 0) lTop = 0;

// Retrieve the left offset of the UI.

    hr = pEncoderApp->get_Left(&lLeft);
    if (lLeft != 0) lLeft = 0;

// Determine whether the UI is locked.

    hr = pEncoderApp->get_UILock(&vbUILock);

// Determine whether the Sources panel is displayed.

    CComBSTR bstrSourceProp(L"View\\Sources");
    CComVariant varBool = NULL;
    hr = pEncoderApp->GetProperty(WMENCAPP_PROP_USER,
                                  bstrSourceProp,
                                  &varBool);

// Display the Sources panel.

    hr = pEncoderApp->SetProperty(WMENCAPP_PROP_USER,
                                  bstrSourceProp,
                                  VARIANT_TRUE);

See Also

  • IWMEncoderApp::get_Left
  • IWMEncoderApp Interface


IWMEncoderApp::put_Top

The put_Top method specifies the offset of the UI, in pixels, from the top of the screen.

Syntax

HRESULT put_Top(
  long  newVal
);

Parameters

newVal

[in] long containing the offset of the UI, in pixels, from the top of the screen.

Return Values

If the method succeeds, it returns S_OK.

Remarks

Use the IWMEncoderApp::get_Top method to retrieve the offset.

Example Code

// Include libraries.

#include <windows.h>
#include <atlbase.h>
#include "wmencode.h"

// Declare variables.

    HRESULT hr;
    IWMEncoderApp* pEncoderApp;
    long lHeight, lWidth, lTop, lLeft;
    VARIANT_BOOL vbUILock;
    CComVariant varSourceState = NULL;

// Initialize the COM library and retrieve a pointer
// to an IWMEncoderApp interface.

    hr = CoInitialize(NULL);
    CoCreateInstance(CLSID_WMEncoderApp,
                     NULL,
                     CLSCTX_LOCAL_SERVER,
                     IID_IWMEncoderApp,
                     (void**) &pEncoderApp);

// Display the predefined user interface (UI).

    hr = pEncoderApp->put_Visible(VARIANT_TRUE);

// Retrieve the height and width, in pixels, of the UI.

    hr = pEncoderApp->get_Height(&lHeight);
    hr = pEncoderApp->get_Width(&lWidth);

// Retrieve the top offset of the UI.

    hr = pEncoderApp->get_Top(&lTop);
    if (lTop != 0) lTop = 0;

// Retrieve the left offset of the UI.

    hr = pEncoderApp->get_Left(&lLeft);
    if (lLeft != 0) lLeft = 0;

// Determine whether the UI is locked.

    hr = pEncoderApp->get_UILock(&vbUILock);

// Determine whether the Sources panel is displayed.

    CComBSTR bstrSourceProp(L"View\\Sources");
    CComVariant varBool = NULL;
    hr = pEncoderApp->GetProperty(WMENCAPP_PROP_USER,
                                  bstrSourceProp,
                                  &varBool);

// Display the Sources panel.

    hr = pEncoderApp->SetProperty(WMENCAPP_PROP_USER,
                                  bstrSourceProp,
                                  VARIANT_TRUE);

See Also

  • IWMEncoderApp::get_Top
  • IWMEncoderApp Interface


IWMEncoderApp::put_UILock

The put_UILock method specifies the lock state of the UI.

Syntax

HRESULT put_UILock(
  VARIANT_BOOL  newVal
);

Parameters

newVal

[in] VARIANT_BOOL indicating whether the UI is locked.

Return Values

If the method succeeds, it returns S_OK.

Remarks

Lock the UI from the local computer to stop it from being changed remotely.

Example Code

// Include libraries.

#include <windows.h>
#include <atlbase.h>
#include "wmencode.h"

// Declare variables.

    HRESULT hr;
    IWMEncoderApp* pEncoderApp;
    long lHeight, lWidth, lTop, lLeft;
    VARIANT_BOOL vbUILock;
    CComVariant varSourceState = NULL;

// Initialize the COM library and retrieve a pointer
// to an IWMEncoderApp interface.

    hr = CoInitialize(NULL);
    CoCreateInstance(CLSID_WMEncoderApp,
                     NULL,
                     CLSCTX_LOCAL_SERVER,
                     IID_IWMEncoderApp,
                     (void**) &pEncoderApp);

// Display the predefined user interface (UI).

    hr = pEncoderApp->put_Visible(VARIANT_TRUE);

// Retrieve the height and width, in pixels, of the UI.

    hr = pEncoderApp->get_Height(&lHeight);
    hr = pEncoderApp->get_Width(&lWidth);

// Retrieve the top offset of the UI.

    hr = pEncoderApp->get_Top(&lTop);
    if (lTop != 0) lTop = 0;

// Retrieve the left offset of the UI.

    hr = pEncoderApp->get_Left(&lLeft);
    if (lLeft != 0) lLeft = 0;

// Determine whether the UI is locked.

    hr = pEncoderApp->get_UILock(&vbUILock);

// Determine whether the Sources panel is displayed.

    CComBSTR bstrSourceProp(L"View\\Sources");
    CComVariant varBool = NULL;
    hr = pEncoderApp->GetProperty(WMENCAPP_PROP_USER,
                                  bstrSourceProp,
                                  &varBool);

// Display the Sources panel.

    hr = pEncoderApp->SetProperty(WMENCAPP_PROP_USER,
                                  bstrSourceProp,
                                  VARIANT_TRUE);

See Also

  • IWMEncoderApp::get_UILock
  • IWMEncoderApp Interface


IWMEncoderApp::put_Visible

The put_Visible method specifies the display state of the UI.

Syntax

HRESULT put_Visible(
  VARIANT_BOOL  newVal
);

Parameters

newVal

[in] VARIANT_BOOL indicating the display state of the UI.

Return Values

If the method succeeds, it returns S_OK.

Remarks

The UI must be made visible before any of the individual panels can be displayed. Use the IWMEncoderApp::get_Visible method to retrieve the display state.

Example Code

// Include libraries.

#include <windows.h>
#include <atlbase.h>
#include "wmencode.h"

// Declare variables.

    HRESULT hr;
    IWMEncoderApp* pEncoderApp;
    long lHeight, lWidth, lTop, lLeft;
    VARIANT_BOOL vbUILock;
    CComVariant varSourceState = NULL;

// Initialize the COM library and retrieve a pointer
// to an IWMEncoderApp interface.

    hr = CoInitialize(NULL);
    CoCreateInstance(CLSID_WMEncoderApp,
                     NULL,
                     CLSCTX_LOCAL_SERVER,
                     IID_IWMEncoderApp,
                     (void**) &pEncoderApp);

// Display the predefined user interface (UI).

    hr = pEncoderApp->put_Visible(VARIANT_TRUE);

// Retrieve the height and width, in pixels, of the UI.

    hr = pEncoderApp->get_Height(&lHeight);
    hr = pEncoderApp->get_Width(&lWidth);

// Retrieve the top offset of the UI.

    hr = pEncoderApp->get_Top(&lTop);
    if (lTop != 0) lTop = 0;

// Retrieve the left offset of the UI.

    hr = pEncoderApp->get_Left(&lLeft);
    if (lLeft != 0) lLeft = 0;

// Determine whether the UI is locked.

    hr = pEncoderApp->get_UILock(&vbUILock);

// Determine whether the Sources panel is displayed.

    CComBSTR bstrSourceProp(L"View\\Sources");
    CComVariant varBool = NULL;
    hr = pEncoderApp->GetProperty(WMENCAPP_PROP_USER,
                                  bstrSourceProp,
                                  &varBool);

// Display the Sources panel.

    hr = pEncoderApp->SetProperty(WMENCAPP_PROP_USER,
                                  bstrSourceProp,
                                  VARIANT_TRUE);

See Also

  • IWMEncoderApp::get_Visible
  • IWMEncoderApp Interface


IWMEncoderApp::put_Width

The put_Width method specifies the width of the UI, in pixels.

Syntax

HRESULT put_Width(
  long  newVal
);

Parameters

newVal

[in] long containing the pixel width of the UI, in pixels.

Return Values

If the method succeeds, it returns S_OK.

Remarks

Use the IWMEncoderApp::get_Width method to retrieve the pixel width of the UI.

Example Code

// Include libraries.

#include <windows.h>
#include <atlbase.h>
#include "wmencode.h"

// Declare variables.

    HRESULT hr;
    IWMEncoderApp* pEncoderApp;
    long lHeight, lWidth, lTop, lLeft;
    VARIANT_BOOL vbUILock;
    CComVariant varSourceState = NULL;

// Initialize the COM library and retrieve a pointer
// to an IWMEncoderApp interface.

    hr = CoInitialize(NULL);
    CoCreateInstance(CLSID_WMEncoderApp,
                     NULL,
                     CLSCTX_LOCAL_SERVER,
                     IID_IWMEncoderApp,
                     (void**) &pEncoderApp);

// Display the predefined user interface (UI).

    hr = pEncoderApp->put_Visible(VARIANT_TRUE);

// Retrieve the height and width, in pixels, of the UI.

    hr = pEncoderApp->get_Height(&lHeight);
    hr = pEncoderApp->get_Width(&lWidth);

// Retrieve the top offset of the UI.

    hr = pEncoderApp->get_Top(&lTop);
    if (lTop != 0) lTop = 0;

// Retrieve the left offset of the UI.

    hr = pEncoderApp->get_Left(&lLeft);
    if (lLeft != 0) lLeft = 0;

// Determine whether the UI is locked.

    hr = pEncoderApp->get_UILock(&vbUILock);

// Determine whether the Sources panel is displayed.

    CComBSTR bstrSourceProp(L"View\\Sources");
    CComVariant varBool = NULL;
    hr = pEncoderApp->GetProperty(WMENCAPP_PROP_USER,
                                  bstrSourceProp,
                                  &varBool);

// Display the Sources panel.

    hr = pEncoderApp->SetProperty(WMENCAPP_PROP_USER,
                                  bstrSourceProp,
                                  VARIANT_TRUE);

See Also

  • IWMEncoderApp::get_Width
  • IWMEncoderApp Interface


IWMEncoderApp::SaveProperties

The SaveProperties method saves changes to the UI properties.

Syntax

HRESULT SaveProperties(
  WMENCAPP_PROP_CLASS  enumClass
);

Parameters

enumClass

[in] Member of a WMENCAPP_PROP_CLASS enumeration type identifying the property class for which the properties will be saved. Currently, this must be the following value.

Value | Number | Meaning
WMENCAPP_PROP_USER | 1 | Identifies the end-user class.

Return Values

If the method succeeds, it returns S_OK. If it fails, it returns an HRESULT error code.

Return code | Number | Meaning
E_INVALIDARG | 0x80070057 | You must specify the property class as WMENCAPP_PROP_USER

Remarks

You must call this method because the Windows Media Encoder SDK does not automatically save changes to UI properties.

Example Code

// Include libraries.

#include <windows.h>
#include <atlbase.h>
#include "wmencode.h"

// Declare variables.

    HRESULT hr;
    IWMEncoderApp* pEncoderApp;
    long lHeight, lWidth, lTop, lLeft;
    VARIANT_BOOL vbUILock;
    CComVariant varSourceState = NULL;

// Initialize the COM library and retrieve a pointer
// to an IWMEncoderApp interface.

    hr = CoInitialize(NULL);
    CoCreateInstance(CLSID_WMEncoderApp,
                     NULL,
                     CLSCTX_LOCAL_SERVER,
                     IID_IWMEncoderApp,
                     (void**) &pEncoderApp);

// Display the predefined user interface (UI).

    hr = pEncoderApp->put_Visible(VARIANT_TRUE);

// Retrieve the height and width, in pixels, of the UI.

    hr = pEncoderApp->get_Height(&lHeight);
    hr = pEncoderApp->get_Width(&lWidth);

// Retrieve the top offset of the UI.

    hr = pEncoderApp->get_Top(&lTop);
    if (lTop != 0) lTop = 0;

// Retrieve the left offset of the UI.

    hr = pEncoderApp->get_Left(&lLeft);
    if (lLeft != 0) lLeft = 0;

// Determine whether the UI is locked.

    hr = pEncoderApp->get_UILock(&vbUILock);

// Determine whether the Sources panel is displayed.

    CComBSTR bstrSourceProp(L"View\\Sources");
    CComVariant varBool = NULL;
    hr = pEncoderApp->GetProperty(WMENCAPP_PROP_USER,
                                  bstrSourceProp,
                                  &varBool);

// Display the Sources panel.

    hr = pEncoderApp->SetProperty(WMENCAPP_PROP_USER,
                                  bstrSourceProp,
                                  VARIANT_TRUE);

See Also

  • IWMEncoderApp Interface


IWMEncoderApp::SetProperty

The SetProperty method specifies a property that identifies the display state of a UI panel, property page, or window.

Syntax

HRESULT SetProperty(
  WMENCAPP_PROP_CLASS  enumClass,
  BSTR  bstrProperty,
  VARIANT  Value
);

Parameters

enumClass

[in] Member of a WMENCAPP_PROP_CLASS enumeration type identifying the property class. Currently, this must be the following value.

Value | Number | Meaning
WMENCAPP_PROP_USER | 1 | Identifies the end-user class.

bstrProperty

[in] BSTR containing the property.

Value

[in] VARIANT containing the display state.

Return Values

If the method succeeds, it returns S_OK. If it fails, it returns an HRESULT error code.

Return code | Number | Meaning
E_INVALIDARG | 0x80070057 | You must specify the property class as WMENCAPP_PROP_USER

Remarks

Any change to the UI by an end user causes the property to change appropriately. The following table lists the properties that are currently defined for Windows Media Encoder.

Property | Variant | Description
View\Sources | Boolean | Specifies the display state of the Sources panel.
View\Audio | Boolean | Specifies the display state of the Audio panel.
View\Monitor | Boolean | Specifies the display state of the Monitor panel.
View\Control | Boolean | Specifies the display state of the Control panel.
View\Script | Boolean | Specifies the display state of the Annotation panel.
View\Archive | Boolean | Specifies the display state of the Archive panel.
View\Video1 | Boolean | Specifies the display state of the Video window.
View\MonitorPage | Integer | Specifies the property page in the Monitor panel. The varValue parameter can take the following values: 100 = General page. 300 = Display Information page. 600 = Connections page.
Video1\Zoom | Integer | Identifies the zoom factor for the video window. For example, use 200 to specify 200%.
Video1\Display | Integer | Identifies the display style of the video window: 0 = input. 1 = Output. 2 = Both. 3 = Next. 4 = Split.

Example Code

// Include libraries.

#include <windows.h>
#include <atlbase.h>
#include "wmencode.h"

// Declare variables.

    HRESULT hr;
    IWMEncoderApp* pEncoderApp;
    long lHeight, lWidth, lTop, lLeft;
    VARIANT_BOOL vbUILock;
    CComVariant varSourceState = NULL;

// Initialize the COM library and retrieve a pointer
// to an IWMEncoderApp interface.

    hr = CoInitialize(NULL);
    CoCreateInstance(CLSID_WMEncoderApp,
                     NULL,
                     CLSCTX_LOCAL_SERVER,
                     IID_IWMEncoderApp,
                     (void**) &pEncoderApp);

// Display the predefined user interface (UI).

    hr = pEncoderApp->put_Visible(VARIANT_TRUE);

// Retrieve the height and width, in pixels, of the UI.

    hr = pEncoderApp->get_Height(&lHeight);
    hr = pEncoderApp->get_Width(&lWidth);

// Retrieve the top offset of the UI.

    hr = pEncoderApp->get_Top(&lTop);
    if (lTop != 0) lTop = 0;

// Retrieve the left offset of the UI.

    hr = pEncoderApp->get_Left(&lLeft);
    if (lLeft != 0) lLeft = 0;

// Determine whether the UI is locked.

    hr = pEncoderApp->get_UILock(&vbUILock);

// Determine whether the Sources panel is displayed.

    CComBSTR bstrSourceProp(L"View\\Sources");
    CComVariant varBool = NULL;
    hr = pEncoderApp->GetProperty(WMENCAPP_PROP_USER,
                                  bstrSourceProp,
                                  &varBool);

// Display the Sources panel.

    hr = pEncoderApp->SetProperty(WMENCAPP_PROP_USER,
                                  bstrSourceProp,
                                  VARIANT_TRUE);

See Also

  • IWMEncoderApp::GetProperty
  • IWMEncoderApp Interface


IWMEncOutputStats Interface

The IWMEncOutputStats interface retrieves status information about the encoding session. In addition to the methods inherited from IDispatch, the IWMEncOutputStats interface exposes the following methods.

Interface | Description
get_AverageBitrate | Retrieves the average number of bits encoded per second since the encoder engine was started.
get_AverageSampleRate | Retrieves the average number of media samples encoded per second since the encoder engine was started.
get_ByteCount | Retrieves the number of bytes encoded since the encoder engine was started.
get_CurrentBitrate | Retrieves the number of bits being encoded per second at the moment this method is called.
get_CurrentSampleRate | Retrieves the number of samples being encoded per second at the moment this method is called.
get_DroppedByteCount | Retrieves the number of bytes dropped since the encoder engine was started.
get_DroppedSampleCount | Retrieves the number of media samples not encoded since the encoder engine was started.
get_ExpectedBitrate | Retrieves the encoding bit rate expected throughout the encoding session.
get_ExpectedSampleRate | Retrieves the encoding sample rate expected throughout the encoding session.
get_SampleCount | Retrieves the number of samples encoded since the encoder engine was started.

See Also

  • Interfaces (C++)
  • [Visual Basic] IWMEncOutputStats Object


IWMEncOutputStats::get_AverageBitrate

The get_AverageBitrate method retrieves the average number of bits encoded per second since the encoder engine was started.

Syntax

HRESULT get_AverageBitrate(
  long*  plAverageBitrate
);

Parameters

plAverageBitrate

[out] Pointer to a long containing the average bit rate.

Return Values

If the method succeeds, it returns S_OK.

Example Code

// Include libraries.

#include <windows.h>
#include <atlbase.h>    // Includes CComBSTR.
#include "wmencode.h"

// Declare variables.

    HRESULT hr;
    IWMEncoder* pEncoder;
    IWMEncStatistics* pStatistics;
    IWMEncOutputStats* pOutputStats;
    IDispatch* pDispOutputStats;

    long lAvgBitrate, lAvgSampleRate;
    long lCurrentBitRate, lCurrentSampleRate;
    long lExpectedBitRate, lExpectedSampleRate;
    WMENC_longlong qwByteCount, qwSampleCount;
    WMENC_longlong qwDroppedByteCount, qwDroppedSampleCount;

// Initialize the COM library and retrieve a pointer
// to an IWMEncoder interface.

    hr = CoInitialize(NULL);
    CoCreateInstance(CLSID_WMEncoder,
                     NULL,
                     CLSCTX_INPROC_SERVER,
                     IID_IWMEncoder,
                    (void**) &pEncoder);

// Retrieve an IWMEncStatistics interface pointer.

    hr = pEncoder->get_Statistics(&pStatistics);

// Retrieve an IDispatch pointer for the IWMEncOutputStats
// interface.

    hr = pStatistics->get_StreamOutputStats(WMENC_AUDIO,
                                            0,
                                            0,
                                            &pDispOutputStats);

// Call QueryInterface for the IWMEncNetConnectionStats
// interface pointer.

    hr = pDispOutputStats->QueryInterface(IID_IWMEncOutputStats,
                                          (void**)&pOutputStats);

// Manually configure the encoder engine or load
// a configuration from a file. For an example, see the
// IWMEncFile object.

// You can create a timer to retrieve the statistics
// after you start the encoder engine.

    hr = pOutputStats->get_AverageBitrate(&lAvgBitrate);
    hr = pOutputStats->get_AverageSampleRate(&lAvgSampleRate);
    hr = pOutputStats->get_ByteCount(&qwByteCount);
    hr = pOutputStats->get_CurrentBitrate(&lCurrentBitRate);
    hr = pOutputStats->get_CurrentSampleRate(&lCurrentSampleRate);
    hr = pOutputStats->get_DroppedByteCount(&qwDroppedByteCount);
    hr = pOutputStats->get_DroppedSampleCount(&qwDroppedSampleCount);
    hr = pOutputStats->get_ExpectedBitrate(&lExpectedBitRate);
    hr = pOutputStats->get_ExpectedSampleRate(&lExpectedSampleRate);
    hr = pOutputStats->get_SampleCount(&qwSampleCount);

See Also

  • IWMEncOutputStats Interface


IWMEncOutputStats::get_AverageSampleRate

The get_AverageSampleRate method retrieves the average number of media samples encoded per second since the encoder engine was started.

Syntax

HRESULT get_AverageSampleRate(
  long*  plAverageSampleRate
);

Parameters

plAverageSampleRate

[out] Pointer to a long containing the average sample rate.

Return Values

If the method succeeds, it returns S_OK.

Example Code

// Include libraries.

#include <windows.h>
#include <atlbase.h>    // Includes CComBSTR.
#include "wmencode.h"

// Declare variables.

    HRESULT hr;
    IWMEncoder* pEncoder;
    IWMEncStatistics* pStatistics;
    IWMEncOutputStats* pOutputStats;
    IDispatch* pDispOutputStats;

    long lAvgBitrate, lAvgSampleRate;
    long lCurrentBitRate, lCurrentSampleRate;
    long lExpectedBitRate, lExpectedSampleRate;
    WMENC_longlong qwByteCount, qwSampleCount;
    WMENC_longlong qwDroppedByteCount, qwDroppedSampleCount;

// Initialize the COM library and retrieve a pointer
// to an IWMEncoder interface.

    hr = CoInitialize(NULL);
    CoCreateInstance(CLSID_WMEncoder,
                     NULL,
                     CLSCTX_INPROC_SERVER,
                     IID_IWMEncoder,
                    (void**) &pEncoder);

// Retrieve an IWMEncStatistics interface pointer.

    hr = pEncoder->get_Statistics(&pStatistics);

// Retrieve an IDispatch pointer for the IWMEncOutputStats
// interface.

    hr = pStatistics->get_StreamOutputStats(WMENC_AUDIO,
                                            0,
                                            0,
                                            &pDispOutputStats);

// Call QueryInterface for the IWMEncNetConnectionStats
// interface pointer.

    hr = pDispOutputStats->QueryInterface(IID_IWMEncOutputStats,
                                          (void**)&pOutputStats);

// Manually configure the encoder engine or load
// a configuration from a file. For an example, see the
// IWMEncFile object.

// You can create a timer to retrieve the statistics
// after you start the encoder engine.

    hr = pOutputStats->get_AverageBitrate(&lAvgBitrate);
    hr = pOutputStats->get_AverageSampleRate(&lAvgSampleRate);
    hr = pOutputStats->get_ByteCount(&qwByteCount);
    hr = pOutputStats->get_CurrentBitrate(&lCurrentBitRate);
    hr = pOutputStats->get_CurrentSampleRate(&lCurrentSampleRate);
    hr = pOutputStats->get_DroppedByteCount(&qwDroppedByteCount);
    hr = pOutputStats->get_DroppedSampleCount(&qwDroppedSampleCount);
    hr = pOutputStats->get_ExpectedBitrate(&lExpectedBitRate);
    hr = pOutputStats->get_ExpectedSampleRate(&lExpectedSampleRate);
    hr = pOutputStats->get_SampleCount(&qwSampleCount);

See Also

  • IWMEncOutputStats Interface


IWMEncOutputStats::get_ByteCount

The get_ByteCount method retrieves the number of bytes encoded since the encoder engine was started.

Syntax

HRESULT get_ByteCount(
  WMENC_longlong*  pqwByteCount
);

Parameters

pqwByteCount

[out] Pointer to a QWORD containing the byte count.

Return Values

If the method succeeds, it returns S_OK.

Remarks

The WMENC_longlong data type is a typedef from the CURRENCY type. A 64-bit integer is needed to hold the byte count, and CURRENCY is the only 64-bit integer type that Automation supports. To manipulate the value, you can use the following:

    qwByteCount.int64

The output statistics do not persist after the encoding process has stopped.

Example Code

// Include libraries.

#include <windows.h>
#include <atlbase.h>    // Includes CComBSTR.
#include "wmencode.h"

// Declare variables.

    HRESULT hr;
    IWMEncoder* pEncoder;
    IWMEncStatistics* pStatistics;
    IWMEncOutputStats* pOutputStats;
    IDispatch* pDispOutputStats;

    long lAvgBitrate, lAvgSampleRate;
    long lCurrentBitRate, lCurrentSampleRate;
    long lExpectedBitRate, lExpectedSampleRate;
    WMENC_longlong qwByteCount, qwSampleCount;
    WMENC_longlong qwDroppedByteCount, qwDroppedSampleCount;

// Initialize the COM library and retrieve a pointer
// to an IWMEncoder interface.

    hr = CoInitialize(NULL);
    CoCreateInstance(CLSID_WMEncoder,
                     NULL,
                     CLSCTX_INPROC_SERVER,
                     IID_IWMEncoder,
                    (void**) &pEncoder);

// Retrieve an IWMEncStatistics interface pointer.

    hr = pEncoder->get_Statistics(&pStatistics);

// Retrieve an IDispatch pointer for the IWMEncOutputStats
// interface.

    hr = pStatistics->get_StreamOutputStats(WMENC_AUDIO,
                                            0,
                                            0,
                                            &pDispOutputStats);

// Call QueryInterface for the IWMEncNetConnectionStats
// interface pointer.

    hr = pDispOutputStats->QueryInterface(IID_IWMEncOutputStats,
                                          (void**)&pOutputStats);

// Manually configure the encoder engine or load
// a configuration from a file. For an example, see the
// IWMEncFile object.

// You can create a timer to retrieve the statistics
// after you start the encoder engine.

    hr = pOutputStats->get_AverageBitrate(&lAvgBitrate);
    hr = pOutputStats->get_AverageSampleRate(&lAvgSampleRate);
    hr = pOutputStats->get_ByteCount(&qwByteCount);
    hr = pOutputStats->get_CurrentBitrate(&lCurrentBitRate);
    hr = pOutputStats->get_CurrentSampleRate(&lCurrentSampleRate);
    hr = pOutputStats->get_DroppedByteCount(&qwDroppedByteCount);
    hr = pOutputStats->get_DroppedSampleCount(&qwDroppedSampleCount);
    hr = pOutputStats->get_ExpectedBitrate(&lExpectedBitRate);
    hr = pOutputStats->get_ExpectedSampleRate(&lExpectedSampleRate);
    hr = pOutputStats->get_SampleCount(&qwSampleCount);

See Also

  • IWMEncOutputStats Interface


IWMEncOutputStats::get_CurrentBitrate

The get_CurrentBitrate method retrieves the number of bits being encoded per second at the moment this method is called.

Syntax

HRESULT get_CurrentBitrate(
  long*  plCurrentBitrate
);

Parameters

plCurrentBitrate

[out] Pointer to a long containing the current bit rate.

Return Values

If the method succeeds, it returns S_OK.

Example Code

// Include libraries.

#include <windows.h>
#include <atlbase.h>    // Includes CComBSTR.
#include "wmencode.h"

// Declare variables.

    HRESULT hr;
    IWMEncoder* pEncoder;
    IWMEncStatistics* pStatistics;
    IWMEncOutputStats* pOutputStats;
    IDispatch* pDispOutputStats;

    long lAvgBitrate, lAvgSampleRate;
    long lCurrentBitRate, lCurrentSampleRate;
    long lExpectedBitRate, lExpectedSampleRate;
    WMENC_longlong qwByteCount, qwSampleCount;
    WMENC_longlong qwDroppedByteCount, qwDroppedSampleCount;

// Initialize the COM library and retrieve a pointer
// to an IWMEncoder interface.

    hr = CoInitialize(NULL);
    CoCreateInstance(CLSID_WMEncoder,
                     NULL,
                     CLSCTX_INPROC_SERVER,
                     IID_IWMEncoder,
                    (void**) &pEncoder);

// Retrieve an IWMEncStatistics interface pointer.

    hr = pEncoder->get_Statistics(&pStatistics);

// Retrieve an IDispatch pointer for the IWMEncOutputStats
// interface.

    hr = pStatistics->get_StreamOutputStats(WMENC_AUDIO,
                                            0,
                                            0,
                                            &pDispOutputStats);

// Call QueryInterface for the IWMEncNetConnectionStats
// interface pointer.

    hr = pDispOutputStats->QueryInterface(IID_IWMEncOutputStats,
                                          (void**)&pOutputStats);

// Manually configure the encoder engine or load
// a configuration from a file. For an example, see the
// IWMEncFile object.

// You can create a timer to retrieve the statistics
// after you start the encoder engine.

    hr = pOutputStats->get_AverageBitrate(&lAvgBitrate);
    hr = pOutputStats->get_AverageSampleRate(&lAvgSampleRate);
    hr = pOutputStats->get_ByteCount(&qwByteCount);
    hr = pOutputStats->get_CurrentBitrate(&lCurrentBitRate);
    hr = pOutputStats->get_CurrentSampleRate(&lCurrentSampleRate);
    hr = pOutputStats->get_DroppedByteCount(&qwDroppedByteCount);
    hr = pOutputStats->get_DroppedSampleCount(&qwDroppedSampleCount);
    hr = pOutputStats->get_ExpectedBitrate(&lExpectedBitRate);
    hr = pOutputStats->get_ExpectedSampleRate(&lExpectedSampleRate);
    hr = pOutputStats->get_SampleCount(&qwSampleCount);

See Also

  • IWMEncOutputStats Interface


IWMEncOutputStats::get_CurrentSampleRate

The get_CurrentSampleRate method retrieves the number of samples being encoded per second at the moment this method is called.

Syntax

HRESULT get_CurrentSampleRate(
  long*  plCurrentSampleRate
);

Parameters

plCurrentSampleRate

[out] Pointer to a long containing the current sample rate.

Return Values

If the method succeeds, it returns S_OK. If it fails, it returns E_FAIL.

Example Code

// Include libraries.

#include <windows.h>
#include <atlbase.h>    // Includes CComBSTR.
#include "wmencode.h"

// Declare variables.

    HRESULT hr;
    IWMEncoder* pEncoder;
    IWMEncStatistics* pStatistics;
    IWMEncOutputStats* pOutputStats;
    IDispatch* pDispOutputStats;

    long lAvgBitrate, lAvgSampleRate;
    long lCurrentBitRate, lCurrentSampleRate;
    long lExpectedBitRate, lExpectedSampleRate;
    WMENC_longlong qwByteCount, qwSampleCount;
    WMENC_longlong qwDroppedByteCount, qwDroppedSampleCount;

// Initialize the COM library and retrieve a pointer
// to an IWMEncoder interface.

    hr = CoInitialize(NULL);
    CoCreateInstance(CLSID_WMEncoder,
                     NULL,
                     CLSCTX_INPROC_SERVER,
                     IID_IWMEncoder,
                    (void**) &pEncoder);

// Retrieve an IWMEncStatistics interface pointer.

    hr = pEncoder->get_Statistics(&pStatistics);

// Retrieve an IDispatch pointer for the IWMEncOutputStats
// interface.

    hr = pStatistics->get_StreamOutputStats(WMENC_AUDIO,
                                            0,
                                            0,
                                            &pDispOutputStats);

// Call QueryInterface for the IWMEncNetConnectionStats
// interface pointer.

    hr = pDispOutputStats->QueryInterface(IID_IWMEncOutputStats,
                                          (void**)&pOutputStats);

// Manually configure the encoder engine or load
// a configuration from a file. For an example, see the
// IWMEncFile object.

// You can create a timer to retrieve the statistics
// after you start the encoder engine.

    hr = pOutputStats->get_AverageBitrate(&lAvgBitrate);
    hr = pOutputStats->get_AverageSampleRate(&lAvgSampleRate);
    hr = pOutputStats->get_ByteCount(&qwByteCount);
    hr = pOutputStats->get_CurrentBitrate(&lCurrentBitRate);
    hr = pOutputStats->get_CurrentSampleRate(&lCurrentSampleRate);
    hr = pOutputStats->get_DroppedByteCount(&qwDroppedByteCount);
    hr = pOutputStats->get_DroppedSampleCount(&qwDroppedSampleCount);
    hr = pOutputStats->get_ExpectedBitrate(&lExpectedBitRate);
    hr = pOutputStats->get_ExpectedSampleRate(&lExpectedSampleRate);
    hr = pOutputStats->get_SampleCount(&qwSampleCount);

See Also

  • IWMEncOutputStats Interface


IWMEncOutputStats::get_DroppedByteCount

The get_DroppedByteCount method retrieves the number of bytes dropped since the encoder engine was started.

Syntax

HRESULT get_DroppedByteCount(
  WMENC_longlong*  pqwDroppedByteCount
);

Parameters

pqwDroppedByteCount

[out] Pointer to a QWORD containing the dropped byte count.

Return Values

If the method succeeds, it returns S_OK.

Remarks

The WMENC_longlong data type is a typedef from the CURRENCY type. A 64-bit integer is needed to hold the byte count, and CURRENCY is the only 64-bit integer type that Automation supports. To manipulate the value, you can use the following:

    qwDroppedByteCount.int64

The output statistics do not persist after the encoding process has stopped.

Example Code

// Include libraries.

#include <windows.h>
#include <atlbase.h>    // Includes CComBSTR.
#include "wmencode.h"

// Declare variables.

    HRESULT hr;
    IWMEncoder* pEncoder;
    IWMEncStatistics* pStatistics;
    IWMEncOutputStats* pOutputStats;
    IDispatch* pDispOutputStats;

    long lAvgBitrate, lAvgSampleRate;
    long lCurrentBitRate, lCurrentSampleRate;
    long lExpectedBitRate, lExpectedSampleRate;
    WMENC_longlong qwByteCount, qwSampleCount;
    WMENC_longlong qwDroppedByteCount, qwDroppedSampleCount;

// Initialize the COM library and retrieve a pointer
// to an IWMEncoder interface.

    hr = CoInitialize(NULL);
    CoCreateInstance(CLSID_WMEncoder,
                     NULL,
                     CLSCTX_INPROC_SERVER,
                     IID_IWMEncoder,
                    (void**) &pEncoder);

// Retrieve an IWMEncStatistics interface pointer.

    hr = pEncoder->get_Statistics(&pStatistics);

// Retrieve an IDispatch pointer for the IWMEncOutputStats
// interface.

    hr = pStatistics->get_StreamOutputStats(WMENC_AUDIO,
                                            0,
                                            0,
                                            &pDispOutputStats);

// You must call QueryInterface for the IWMEncNetConnectionStats
// interface pointer.

    hr = pDispOutputStats->QueryInterface(IID_IWMEncOutputStats,
                                          (void**)&pOutputStats);

// Manually configure the encoder engine or load
// a configuration from a file. For an example, see the
// IWMEncFile object.

// You can create a timer to retrieve the statistics
// after you start the encoder engine.

    hr = pOutputStats->get_AverageBitrate(&lAvgBitrate);
    hr = pOutputStats->get_AverageSampleRate(&lAvgSampleRate);
    hr = pOutputStats->get_ByteCount(&qwByteCount);
    hr = pOutputStats->get_CurrentBitrate(&lCurrentBitRate);
    hr = pOutputStats->get_CurrentSampleRate(&lCurrentSampleRate);
    hr = pOutputStats->get_DroppedByteCount(&qwDroppedByteCount);
    hr = pOutputStats->get_DroppedSampleCount(&qwDroppedSampleCount);
    hr = pOutputStats->get_ExpectedBitrate(&lExpectedBitRate);
    hr = pOutputStats->get_ExpectedSampleRate(&lExpectedSampleRate);
    hr = pOutputStats->get_SampleCount(&qwSampleCount);

See Also

  • IWMEncOutputStats Interface


IWMEncOutputStats::get_DroppedSampleCount

The get_DroppedSampleCount method retrieves the number of media samples dropped since the encoder engine was started.

Syntax

HRESULT get_DroppedSampleCount(
  WMENC_longlong*  pqwDroppedSampleCount
);

Parameters

pqwDroppedSampleCount

[out] Pointer to a QWORD containing the number of samples dropped.

Return Values

If the method succeeds, it returns S_OK.

Remarks

The WMENC_longlong data type is a typedef from the CURRENCY type. A 64-bit integer is needed to hold the byte count, and CURRENCY is the only 64-bit integer type that Automation supports. To manipulate the value, you can use the following:

    qwDroppedSampleCount.int64

The output statistics do not persist after the encoding process has stopped.

Example Code

// Include libraries.

#include <windows.h>
#include <atlbase.h>    // Includes CComBSTR.
#include "wmencode.h"

// Declare variables.

    HRESULT hr;
    IWMEncoder* pEncoder;
    IWMEncStatistics* pStatistics;
    IWMEncOutputStats* pOutputStats;
    IDispatch* pDispOutputStats;

    long lAvgBitrate, lAvgSampleRate;
    long lCurrentBitRate, lCurrentSampleRate;
    long lExpectedBitRate, lExpectedSampleRate;
    WMENC_longlong qwByteCount, qwSampleCount;
    WMENC_longlong qwDroppedByteCount, qwDroppedSampleCount;

// Initialize the COM library and retrieve a pointer
// to an IWMEncoder interface.

    hr = CoInitialize(NULL);
    CoCreateInstance(CLSID_WMEncoder,
                     NULL,
                     CLSCTX_INPROC_SERVER,
                     IID_IWMEncoder,
                    (void**) &pEncoder);

// Retrieve an IWMEncStatistics interface pointer.

    hr = pEncoder->get_Statistics(&pStatistics);

// Retrieve an IDispatch pointer for the IWMEncOutputStats
// interface.

    hr = pStatistics->get_StreamOutputStats(WMENC_AUDIO,
                                            0,
                                            0,
                                            &pDispOutputStats);

// Call QueryInterface for the IWMEncNetConnectionStats
// interface pointer.

    hr = pDispOutputStats->QueryInterface(IID_IWMEncOutputStats,
                                          (void**)&pOutputStats);

// Manually configure the encoder engine or load
// a configuration from a file. For an example, see the
// IWMEncFile object.

// You can create a timer to retrieve the statistics
// after you start the encoder engine.

    hr = pOutputStats->get_AverageBitrate(&lAvgBitrate);
    hr = pOutputStats->get_AverageSampleRate(&lAvgSampleRate);
    hr = pOutputStats->get_ByteCount(&qwByteCount);
    hr = pOutputStats->get_CurrentBitrate(&lCurrentBitRate);
    hr = pOutputStats->get_CurrentSampleRate(&lCurrentSampleRate);
    hr = pOutputStats->get_DroppedByteCount(&qwDroppedByteCount);
    hr = pOutputStats->get_DroppedSampleCount(&qwDroppedSampleCount);
    hr = pOutputStats->get_ExpectedBitrate(&lExpectedBitRate);
    hr = pOutputStats->get_ExpectedSampleRate(&lExpectedSampleRate);
    hr = pOutputStats->get_SampleCount(&qwSampleCount);

See Also

  • IWMEncOutputStats Interface


IWMEncOutputStats::get_ExpectedBitrate

The get_ExpectedBitrate method retrieves the encoding bit rate expected throughout the encoding session.

Syntax

HRESULT get_ExpectedBitrate(
  long*  plExpectedBitrate
);

Parameters

plExpectedBitrate

[out] Pointer to a long containing the expected bit rate.

Return Values

If the method succeeds, it returns S_OK.

Example Code

// Include libraries.

#include <windows.h>
#include <atlbase.h>    // Includes CComBSTR.
#include "wmencode.h"

// Declare variables.

    HRESULT hr;
    IWMEncoder* pEncoder;
    IWMEncStatistics* pStatistics;
    IWMEncOutputStats* pOutputStats;
    IDispatch* pDispOutputStats;

    long lAvgBitrate, lAvgSampleRate;
    long lCurrentBitRate, lCurrentSampleRate;
    long lExpectedBitRate, lExpectedSampleRate;
    WMENC_longlong qwByteCount, qwSampleCount;
    WMENC_longlong qwDroppedByteCount, qwDroppedSampleCount;

// Initialize the COM library and retrieve a pointer
// to an IWMEncoder interface.

    hr = CoInitialize(NULL);
    CoCreateInstance(CLSID_WMEncoder,
                     NULL,
                     CLSCTX_INPROC_SERVER,
                     IID_IWMEncoder,
                    (void**) &pEncoder);

// Retrieve an IWMEncStatistics interface pointer.

    hr = pEncoder->get_Statistics(&pStatistics);

// Retrieve an IDispatch pointer for the IWMEncOutputStats
// interface.

    hr = pStatistics->get_StreamOutputStats(WMENC_AUDIO,
                                            0,
                                            0,
                                            &pDispOutputStats);

// Call QueryInterface for the IWMEncNetConnectionStats
// interface pointer.

    hr = pDispOutputStats->QueryInterface(IID_IWMEncOutputStats,
                                          (void**)&pOutputStats);

// Manually configure the encoder engine or load
// a configuration from a file. For an example, see the
// IWMEncFile object.

// You can create a timer to retrieve the statistics
// after you start the encoder engine.

    hr = pOutputStats->get_AverageBitrate(&lAvgBitrate);
    hr = pOutputStats->get_AverageSampleRate(&lAvgSampleRate);
    hr = pOutputStats->get_ByteCount(&qwByteCount);
    hr = pOutputStats->get_CurrentBitrate(&lCurrentBitRate);
    hr = pOutputStats->get_CurrentSampleRate(&lCurrentSampleRate);
    hr = pOutputStats->get_DroppedByteCount(&qwDroppedByteCount);
    hr = pOutputStats->get_DroppedSampleCount(&qwDroppedSampleCount);
    hr = pOutputStats->get_ExpectedBitrate(&lExpectedBitRate);
    hr = pOutputStats->get_ExpectedSampleRate(&lExpectedSampleRate);
    hr = pOutputStats->get_SampleCount(&qwSampleCount);

See Also

  • IWMEncOutputStats Interface


IWMEncOutputStats::get_ExpectedSampleRate

The get_ExpectedSampleRate method retrieves the encoding sample rate expected throughout the encoding session.

Syntax

HRESULT get_ExpectedSampleRate(
  long*  plExpectedSampleRate
);

Parameters

plExpectedSampleRate

[out] Pointer to a long containing the expected sample rate.

Return Values

If the method succeeds, it returns S_OK.

Example Code

// Include libraries.

#include <windows.h>
#include <atlbase.h>    // Includes CComBSTR.
#include "wmencode.h"

// Declare variables.

    HRESULT hr;
    IWMEncoder* pEncoder;
    IWMEncStatistics* pStatistics;
    IWMEncOutputStats* pOutputStats;
    IDispatch* pDispOutputStats;

    long lAvgBitrate, lAvgSampleRate;
    long lCurrentBitRate, lCurrentSampleRate;
    long lExpectedBitRate, lExpectedSampleRate;
    WMENC_longlong qwByteCount, qwSampleCount;
    WMENC_longlong qwDroppedByteCount, qwDroppedSampleCount;

// Initialize the COM library and retrieve a pointer
// to an IWMEncoder interface.

    hr = CoInitialize(NULL);
    CoCreateInstance(CLSID_WMEncoder,
                     NULL,
                     CLSCTX_INPROC_SERVER,
                     IID_IWMEncoder,
                    (void**) &pEncoder);

// Retrieve an IWMEncStatistics interface pointer.

    hr = pEncoder->get_Statistics(&pStatistics);

// Retrieve an IDispatch pointer for the IWMEncOutputStats
// interface.

    hr = pStatistics->get_StreamOutputStats(WMENC_AUDIO,
                                            0,
                                            0,
                                            &pDispOutputStats);

// Call QueryInterface for the IWMEncNetConnectionStats
// interface pointer.

    hr = pDispOutputStats->QueryInterface(IID_IWMEncOutputStats,
                                          (void**)&pOutputStats);

// Manually configure the encoder engine or load
// a configuration from a file. For an example, see the
// IWMEncFile object.

// You can create a timer to retrieve the statistics
// after you start the encoder engine.

    hr = pOutputStats->get_AverageBitrate(&lAvgBitrate);
    hr = pOutputStats->get_AverageSampleRate(&lAvgSampleRate);
    hr = pOutputStats->get_ByteCount(&qwByteCount);
    hr = pOutputStats->get_CurrentBitrate(&lCurrentBitRate);
    hr = pOutputStats->get_CurrentSampleRate(&lCurrentSampleRate);
    hr = pOutputStats->get_DroppedByteCount(&qwDroppedByteCount);
    hr = pOutputStats->get_DroppedSampleCount(&qwDroppedSampleCount);
    hr = pOutputStats->get_ExpectedBitrate(&lExpectedBitRate);
    hr = pOutputStats->get_ExpectedSampleRate(&lExpectedSampleRate);
    hr = pOutputStats->get_SampleCount(&qwSampleCount);

See Also

  • IWMEncOutputStats Interface


IWMEncOutputStats::get_SampleCount

The get_SampleCount method retrieves the number of samples encoded since the encoder engine was started.

Syntax

HRESULT get_SampleCount(
  WMENC_longlong*  pqwSampleCount
);

Parameters

pqwSampleCount

[out] Pointer to a QWORD containing the number of encoded samples.

Return Values

If the method succeeds, it returns S_OK.

Remarks

The WMENC_longlong data type is a typedef from the CURRENCY type. A 64-bit integer is needed to hold the byte count, and CURRENCY is the only 64-bit integer type that Automation supports. To manipulate the value, you can use the following:

    qwSampleCount.int64

The output statistics do not persist after the encoding process has stopped.

Example Code

// Include libraries.

#include <windows.h>
#include <atlbase.h>    // Includes CComBSTR.
#include "wmencode.h"

// Declare variables.

    HRESULT hr;
    IWMEncoder* pEncoder;
    IWMEncStatistics* pStatistics;
    IWMEncOutputStats* pOutputStats;
    IDispatch* pDispOutputStats;

    long lAvgBitrate, lAvgSampleRate;
    long lCurrentBitRate, lCurrentSampleRate;
    long lExpectedBitRate, lExpectedSampleRate;
    WMENC_longlong qwByteCount, qwSampleCount;
    WMENC_longlong qwDroppedByteCount, qwDroppedSampleCount;

// Initialize the COM library and retrieve a pointer
// to an IWMEncoder interface.

    hr = CoInitialize(NULL);
    CoCreateInstance(CLSID_WMEncoder,
                     NULL,
                     CLSCTX_INPROC_SERVER,
                     IID_IWMEncoder,
                    (void**) &pEncoder);

// Retrieve an IWMEncStatistics interface pointer.

    hr = pEncoder->get_Statistics(&pStatistics);

// Retrieve an IDispatch pointer for the IWMEncOutputStats
// interface.

    hr = pStatistics->get_StreamOutputStats(WMENC_AUDIO,
                                            0,
                                            0,
                                            &pDispOutputStats);

// Call QueryInterface for the IWMEncNetConnectionStats
// interface pointer.

    hr = pDispOutputStats->QueryInterface(IID_IWMEncOutputStats,
                                          (void**)&pOutputStats);

// Manually configure the encoder engine or load
// a configuration from a file. For an example, see the
// IWMEncFile object.

// You can create a timer to retrieve the statistics
// after you start the encoder engine.

    hr = pOutputStats->get_AverageBitrate(&lAvgBitrate);
    hr = pOutputStats->get_AverageSampleRate(&lAvgSampleRate);
    hr = pOutputStats->get_ByteCount(&qwByteCount);
    hr = pOutputStats->get_CurrentBitrate(&lCurrentBitRate);
    hr = pOutputStats->get_CurrentSampleRate(&lCurrentSampleRate);
    hr = pOutputStats->get_DroppedByteCount(&qwDroppedByteCount);
    hr = pOutputStats->get_DroppedSampleCount(&qwDroppedSampleCount);
    hr = pOutputStats->get_ExpectedBitrate(&lExpectedBitRate);
    hr = pOutputStats->get_ExpectedSampleRate(&lExpectedSampleRate);
    hr = pOutputStats->get_SampleCount(&qwSampleCount);

See Also

  • IWMEncOutputStats Interface


IWMEncPluginInfo Interface

The IWMEncPluginInfo interface retrieves plug-in registry information. In addition to the methods inherited from IDispatch, the IWMEncPluginInfo interface exposes the following methods.

Method | Description
get_CLSID | Retrieves the globally unique identifier (GUID) of the plug-in.
get_Copyright | Retrieves the copyright information assigned to the plug-in by the author.
get_Count | Retrieves the number of registered plug-ins.
get_Exclusive | Retrieves a Boolean value indicating whether the plug-in can be used more than once in an encoding session.
get_Hidden | Retrieves a Boolean value indicating whether the plug-in is hidden from the UI.
get_InfoURL | Retrieves an optional URL that directs the user to a Web site presenting information about the plug-in.
get_MediaType | Retrieves the media types supported by the plug-in.
get_Name | Retrieves the name of the plug-in.
get_PluginType | Retrieves the plug-in type.
get_PropertyPage | Retrieves a Boolean value indicating whether the plug-in supports property pages.
get_Resources | Retrieves a Boolean value indicating whether the plug-in supports resources.
get_SchemeType | Retrieves the scheme type of the plug-in.
get_TransformFlags | Retrieves flags indicating whether a transform plug-in is applied to a single stream or to a source group of streams or both.
Item | Retrieves the resource corresponding to an index entry in the resource array.

See Also

  • [Visual Basic] IWMEncPluginInfo Object
  • Interfaces (C++)


IWMEncPluginInfo::get_CLSID

The get_CLSID method retrieves the GUID of the plug-in.

Syntax

HRESULT get_CLSID(
  BSTR*  pbstrCLSID
);

Parameters

pbstrCLSID

[out] Pointer to a BSTR containing the GUID of the plug-in.

Return Values

If the method succeeds, it returns S_OK. If it fails, it supports the IErrorInfo interface and returns an HRESULT error code.

Return code | Number | Meaning
E_POINTER | 0x80004003 | The pointer to the class ID is NULL.

Remarks

Plug-ins for Windows Media Encoder must be COM objects. The GUID, or CLSID, is the 128-bit object identifier. The CLSID is used by Windows Media Encoder to create an instance of the plug-in object.

Example Code

// Include libraries.

#include <windows.h>
#include <atlbase.h>
#include "wmencode.h"

// Declare variables.

    HRESULT hr;
    IWMEncoder* pEncoder;
    IWMEncSourcePluginInfoManager* pSrcPlugMgr;
    IWMEncPluginInfo* pPlugInfo;

    int i,j;
    long lPlugCount, lResCount;
    VARIANT_BOOL bResources, bExclusive, bHidden, bPropPage;
    WMENC_SOURCE_TYPE enumMediaType;
    WMENC_PLUGIN_TYPE enumPluginType;

// Initialize the COM library and retrieve a pointer
// to an IWMEncoder interface.

    hr = CoInitialize(NULL);
    CoCreateInstance(CLSID_WMEncoder,
                     NULL,
                     CLSCTX_INPROC_SERVER,
                     IID_IWMEncoder,
                     (void**) &pEncoder);

// Retrieve an IWMEncSourcePluginInfoManager pointer.

    hr = pEncoder->get_SourcePluginInfoManager(&pSrcPlugMgr);

// Loop through the source plug-ins. Call the Item method on each
// plug-in to retrieve an IWMEncPluginInfo object. Use the
// SchemeType property to retrieve a string containing the scheme
// type of the plug-in. If the scheme type is "DEVICE" and if the
// plug-in supports resources, call the Item method to retrieve a
// string identifying the resource. If the resource indicates that
// the plug-in captures streams from the default video device,
// retrieve registry information about the plug-in.

    hr = pSrcPlugMgr->get_Count(&lPlugCount);
    for (i=0; i<lPlugCount; i++)
    {
        hr = pSrcPlugMgr->Item(i, &pPlugInfo);
        CComBSTR bstrScheme;
        hr = pPlugInfo->get_SchemeType(&bstrScheme);
        if (_wcsicmp(bstrScheme, L"DEVICE")==0)
        {
            hr = pPlugInfo->get_Resources(&bResources);
            if (bResources==VARIANT_TRUE)
            {
                hr = pPlugInfo->get_Count(&lResCount);
                for (j=0; j<lResCount; j++)
                {
                    CComBSTR bstrResource;
                    hr = pPlugInfo->Item(j, &bstrResource);
                    if (_wcsicmp(bstrResource,
                                 L"Default_Video_Device")==0)
                    {
                     // Retrieve the GUID.
                     CComBSTR bstrCLSID;
                     hr = pPlugInfo->get_CLSID(&bstrCLSID);

                     // Retrieve the copyright information.
                     CComBSTR bstrCopyright;
                     hr = pPlugInfo->get_CLSID(&bstrCopyright);

                     // Determine whether the plug-in can be used
                     // more than once in a source group.
                     hr = pPlugInfo->get_Exclusive(&bExclusive);

                     // Determine whether the plug-in is hidden
                     // from the UI.
                     hr = pPlugInfo->get_Exclusive(&bHidden);

                     // Retrieve the URL, if any, of the Web site
                     // containing information about the plug-in.
                     CComBSTR bstrURL;
                     hr = pPlugInfo->get_InfoURL(&bstrURL);

                     // Retrieve the media types supported by the
                     // plug-in. This is a bitwise OR of the
                     // WMENC_SOURCE_TYPE enumeration type.
                     hr = pPlugInfo->get_MediaType(&enumMediaType);

                     // Retrieve the name of the plug-in.
                     CComBSTR bstrName;
                     hr = pPlugInfo->get_Name(&bstrName);

                     // Determine whether the plug-in is a source or
                     // transform type.
                     hr = pPlugInfo->get_PluginType(&enumPluginType);

                     // Determine whether the plug-in supports
                     // property pages.
                     hr = pPlugInfo->get_PropertyPage(&bPropPage);
                    }
                }
            }
        }
    }

// Continue configuring Windows Media Encoder.

See Also

  • IWMEncPluginInfo Interface


IWMEncPluginInfo::get_Copyright

The get_Copyright method retrieves the copyright information assigned to the plug-in by the author.

Syntax

HRESULT get_Copyright(
  BSTR*  pbstrCopyright
);

Parameters

pbstrCopyright

[out] Pointer to a BSTR containing the copyright information.

Return Values

If the method succeeds, it returns S_OK. If it fails, it supports the IErrorInfo interface and returns an HRESULT error code.

Return code | Number | Meaning
E_POINTER | 0x80004003 | The pointer to the copyright information is NULL.

Remarks

The pbstrCopyright parameter can contain information similar to Copyright 1999 Company_Name. All rights reserved. The copyright structure member is optional.

Example Code

// Include libraries.

#include <windows.h>
#include <atlbase.h>
#include "wmencode.h"

// Declare variables.

    HRESULT hr;
    IWMEncoder* pEncoder;
    IWMEncSourcePluginInfoManager* pSrcPlugMgr;
    IWMEncPluginInfo* pPlugInfo;

    int i,j;
    long lPlugCount, lResCount;
    VARIANT_BOOL bResources, bExclusive, bHidden, bPropPage;
    WMENC_SOURCE_TYPE enumMediaType;
    WMENC_PLUGIN_TYPE enumPluginType;

// Initialize the COM library and retrieve a pointer
// to an IWMEncoder interface.

    hr = CoInitialize(NULL);
    CoCreateInstance(CLSID_WMEncoder,
                     NULL,
                     CLSCTX_INPROC_SERVER,
                     IID_IWMEncoder,
                     (void**) &pEncoder);

// Retrieve an IWMEncSourcePluginInfoManager pointer.

    hr = pEncoder->get_SourcePluginInfoManager(&pSrcPlugMgr);

// Loop through the source plug-ins. Call the Item method on each
// plug-in to retrieve an IWMEncPluginInfo object. Use the
// SchemeType property to retrieve a string containing the scheme
// type of the plug-in. If the scheme type is "DEVICE" and if the
// plug-in supports resources, call the Item method to retrieve a
// string identifying the resource. If the resource indicates that
// the plug-in captures streams from the default video device,
// retrieve registry information about the plug-in.

    hr = pSrcPlugMgr->get_Count(&lPlugCount);
    for (i=0; i<lPlugCount; i++)
    {
        hr = pSrcPlugMgr->Item(i, &pPlugInfo);
        CComBSTR bstrScheme;
        hr = pPlugInfo->get_SchemeType(&bstrScheme);
        if (_wcsicmp(bstrScheme, L"DEVICE")==0)
        {
            hr = pPlugInfo->get_Resources(&bResources);
            if (bResources==VARIANT_TRUE)
            {
                hr = pPlugInfo->get_Count(&lResCount);
                for (j=0; j<lResCount; j++)
                {
                    CComBSTR bstrResource;
                    hr = pPlugInfo->Item(j, &bstrResource);
                    if (_wcsicmp(bstrResource,
                                 L"Default_Video_Device")==0)
                    {
                     // Retrieve the GUID.
                     CComBSTR bstrCLSID;
                     hr = pPlugInfo->get_CLSID(&bstrCLSID);

                     // Retrieve the copyright information.
                     CComBSTR bstrCopyright;
                     hr = pPlugInfo->get_CLSID(&bstrCopyright);

                     // Determine whether the plug-in can be used
                     // more than once in a source group.
                     hr = pPlugInfo->get_Exclusive(&bExclusive);

                     // Determine whether the plug-in is hidden
                     // from the UI.
                     hr = pPlugInfo->get_Exclusive(&bHidden);

                     // Retrieve the URL, if any, of the Web site
                     // containing information about the plug-in.
                     CComBSTR bstrURL;
                     hr = pPlugInfo->get_InfoURL(&bstrURL);

                     // Retrieve the media types supported by the
                     // plug-in. This is a bitwise OR of the
                     // WMENC_SOURCE_TYPE enumeration type.
                     hr = pPlugInfo->get_MediaType(&enumMediaType);

                     // Retrieve the name of the plug-in.
                     CComBSTR bstrName;
                     hr = pPlugInfo->get_Name(&bstrName);

                     // Determine whether the plug-in is a source or
                     // transform type.
                     hr = pPlugInfo->get_PluginType(&enumPluginType);

                     // Determine whether the plug-in supports
                     // property pages.
                     hr = pPlugInfo->get_PropertyPage(&bPropPage);
                    }
                }
            }
        }
    }

See Also

  • IWMEncPluginInfo Interface


IWMEncPluginInfo::get_Count

The get_Count method retrieves the number of resources in the plug-in.

Syntax

HRESULT get_Count(
  long*  plCount
);

Parameters

plCount

[out] Pointer to a long containing the number of resources.

Return Values

If the method succeeds, it returns S_OK.

Remarks

If your system has two or more audio capture cards, each card is identified by a resource.

Example Code

// Include libraries.

#include <windows.h>
#include <atlbase.h>
#include "wmencode.h"

// Declare variables.

    HRESULT hr;
    IWMEncoder* pEncoder;
    IWMEncSourcePluginInfoManager* pSrcPlugMgr;
    IWMEncPluginInfo* pPlugInfo;

    int i,j;
    long lPlugCount, lResCount;
    VARIANT_BOOL bResources, bExclusive, bHidden, bPropPage;
    WMENC_SOURCE_TYPE enumMediaType;
    WMENC_PLUGIN_TYPE enumPluginType;

// Initialize the COM library and retrieve a pointer
// to an IWMEncoder interface.

    hr = CoInitialize(NULL);
    CoCreateInstance(CLSID_WMEncoder,
                     NULL,
                     CLSCTX_INPROC_SERVER,
                     IID_IWMEncoder,
                     (void**) &pEncoder);

// Retrieve an IWMEncSourcePluginInfoManager pointer.

    hr = pEncoder->get_SourcePluginInfoManager(&pSrcPlugMgr);

// Loop through the source plug-ins. Call the Item method on each
// plug-in to retrieve an IWMEncPluginInfo object. Use the
// SchemeType property to retrieve a string containing the scheme
// type of the plug-in. If the scheme type is "DEVICE" and if the
// plug-in supports resources, call the Item method to retrieve a
// string identifying the resource. If the resource indicates that
// the plug-in captures streams from the default video device,
// retrieve registry information about the plug-in.

    hr = pSrcPlugMgr->get_Count(&lPlugCount);
    for (i=0; i<lPlugCount; i++)
    {
        hr = pSrcPlugMgr->Item(i, &pPlugInfo);
        CComBSTR bstrScheme;
        hr = pPlugInfo->get_SchemeType(&bstrScheme);
        if (_wcsicmp(bstrScheme, L"DEVICE")==0)
        {
            hr = pPlugInfo->get_Resources(&bResources);
            if (bResources==VARIANT_TRUE)
            {
                hr = pPlugInfo->get_Count(&lResCount);
                for (j=0; j<lResCount; j++)
                {
                    CComBSTR bstrResource;
                    hr = pPlugInfo->Item(j, &bstrResource);
                    if (_wcsicmp(bstrResource,
                                 L"Default_Video_Device")==0)
                    {
                     // Retrieve the GUID.
                     CComBSTR bstrCLSID;
                     hr = pPlugInfo->get_CLSID(&bstrCLSID);

                     // Retrieve the copyright information.
                     CComBSTR bstrCopyright;
                     hr = pPlugInfo->get_CLSID(&bstrCopyright);

                     // Determine whether the plug-in can be used
                     // more than once in a source group.
                     hr = pPlugInfo->get_Exclusive(&bExclusive);

                     // Determine whether the plug-in is hidden
                     // from the UI.
                     hr = pPlugInfo->get_Exclusive(&bHidden);

                     // Retrieve the URL, if any, of the Web site
                     // containing information about the plug-in.
                     CComBSTR bstrURL;
                     hr = pPlugInfo->get_InfoURL(&bstrURL);

                     // Retrieve the media types supported by the
                     // plug-in. This is a bitwise OR of the
                     // WMENC_SOURCE_TYPE enumeration type.
                     hr = pPlugInfo->get_MediaType(&enumMediaType);

                     // Retrieve the name of the plug-in.
                     CComBSTR bstrName;
                     hr = pPlugInfo->get_Name(&bstrName);

                     // Determine whether the plug-in is a source or
                     // transform type.
                     hr = pPlugInfo->get_PluginType(&enumPluginType);

                     // Determine whether the plug-in supports
                     // property pages.
                     hr = pPlugInfo->get_PropertyPage(&bPropPage);
                    }
                }
            }
        }
    }

See Also

  • IWMEncPluginInfo Interface


IWMEncPluginInfo::get_Exclusive

The get_Exclusive method retrieves a Boolean value indicating whether the plug-in can be used more than once in an encoding session.

Syntax

HRESULT get_Exclusive(
  VARIANT_BOOL*  pbExclusive
);

Parameters

pbExclusive

[out] Pointer to a VARIANT_BOOL that indicates whether the plug-in can be used more than once in a source group. The default value is FALSE.

Return Values

If the method succeeds, it returns S_OK. If it fails, it supports the IErrorInfo interface and returns an HRESULT error code.

Return code | Number | Meaning
E_POINTER | 0x80004003 | The pointer to the Boolean value is NULL.

Remarks

For some physical devices it may be necessary for get_Exclusive to return TRUE. By default, it returns FALSE.

Example Code

// Include libraries.

#include <windows.h>
#include <atlbase.h>
#include "wmencode.h"

// Declare variables.

    HRESULT hr;
    IWMEncoder* pEncoder;
    IWMEncSourcePluginInfoManager* pSrcPlugMgr;
    IWMEncPluginInfo* pPlugInfo;

    int i,j;
    long lPlugCount, lResCount;
    VARIANT_BOOL bResources, bExclusive, bHidden, bPropPage;
    WMENC_SOURCE_TYPE enumMediaType;
    WMENC_PLUGIN_TYPE enumPluginType;

// Initialize the COM library and retrieve a pointer
// to an IWMEncoder interface.

    hr = CoInitialize(NULL);
    CoCreateInstance(CLSID_WMEncoder,
                     NULL,
                     CLSCTX_INPROC_SERVER,
                     IID_IWMEncoder,
                     (void**) &pEncoder);

// Retrieve an IWMEncSourcePluginInfoManager pointer.

    hr = pEncoder->get_SourcePluginInfoManager(&pSrcPlugMgr);

// Loop through the source plug-ins. Call the Item method on each
// plug-in to retrieve an IWMEncPluginInfo object. Use the
// SchemeType property to retrieve a string containing the scheme
// type of the plug-in. If the scheme type is "DEVICE" and if the
// plug-in supports resources, call the Item method to retrieve a
// string identifying the resource. If the resource indicates that
// the plug-in captures streams from the default video device,
// retrieve registry information about the plug-in.

    hr = pSrcPlugMgr->get_Count(&lPlugCount);
    for (i=0; i<lPlugCount; i++)
    {
        hr = pSrcPlugMgr->Item(i, &pPlugInfo);
        CComBSTR bstrScheme;
        hr = pPlugInfo->get_SchemeType(&bstrScheme);
        if (_wcsicmp(bstrScheme, L"DEVICE")==0)
        {
            hr = pPlugInfo->get_Resources(&bResources);
            if (bResources==VARIANT_TRUE)
            {
                hr = pPlugInfo->get_Count(&lResCount);
                for (j=0; j<lResCount; j++)
                {
                    CComBSTR bstrResource;
                    hr = pPlugInfo->Item(j, &bstrResource);
                    if (_wcsicmp(bstrResource,
                                 L"Default_Video_Device")==0)
                    {
                     // Retrieve the GUID.
                     CComBSTR bstrCLSID;
                     hr = pPlugInfo->get_CLSID(&bstrCLSID);

                     // Retrieve the copyright information.
                     CComBSTR bstrCopyright;
                     hr = pPlugInfo->get_CLSID(&bstrCopyright);

                     // Determine whether the plug-in can be used
                     // more than once in a source group.
                     hr = pPlugInfo->get_Exclusive(&bExclusive);

                     // Determine whether the plug-in is hidden
                     // from the UI.
                     hr = pPlugInfo->get_Exclusive(&bHidden);

                     // Retrieve the URL, if any, of the Web site
                     // containing information about the plug-in.
                     CComBSTR bstrURL;
                     hr = pPlugInfo->get_InfoURL(&bstrURL);

                     // Retrieve the media types supported by the
                     // plug-in. This is a bitwise OR of the
                     // WMENC_SOURCE_TYPE enumeration type.
                     hr = pPlugInfo->get_MediaType(&enumMediaType);

                     // Retrieve the name of the plug-in.
                     CComBSTR bstrName;
                     hr = pPlugInfo->get_Name(&bstrName);

                     // Determine whether the plug-in is a source or
                     // transform type.
                     hr = pPlugInfo->get_PluginType(&enumPluginType);

                     // Determine whether the plug-in supports
                     // property pages.
                     hr = pPlugInfo->get_PropertyPage(&bPropPage);
                    }
                }
            }
        }
    }

See Also

  • IWMEncPluginInfo Interface


IWMEncPluginInfo::get_Hidden

The get_Hidden method retrieves a Boolean value indicating whether the plug-in is hidden from the UI.

Syntax

HRESULT get_Hidden(
  VARIANT_BOOL*  pbHidden
);

Parameters

pbHidden

[out] Pointer to a VARIANT_BOOL indicating whether the plug-in is visible in the UI.

Return Values

If the method succeeds, it returns S_OK. If it fails, it supports the IErrorInfo interface and returns an HRESULT error code.

Return code | Number | Meaning
E_POINTER | 0x80004003 | The pointer to the Boolean value is NULL.

Remarks

Use this method to hide the plug-in from the user interface if, for instance, you only intend to use the plug-in programmatically. By default, get_Hidden returns FALSE

Example Code

// Include libraries.

#include <windows.h>
#include <atlbase.h>
#include "wmencode.h"

// Declare variables.

    HRESULT hr;
    IWMEncoder* pEncoder;
    IWMEncSourcePluginInfoManager* pSrcPlugMgr;
    IWMEncPluginInfo* pPlugInfo;

    int i,j;
    long lPlugCount, lResCount;
    VARIANT_BOOL bResources, bExclusive, bHidden, bPropPage;
    WMENC_SOURCE_TYPE enumMediaType;
    WMENC_PLUGIN_TYPE enumPluginType;

// Initialize the COM library and retrieve a pointer
// to an IWMEncoder interface.

    hr = CoInitialize(NULL);
    CoCreateInstance(CLSID_WMEncoder,
                     NULL,
                     CLSCTX_INPROC_SERVER,
                     IID_IWMEncoder,
                     (void**) &pEncoder);

// Retrieve an IWMEncSourcePluginInfoManager pointer.

    hr = pEncoder->get_SourcePluginInfoManager(&pSrcPlugMgr);

// Loop through the source plug-ins. Call the Item method on each
// plug-in to retrieve an IWMEncPluginInfo object. Use the
// SchemeType property to retrieve a string containing the scheme
// type of the plug-in. If the scheme type is "DEVICE" and if the
// plug-in supports resources, call the Item method to retrieve a
// string identifying the resource. If the resource indicates that
// the plug-in captures streams from the default video device,
// retrieve registry information about the plug-in.

    hr = pSrcPlugMgr->get_Count(&lPlugCount);
    for (i=0; i<lPlugCount; i++)
    {
        hr = pSrcPlugMgr->Item(i, &pPlugInfo);
        CComBSTR bstrScheme;
        hr = pPlugInfo->get_SchemeType(&bstrScheme);
        if (_wcsicmp(bstrScheme, L"DEVICE")==0)
        {
            hr = pPlugInfo->get_Resources(&bResources);
            if (bResources==VARIANT_TRUE)
            {
                hr = pPlugInfo->get_Count(&lResCount);
                for (j=0; j<lResCount; j++)
                {
                    CComBSTR bstrResource;
                    hr = pPlugInfo->Item(j, &bstrResource);
                    if (_wcsicmp(bstrResource,
                                 L"Default_Video_Device")==0)
                    {
                     // Retrieve the GUID.
                     CComBSTR bstrCLSID;
                     hr = pPlugInfo->get_CLSID(&bstrCLSID);

                     // Retrieve the copyright information.
                     CComBSTR bstrCopyright;
                     hr = pPlugInfo->get_CLSID(&bstrCopyright);

                     // Determine whether the plug-in can be used
                     // more than once in a source group.
                     hr = pPlugInfo->get_Exclusive(&bExclusive);

                     // Determine whether the plug-in is hidden
                     // from the UI.
                     hr = pPlugInfo->get_Exclusive(&bHidden);

                     // Retrieve the URL, if any, of the Web site
                     // containing information about the plug-in.
                     CComBSTR bstrURL;
                     hr = pPlugInfo->get_InfoURL(&bstrURL);

                     // Retrieve the media types supported by the
                     // plug-in. This is a bitwise OR of the
                     // WMENC_SOURCE_TYPE enumeration type.
                     hr = pPlugInfo->get_MediaType(&enumMediaType);

                     // Retrieve the name of the plug-in.
                     CComBSTR bstrName;
                     hr = pPlugInfo->get_Name(&bstrName);

                     // Determine whether the plug-in is a source or
                     // transform type.
                     hr = pPlugInfo->get_PluginType(&enumPluginType);

                     // Determine whether the plug-in supports
                     // property pages.
                     hr = pPlugInfo->get_PropertyPage(&bPropPage);
                    }
                }
            }
        }
    }

See Also

  • IWMEncPluginInfo Interface


IWMEncPluginInfo::get_InfoURL

The get_InfoURL method retrieves an optional URL that directs the user to a Web site presenting information about the plug-in.

Syntax

HRESULT get_InfoURL(
  BSTR*  pbstrInfoURL
);

Parameters

pbstrInfoURL

[out] Pointer to a BSTR containing the URL.

Return Values

If the method succeeds, it returns S_OK. If it fails, it supports the IErrorInfo interface and returns an HRESULT error code.

Return code | Number | Meaning
E_POINTER | 0x80004003 | The pointer to the URL is NULL.

Example Code

// Include libraries.

#include <windows.h>
#include <atlbase.h>
#include "wmencode.h"

// Declare variables.

    HRESULT hr;
    IWMEncoder* pEncoder;
    IWMEncSourcePluginInfoManager* pSrcPlugMgr;
    IWMEncPluginInfo* pPlugInfo;

    int i,j;
    long lPlugCount, lResCount;
    VARIANT_BOOL bResources, bExclusive, bHidden, bPropPage;
    WMENC_SOURCE_TYPE enumMediaType;
    WMENC_PLUGIN_TYPE enumPluginType;

// Initialize the COM library and retrieve a pointer
// to an IWMEncoder interface.

    hr = CoInitialize(NULL);
    CoCreateInstance(CLSID_WMEncoder,
                     NULL,
                     CLSCTX_INPROC_SERVER,
                     IID_IWMEncoder,
                     (void**) &pEncoder);

// Retrieve an IWMEncSourcePluginInfoManager pointer.

    hr = pEncoder->get_SourcePluginInfoManager(&pSrcPlugMgr);

// Loop through the source plug-ins. Call the Item method on each
// plug-in to retrieve an IWMEncPluginInfo object. Use the
// SchemeType property to retrieve a string containing the scheme
// type of the plug-in. If the scheme type is "DEVICE" and if the
// plug-in supports resources, call the Item method to retrieve a
// string identifying the resource. If the resource indicates that
// the plug-in captures streams from the default video device,
// retrieve registry information about the plug-in.

    hr = pSrcPlugMgr->get_Count(&lPlugCount);
    for (i=0; i<lPlugCount; i++)
    {
        hr = pSrcPlugMgr->Item(i, &pPlugInfo);
        CComBSTR bstrScheme;
        hr = pPlugInfo->get_SchemeType(&bstrScheme);
        if (_wcsicmp(bstrScheme, L"DEVICE")==0)
        {
            hr = pPlugInfo->get_Resources(&bResources);
            if (bResources==VARIANT_TRUE)
            {
                hr = pPlugInfo->get_Count(&lResCount);
                for (j=0; j<lResCount; j++)
                {
                    CComBSTR bstrResource;
                    hr = pPlugInfo->Item(j, &bstrResource);
                    if (_wcsicmp(bstrResource,
                                 L"Default_Video_Device")==0)
                    {
                     // Retrieve the GUID.
                     CComBSTR bstrCLSID;
                     hr = pPlugInfo->get_CLSID(&bstrCLSID);

                     // Retrieve the copyright information.
                     CComBSTR bstrCopyright;
                     hr = pPlugInfo->get_CLSID(&bstrCopyright);

                     // Determine whether the plug-in can be used
                     // more than once in a source group.
                     hr = pPlugInfo->get_Exclusive(&bExclusive);

                     // Determine whether the plug-in is hidden
                     // from the UI.
                     hr = pPlugInfo->get_Exclusive(&bHidden);

                     // Retrieve the URL, if any, of the Web site
                     // containing information about the plug-in.
                     CComBSTR bstrURL;
                     hr = pPlugInfo->get_InfoURL(&bstrURL);

                     // Retrieve the media types supported by the
                     // plug-in. This is a bitwise OR of the
                     // WMENC_SOURCE_TYPE enumeration type.
                     hr = pPlugInfo->get_MediaType(&enumMediaType);

                     // Retrieve the name of the plug-in.
                     CComBSTR bstrName;
                     hr = pPlugInfo->get_Name(&bstrName);

                     // Determine whether the plug-in is a source or
                     // transform type.
                     hr = pPlugInfo->get_PluginType(&enumPluginType);

                     // Determine whether the plug-in supports
                     // property pages.
                     hr = pPlugInfo->get_PropertyPage(&bPropPage);
                    }
                }
            }
        }
    }

See Also

  • IWMEncPluginInfo Interface


IWMEncPluginInfo::get_MediaType

The get_MediaType method retrieves the media types supported by the plug-in.

Syntax

HRESULT get_MediaType(
  WMENC_SOURCE_TYPE*  penumMediaType
);

Parameters

penumMediaType

[out] Member of a WMENC_SOURCE_TYPE enumeration type identifying the supported media. This must be a bitwise OR of the following values.

Value | Number | Meaning
WMENC_AUDIO | 1 | The plug_in supports audio streams.
WMENC_VIDEO | 2 | The plug_in supports video streams.
WMENC_SCRIPT | 4 | The plug_in supports text streams.

Return Values

If the method succeeds, it returns S_OK. If it fails, it supports the IErrorInfo interface and returns an HRESULT error code.

Return code | Number | Meaning
E_POINTER | 0x80004003 | The pointer to the media type is NULL.

Example Code

// Include libraries.

#include <windows.h>
#include <atlbase.h>
#include "wmencode.h"

// Declare variables.

    HRESULT hr;
    IWMEncoder* pEncoder;
    IWMEncSourcePluginInfoManager* pSrcPlugMgr;
    IWMEncPluginInfo* pPlugInfo;

    int i,j;
    long lPlugCount, lResCount;
    VARIANT_BOOL bResources, bExclusive, bHidden, bPropPage;
    WMENC_SOURCE_TYPE enumMediaType;
    WMENC_PLUGIN_TYPE enumPluginType;

// Initialize the COM library and retrieve a pointer
// to an IWMEncoder interface.

    hr = CoInitialize(NULL);
    CoCreateInstance(CLSID_WMEncoder,
                     NULL,
                     CLSCTX_INPROC_SERVER,
                     IID_IWMEncoder,
                     (void**) &pEncoder);

// Retrieve an IWMEncSourcePluginInfoManager pointer.

    hr = pEncoder->get_SourcePluginInfoManager(&pSrcPlugMgr);

// Loop through the source plug-ins. Call the Item method on each
// plug-in to retrieve an IWMEncPluginInfo object. Use the
// SchemeType property to retrieve a string containing the scheme
// type of the plug-in. If the scheme type is "DEVICE" and if the
// plug-in supports resources, call the Item method to retrieve a
// string identifying the resource. If the resource indicates that
// the plug-in captures streams from the default video device,
// retrieve registry information about the plug-in.

    hr = pSrcPlugMgr->get_Count(&lPlugCount);
    for (i=0; i<lPlugCount; i++)
    {
        hr = pSrcPlugMgr->Item(i, &pPlugInfo);
        CComBSTR bstrScheme;
        hr = pPlugInfo->get_SchemeType(&bstrScheme);
        if (_wcsicmp(bstrScheme, L"DEVICE")==0)
        {
            hr = pPlugInfo->get_Resources(&bResources);
            if (bResources==VARIANT_TRUE)
            {
                hr = pPlugInfo->get_Count(&lResCount);
                for (j=0; j<lResCount; j++)
                {
                    CComBSTR bstrResource;
                    hr = pPlugInfo->Item(j, &bstrResource);
                    if (_wcsicmp(bstrResource,
                                 L"Default_Video_Device")==0)
                    {
                     // Retrieve the GUID.
                     CComBSTR bstrCLSID;
                     hr = pPlugInfo->get_CLSID(&bstrCLSID);

                     // Retrieve the copyright information.
                     CComBSTR bstrCopyright;
                     hr = pPlugInfo->get_CLSID(&bstrCopyright);

                     // Determine whether the plug-in can be used
                     // more than once in a source group.
                     hr = pPlugInfo->get_Exclusive(&bExclusive);

                     // Determine whether the plug-in is hidden
                     // from the UI.
                     hr = pPlugInfo->get_Exclusive(&bHidden);

                     // Retrieve the URL, if any, of the Web site
                     // containing information about the plug-in.
                     CComBSTR bstrURL;
                     hr = pPlugInfo->get_InfoURL(&bstrURL);

                     // Retrieve the media types supported by the
                     // plug-in. This is a bitwise OR of the
                     // WMENC_SOURCE_TYPE enumeration type.
                     hr = pPlugInfo->get_MediaType(&enumMediaType);

                     // Retrieve the name of the plug-in.
                     CComBSTR bstrName;
                     hr = pPlugInfo->get_Name(&bstrName);

                     // Determine whether the plug-in is a source or
                     // transform type.
                     hr = pPlugInfo->get_PluginType(&enumPluginType);

                     // Determine whether the plug-in supports
                     // property pages.
                     hr = pPlugInfo->get_PropertyPage(&bPropPage);
                    }
                }
            }
        }
    }

See Also

  • IWMEncPluginInfo Interface


IWMEncPluginInfo::get_Name

The get_Name method retrieves the name of the plug-in.

Syntax

HRESULT get_Name(
  BSTR*  pbstrName
);

Parameters

pbstrName

[out] Pointer to a BSTR containing the name.

Return Values

If the method succeeds, it returns S_OK. If it fails, it supports the IErrorInfo interface and returns an HRESULT error code.

Return code | Number | Description
E_POINTER | 0x80004003 | The pointer to the name is NULL.

Remarks

This method returns the resources associated with the plug-in.

Example Code

// Include libraries.

#include <windows.h>
#include <atlbase.h>
#include "wmencode.h"

// Declare variables.

    HRESULT hr;
    IWMEncoder* pEncoder;
    IWMEncSourcePluginInfoManager* pSrcPlugMgr;
    IWMEncPluginInfo* pPlugInfo;

    int i,j;
    long lPlugCount, lResCount;
    VARIANT_BOOL bResources, bExclusive, bHidden, bPropPage;
    WMENC_SOURCE_TYPE enumMediaType;
    WMENC_PLUGIN_TYPE enumPluginType;

// Initialize the COM library and retrieve a pointer
// to an IWMEncoder interface.

    hr = CoInitialize(NULL);
    CoCreateInstance(CLSID_WMEncoder,
                     NULL,
                     CLSCTX_INPROC_SERVER,
                     IID_IWMEncoder,
                     (void**) &pEncoder);

// Retrieve an IWMEncSourcePluginInfoManager pointer.

    hr = pEncoder->get_SourcePluginInfoManager(&pSrcPlugMgr);

// Loop through the source plug-ins. Call the Item method on each
// plug-in to retrieve an IWMEncPluginInfo object. Use the
// SchemeType property to retrieve a string containing the scheme
// type of the plug-in. If the scheme type is "DEVICE" and if the
// plug-in supports resources, call the Item method to retrieve a
// string identifying the resource. If the resource indicates that
// the plug-in captures streams from the default video device,
// retrieve registry information about the plug-in.

    hr = pSrcPlugMgr->get_Count(&lPlugCount);
    for (i=0; i<lPlugCount; i++)
    {
        hr = pSrcPlugMgr->Item(i, &pPlugInfo);
        CComBSTR bstrScheme;
        hr = pPlugInfo->get_SchemeType(&bstrScheme);
        if (_wcsicmp(bstrScheme, L"DEVICE")==0)
        {
            hr = pPlugInfo->get_Resources(&bResources);
            if (bResources==VARIANT_TRUE)
            {
                hr = pPlugInfo->get_Count(&lResCount);
                for (j=0; j<lResCount; j++)
                {
                    CComBSTR bstrResource;
                    hr = pPlugInfo->Item(j, &bstrResource);
                    if (_wcsicmp(bstrResource,
                                 L"Default_Video_Device")==0)
                    {
                     // Retrieve the GUID.
                     CComBSTR bstrCLSID;
                     hr = pPlugInfo->get_CLSID(&bstrCLSID);

                     // Retrieve the copyright information.
                     CComBSTR bstrCopyright;
                     hr = pPlugInfo->get_CLSID(&bstrCopyright);

                     // Determine whether the plug-in can be used
                     // more than once in a source group.
                     hr = pPlugInfo->get_Exclusive(&bExclusive);

                     // Determine whether the plug-in is hidden
                     // from the UI.
                     hr = pPlugInfo->get_Exclusive(&bHidden);

                     // Retrieve the URL, if any, of the Web site
                     // containing information about the plug-in.
                     CComBSTR bstrURL;
                     hr = pPlugInfo->get_InfoURL(&bstrURL);

                     // Retrieve the media types supported by the
                     // plug-in. This is a bitwise OR of the
                     // WMENC_SOURCE_TYPE enumeration type.
                     hr = pPlugInfo->get_MediaType(&enumMediaType);

                     // Retrieve the name of the plug-in.
                     CComBSTR bstrName;
                     hr = pPlugInfo->get_Name(&bstrName);

                     // Determine whether the plug-in is a source or
                     // transform type.
                     hr = pPlugInfo->get_PluginType(&enumPluginType);

                     // Determine whether the plug-in supports
                     // property pages.
                     hr = pPlugInfo->get_PropertyPage(&bPropPage);
                    }
                }
            }
        }
    }

See Also

  • IWMEncPluginInfo Interface


IWMEncPluginInfo::get_PluginType

The get_PluginType method retrieves the plug-in type.

Syntax

HRESULT get_PluginType(
  WMENC_PLUGIN_TYPE*  penumType
);

Parameters

penumType

[out] Pointer to a member of the WMENC_PLUGIN_TYPE enumeration type indicating the type of the plug-in. This must be one of the following values.

Value | Number | Meaning
WMENC_PLUGIN_SOURCE | 1 | The plug-in is a source type that captures multimedia content.
WMENC_PLUGIN_TRANSFORM | 2 | The plug-in is a transform type that modifies multimedia streams.

Return Values

If the method succeeds, it returns S_OK. If it fails, it supports the IErrorInfo interface and returns an HRESULT error code.

Return code | Number | Meaning
E_POINTER | 0x80004003 | The pointer to the plug-in type is NULL.

Example Code

// Include libraries.

#include <windows.h>
#include <atlbase.h>
#include "wmencode.h"

// Declare variables.

    HRESULT hr;
    IWMEncoder* pEncoder;
    IWMEncSourcePluginInfoManager* pSrcPlugMgr;
    IWMEncPluginInfo* pPlugInfo;

    int i,j;
    long lPlugCount, lResCount;
    VARIANT_BOOL bResources, bExclusive, bHidden, bPropPage;
    WMENC_SOURCE_TYPE enumMediaType;
    WMENC_PLUGIN_TYPE enumPluginType;

// Initialize the COM library and retrieve a pointer
// to an IWMEncoder interface.

    hr = CoInitialize(NULL);
    CoCreateInstance(CLSID_WMEncoder,
                     NULL,
                     CLSCTX_INPROC_SERVER,
                     IID_IWMEncoder,
                     (void**) &pEncoder);

// Retrieve an IWMEncSourcePluginInfoManager pointer.

    hr = pEncoder->get_SourcePluginInfoManager(&pSrcPlugMgr);

// Loop through the source plug-ins. Call the Item method on each
// plug-in to retrieve an IWMEncPluginInfo object. Use the
// SchemeType property to retrieve a string containing the scheme
// type of the plug-in. If the scheme type is "DEVICE" and if the
// plug-in supports resources, call the Item method to retrieve a
// string identifying the resource. If the resource indicates that
// the plug-in captures streams from the default video device,
// retrieve registry information about the plug-in.

    hr = pSrcPlugMgr->get_Count(&lPlugCount);
    for (i=0; i<lPlugCount; i++)
    {
        hr = pSrcPlugMgr->Item(i, &pPlugInfo);
        CComBSTR bstrScheme;
        hr = pPlugInfo->get_SchemeType(&bstrScheme);
        if (_wcsicmp(bstrScheme, L"DEVICE")==0)
        {
            hr = pPlugInfo->get_Resources(&bResources);
            if (bResources==VARIANT_TRUE)
            {
                hr = pPlugInfo->get_Count(&lResCount);
                for (j=0; j<lResCount; j++)
                {
                    CComBSTR bstrResource;
                    hr = pPlugInfo->Item(j, &bstrResource);
                    if (_wcsicmp(bstrResource,
                                 L"Default_Video_Device")==0)
                    {
                     // Retrieve the GUID.
                     CComBSTR bstrCLSID;
                     hr = pPlugInfo->get_CLSID(&bstrCLSID);

                     // Retrieve the copyright information.
                     CComBSTR bstrCopyright;
                     hr = pPlugInfo->get_CLSID(&bstrCopyright);

                     // Determine whether the plug-in can be used
                     // more than once in a source group.
                     hr = pPlugInfo->get_Exclusive(&bExclusive);

                     // Determine whether the plug-in is hidden
                     // from the UI.
                     hr = pPlugInfo->get_Exclusive(&bHidden);

                     // Retrieve the URL, if any, of the Web site
                     // containing information about the plug-in.
                     CComBSTR bstrURL;
                     hr = pPlugInfo->get_InfoURL(&bstrURL);

                     // Retrieve the media types supported by the
                     // plug-in. This is a bitwise OR of the
                     // WMENC_SOURCE_TYPE enumeration type.
                     hr = pPlugInfo->get_MediaType(&enumMediaType);

                     // Retrieve the name of the plug-in.
                     CComBSTR bstrName;
                     hr = pPlugInfo->get_Name(&bstrName);

                     // Determine whether the plug-in is a source or
                     // transform type.
                     hr = pPlugInfo->get_PluginType(&enumPluginType);

                     // Determine whether the plug-in supports
                     // property pages.
                     hr = pPlugInfo->get_PropertyPage(&bPropPage);
                    }
                }
            }
        }
    }

See Also

  • IWMEncPluginInfo Interface


IWMEncPluginInfo::get_PropertyPage

The get_PropertyPage property retrieves a Boolean value indicating whether the plug-in supports property pages.

Syntax

HRESULT get_PropertyPage(
  VARIANT_BOOL*  pbProppage
);

Parameters

pbstrCLSID

[out] Pointer to a BSTR containing the CLSID of the viewpage.

Return Values

If the method succeeds, it returns S_OK. If it fails, it supports the IErrorInfo interface and returns an HRESULT error code.

Return code | Number | Meaning
E_POINTER | 0x80004003 | The pointer to the property page class ID is NULL.

Remarks

Both source and transform plug-ins can have associated property pages. The Windows Media Encoder user interface creates a dialog box to host the property page. Parameters modified on the property page are applied to the plug-in.

Example Code

// Include libraries.

#include <windows.h>
#include <atlbase.h>
#include "wmencode.h"

// Declare variables.

    HRESULT hr;
    IWMEncoder* pEncoder;
    IWMEncSourcePluginInfoManager* pSrcPlugMgr;
    IWMEncPluginInfo* pPlugInfo;

    int i,j;
    long lPlugCount, lResCount;
    VARIANT_BOOL bResources, bExclusive, bHidden, bPropPage;
    WMENC_SOURCE_TYPE enumMediaType;
    WMENC_PLUGIN_TYPE enumPluginType;

// Initialize the COM library and retrieve a pointer
// to an IWMEncoder interface.

    hr = CoInitialize(NULL);
    CoCreateInstance(CLSID_WMEncoder,
                     NULL,
                     CLSCTX_INPROC_SERVER,
                     IID_IWMEncoder,
                     (void**) &pEncoder);

// Retrieve an IWMEncSourcePluginInfoManager pointer.

    hr = pEncoder->get_SourcePluginInfoManager(&pSrcPlugMgr);

// Loop through the source plug-ins. Call the Item method on each
// plug-in to retrieve an IWMEncPluginInfo object. Use the
// SchemeType property to retrieve a string containing the scheme
// type of the plug-in. If the scheme type is "DEVICE" and if the
// plug-in supports resources, call the Item method to retrieve a
// string identifying the resource. If the resource indicates that
// the plug-in captures streams from the default video device,
// retrieve registry information about the plug-in.

    hr = pSrcPlugMgr->get_Count(&lPlugCount);
    for (i=0; i<lPlugCount; i++)
    {
        hr = pSrcPlugMgr->Item(i, &pPlugInfo);
        CComBSTR bstrScheme;
        hr = pPlugInfo->get_SchemeType(&bstrScheme);
        if (_wcsicmp(bstrScheme, L"DEVICE")==0)
        {
            hr = pPlugInfo->get_Resources(&bResources);
            if (bResources==VARIANT_TRUE)
            {
                hr = pPlugInfo->get_Count(&lResCount);
                for (j=0; j<lResCount; j++)
                {
                    CComBSTR bstrResource;
                    hr = pPlugInfo->Item(j, &bstrResource);
                    if (_wcsicmp(bstrResource,
                                 L"Default_Video_Device")==0)
                    {
                     // Retrieve the GUID.
                     CComBSTR bstrCLSID;
                     hr = pPlugInfo->get_CLSID(&bstrCLSID);

                     // Retrieve the copyright information.
                     CComBSTR bstrCopyright;
                     hr = pPlugInfo->get_CLSID(&bstrCopyright);

                     // Determine whether the plug-in can be used
                     // more than once in a source group.
                     hr = pPlugInfo->get_Exclusive(&bExclusive);

                     // Determine whether the plug-in is hidden
                     // from the UI.
                     hr = pPlugInfo->get_Exclusive(&bHidden);

                     // Retrieve the URL, if any, of the Web site
                     // containing information about the plug-in.
                     CComBSTR bstrURL;
                     hr = pPlugInfo->get_InfoURL(&bstrURL);

                     // Retrieve the media types supported by the
                     // plug-in. This is a bitwise OR of the
                     // WMENC_SOURCE_TYPE enumeration type.
                     hr = pPlugInfo->get_MediaType(&enumMediaType);

                     // Retrieve the name of the plug-in.
                     CComBSTR bstrName;
                     hr = pPlugInfo->get_Name(&bstrName);

                     // Determine whether the plug-in is a source or
                     // transform type.
                     hr = pPlugInfo->get_PluginType(&enumPluginType);

                     // Determine whether the plug-in supports
                     // property pages.
                     hr = pPlugInfo->get_PropertyPage(&bPropPage);
                    }
                }
            }
        }
    }

See Also

  • IWMEncPluginInfo Interface


IWMEncPluginInfo::get_Resources

The get_Resources method retrieves a Boolean value indicating whether the plug-in supports resources

Syntax

HRESULT get_Resources(
  VARIANT_BOOLbResources
);

Parameters

pbResources

[out] Pointer to a VARIANT_BOOL indicating whether the plug-in supports resources.

Return Values

If the method succeeds, it returns S_OK. If it fails, it supports the IErrorInfo interface and returns an HRESULT error code.

Return code | Number | Meaning
E_POINTER | 0x80004003 | The pointer to the Boolean value is NULL.

Remarks

Resources are the physical devices that provide a source of content. The array of resources used by the plug-in, if present, must be defined as part of the plug-in. The encoder appends each resource to the scheme type to create a string used by Windows Media Encoder toin identify the plug-in. In the following example, Device is the scheme type and Card1 and Card2 are resources.

  • Device://Card1
  • Device://Card2

Example Code

// Include libraries.

#include <windows.h>
#include <atlbase.h>
#include "wmencode.h"

// Declare variables.

    HRESULT hr;
    IWMEncoder* pEncoder;
    IWMEncSourcePluginInfoManager* pSrcPlugMgr;
    IWMEncPluginInfo* pPlugInfo;

    int i,j;
    long lPlugCount, lResCount;
    VARIANT_BOOL bResources, bExclusive, bHidden, bPropPage;
    WMENC_SOURCE_TYPE enumMediaType;
    WMENC_PLUGIN_TYPE enumPluginType;

// Initialize the COM library and retrieve a pointer
// to an IWMEncoder interface.

    hr = CoInitialize(NULL);
    CoCreateInstance(CLSID_WMEncoder,
                     NULL,
                     CLSCTX_INPROC_SERVER,
                     IID_IWMEncoder,
                     (void**) &pEncoder);

// Retrieve an IWMEncSourcePluginInfoManager pointer.

    hr = pEncoder->get_SourcePluginInfoManager(&pSrcPlugMgr);

// Loop through the source plug-ins. Call the Item method on each
// plug-in to retrieve an IWMEncPluginInfo object. Use the
// SchemeType property to retrieve a string containing the scheme
// type of the plug-in. If the scheme type is "DEVICE" and if the
// plug-in supports resources, call the Item method to retrieve a
// string identifying the resource. If the resource indicates that
// the plug-in captures streams from the default video device,
// retrieve registry information about the plug-in.

    hr = pSrcPlugMgr->get_Count(&lPlugCount);
    for (i=0; i<lPlugCount; i++)
    {
        hr = pSrcPlugMgr->Item(i, &pPlugInfo);
        CComBSTR bstrScheme;
        hr = pPlugInfo->get_SchemeType(&bstrScheme);
        if (_wcsicmp(bstrScheme, L"DEVICE")==0)
        {
            hr = pPlugInfo->get_Resources(&bResources);
            if (bResources==VARIANT_TRUE)
            {
                hr = pPlugInfo->get_Count(&lResCount);
                for (j=0; j<lResCount; j++)
                {
                    CComBSTR bstrResource;
                    hr = pPlugInfo->Item(j, &bstrResource);
                    if (_wcsicmp(bstrResource,
                                 L"Default_Video_Device")==0)
                    {
                     // Retrieve the GUID.
                     CComBSTR bstrCLSID;
                     hr = pPlugInfo->get_CLSID(&bstrCLSID);

                     // Retrieve the copyright information.
                     CComBSTR bstrCopyright;
                     hr = pPlugInfo->get_CLSID(&bstrCopyright);

                     // Determine whether the plug-in can be used
                     // more than once in a source group.
                     hr = pPlugInfo->get_Exclusive(&bExclusive);

                     // Determine whether the plug-in is hidden
                     // from the UI.
                     hr = pPlugInfo->get_Exclusive(&bHidden);

                     // Retrieve the URL, if any, of the Web site
                     // containing information about the plug-in.
                     CComBSTR bstrURL;
                     hr = pPlugInfo->get_InfoURL(&bstrURL);

                     // Retrieve the media types supported by the
                     // plug-in. This is a bitwise OR of the
                     // WMENC_SOURCE_TYPE enumeration type.
                     hr = pPlugInfo->get_MediaType(&enumMediaType);

                     // Retrieve the name of the plug-in.
                     CComBSTR bstrName;
                     hr = pPlugInfo->get_Name(&bstrName);

                     // Determine whether the plug-in is a source or
                     // transform type.
                     hr = pPlugInfo->get_PluginType(&enumPluginType);

                     // Determine whether the plug-in supports
                     // property pages.
                     hr = pPlugInfo->get_PropertyPage(&bPropPage);
                    }
                }
            }
        }
    }

See Also

  • IWMEncPluginInfo Interface


IWMEncPluginInfo::get_SchemeType

The get_SchemeType method retrieves the scheme type of the plug-in.

Syntax

HRESULT get_SchemeType(
  BSTR*  pbstrSchemeType
);

Parameters

pbstrSchemeType

[out] Pointer to a BSTR containing the scheme type.

Return Values

If the method succeeds, it returns S_OK. If it fails, it supports the IErrorInfo interface and returns an HRESULT error code.

Return code | Number | Meaning
E_POINTER | 0x80004003 | The pointer to the scheme type is NULL.

Remarks

The scheme type occupies the root position of the registration information structure and broadly categorizes the plug-in. For instance, in the string Device://Card1, Device is the scheme type. The following table lists the possible scheme types available in Windows Media Encoder.

Scheme type | Description
Device | Identifies a source plug-in that enables stream capture from a device attached to a computer.
File | Identifies a source plug-in that enables stream capture from a file.
UserScript | Identifies a source plug-in that enables transmission of a script to the encoder engine.
ScreenCap | Identifies a source plug-in that enables screen capture.
TCGroupTransformPlugin | Identifies a transform plug-in that enables time compression.

Example Code

// Include libraries.

#include <windows.h>
#include <atlbase.h>
#include "wmencode.h"

// Declare variables.

    HRESULT hr;
    IWMEncoder* pEncoder;
    IWMEncSourcePluginInfoManager* pSrcPlugMgr;
    IWMEncPluginInfo* pPlugInfo;

    int i,j;
    long lPlugCount, lResCount;
    VARIANT_BOOL bResources, bExclusive, bHidden, bPropPage;
    WMENC_SOURCE_TYPE enumMediaType;
    WMENC_PLUGIN_TYPE enumPluginType;

// Initialize the COM library and retrieve a pointer
// to an IWMEncoder interface.

    hr = CoInitialize(NULL);
    CoCreateInstance(CLSID_WMEncoder,
                     NULL,
                     CLSCTX_INPROC_SERVER,
                     IID_IWMEncoder,
                     (void**) &pEncoder);

// Retrieve an IWMEncSourcePluginInfoManager pointer.

    hr = pEncoder->get_SourcePluginInfoManager(&pSrcPlugMgr);

// Loop through the source plug-ins. Call the Item method on each
// plug-in to retrieve an IWMEncPluginInfo object. Use the
// SchemeType property to retrieve a string containing the scheme
// type of the plug-in. If the scheme type is "DEVICE" and if the
// plug-in supports resources, call the Item method to retrieve a
// string identifying the resource. If the resource indicates that
// the plug-in captures streams from the default video device,
// retrieve registry information about the plug-in.

    hr = pSrcPlugMgr->get_Count(&lPlugCount);
    for (i=0; i<lPlugCount; i++)
    {
        hr = pSrcPlugMgr->Item(i, &pPlugInfo);
        CComBSTR bstrScheme;
        hr = pPlugInfo->get_SchemeType(&bstrScheme);
        if (_wcsicmp(bstrScheme, L"DEVICE")==0)
        {
            hr = pPlugInfo->get_Resources(&bResources);
            if (bResources==VARIANT_TRUE)
            {
                hr = pPlugInfo->get_Count(&lResCount);
                for (j=0; j<lResCount; j++)
                {
                    CComBSTR bstrResource;
                    hr = pPlugInfo->Item(j, &bstrResource);
                    if (_wcsicmp(bstrResource,
                                 L"Default_Video_Device")==0)
                    {
                     // Retrieve the GUID.
                     CComBSTR bstrCLSID;
                     hr = pPlugInfo->get_CLSID(&bstrCLSID);

                     // Retrieve the copyright information.
                     CComBSTR bstrCopyright;
                     hr = pPlugInfo->get_CLSID(&bstrCopyright);

                     // Determine whether the plug-in can be used
                     // more than once in a source group.
                     hr = pPlugInfo->get_Exclusive(&bExclusive);

                     // Determine whether the plug-in is hidden
                     // from the UI.
                     hr = pPlugInfo->get_Exclusive(&bHidden);

                     // Retrieve the URL, if any, of the Web site
                     // containing information about the plug-in.
                     CComBSTR bstrURL;
                     hr = pPlugInfo->get_InfoURL(&bstrURL);

                     // Retrieve the media types supported by the
                     // plug-in. This is a bitwise OR of the
                     // WMENC_SOURCE_TYPE enumeration type.
                     hr = pPlugInfo->get_MediaType(&enumMediaType);

                     // Retrieve the name of the plug-in.
                     CComBSTR bstrName;
                     hr = pPlugInfo->get_Name(&bstrName);

                     // Determine whether the plug-in is a source or
                     // transform type.
                     hr = pPlugInfo->get_PluginType(&enumPluginType);

                     // Determine whether the plug-in supports
                     // property pages.
                     hr = pPlugInfo->get_PropertyPage(&bPropPage);
                    }
                }
            }
        }
    }

See Also

  • IWMEncPluginInfo Interface


IWMEncPluginInfo::get_TransformFlags

The get_TransformFlags method retrieves flags indicating whether a transform plug-in is applied to a single stream or to a source group of streams or both.

Syntax

HRESULT get_TransformFlags(
  short*  piFlags
);

Parameters

piFlags

[out] Pointer to a short containing the transform plug-in flags.

Return Values

If the method succeeds, it returns S_OK. If it fails, it supports the IErrorInfo interface and returns an HRESULT error code.

Return code | Number | Meaning
E_POINTER | 0x80004003 | The pointer to the flags is NULL.

Remarks

Stream-level plug-ins are applied only to a specific stream. Global transform plug-ins are applied to all streams in the active source group.

Example Code

// Include libraries.

#include <windows.h>
#include <atlbase.h>
#include "wmencode.h"

// Declare variables.

    HRESULT hr;
    IWMEncoder* pEncoder;
    IWMEncSourcePluginInfoManager* pSrcPlugMgr;
    IWMEncPluginInfo* pPlugInfo;

    int i,j;
    long lPlugCount, lResCount;
    VARIANT_BOOL bResources, bExclusive, bHidden, bPropPage;
    WMENC_SOURCE_TYPE enumMediaType;
    WMENC_PLUGIN_TYPE enumPluginType;

// Initialize the COM library and retrieve a pointer
// to an IWMEncoder interface.

    hr = CoInitialize(NULL);
    CoCreateInstance(CLSID_WMEncoder,
                     NULL,
                     CLSCTX_INPROC_SERVER,
                     IID_IWMEncoder,
                     (void**) &pEncoder);

// Retrieve an IWMEncSourcePluginInfoManager pointer.

    hr = pEncoder->get_SourcePluginInfoManager(&pSrcPlugMgr);

// Loop through the source plug-ins. Call the Item method on each
// plug-in to retrieve an IWMEncPluginInfo object. Use the
// SchemeType property to retrieve a string containing the scheme
// type of the plug-in. If the scheme type is "DEVICE" and if the
// plug-in supports resources, call the Item method to retrieve a
// string identifying the resource. If the resource indicates that
// the plug-in captures streams from the default video device,
// retrieve registry information about the plug-in.

    hr = pSrcPlugMgr->get_Count(&lPlugCount);
    for (i=0; i<lPlugCount; i++)
    {
        hr = pSrcPlugMgr->Item(i, &pPlugInfo);
        CComBSTR bstrScheme;
        hr = pPlugInfo->get_SchemeType(&bstrScheme);
        if (_wcsicmp(bstrScheme, L"DEVICE")==0)
        {
            hr = pPlugInfo->get_Resources(&bResources);
            if (bResources==VARIANT_TRUE)
            {
                hr = pPlugInfo->get_Count(&lResCount);
                for (j=0; j<lResCount; j++)
                {
                    CComBSTR bstrResource;
                    hr = pPlugInfo->Item(j, &bstrResource);
                    if (_wcsicmp(bstrResource,
                                 L"Default_Video_Device")==0)
                    {
                     // Retrieve the GUID.
                     CComBSTR bstrCLSID;
                     hr = pPlugInfo->get_CLSID(&bstrCLSID);

                     // Retrieve the copyright information.
                     CComBSTR bstrCopyright;
                     hr = pPlugInfo->get_CLSID(&bstrCopyright);

                     // Determine whether the plug-in can be used
                     // more than once in a source group.
                     hr = pPlugInfo->get_Exclusive(&bExclusive);

                     // Determine whether the plug-in is hidden
                     // from the UI.
                     hr = pPlugInfo->get_Exclusive(&bHidden);

                     // Retrieve the URL, if any, of the Web site
                     // containing information about the plug-in.
                     CComBSTR bstrURL;
                     hr = pPlugInfo->get_InfoURL(&bstrURL);

                     // Retrieve the media types supported by the
                     // plug-in. This is a bitwise OR of the
                     // WMENC_SOURCE_TYPE enumeration type.
                     hr = pPlugInfo->get_MediaType(&enumMediaType);

                     // Retrieve the name of the plug-in.
                     CComBSTR bstrName;
                     hr = pPlugInfo->get_Name(&bstrName);

                     // Determine whether the plug-in is a source or
                     // transform type.
                     hr = pPlugInfo->get_PluginType(&enumPluginType);

                     // Determine whether the plug-in supports
                     // property pages.
                     hr = pPlugInfo->get_PropertyPage(&bPropPage);
                    }
                }
            }
        }
    }

See Also

  • IWMEncPluginInfo Interface


IWMEncPluginInfo::Item

The Item method retrieves the resource corresponding to an index entry in the resource array.

Syntax

HRESULT Item(
  short  iIndex,
  BSTR*  pbstrResource
);

Parameters

iIndex

[in] short containing an index into the resource array.

pbstrResource

[out] Pointer to a BSTR containing the resource specified by iIndex.

Return Values

If the method succeeds, it returns S_OK.

Remarks

Resources are the physical devices that provide a source of content. The array of resources used by the plug-in, if present, must be defined as part of the plug-in. The encoder appends each resource to the scheme type to create a string used by Windows Media Encoder to identify the plug-in. In the following example, Device is the scheme type and Card1 and Card2 are resources.

  • Device://Card1
  • Device://Card2

Example Code

// Include libraries.

#include <windows.h>
#include <atlbase.h>
#include "wmencode.h"

// Declare variables.

    HRESULT hr;
    IWMEncoder* pEncoder;
    IWMEncSourcePluginInfoManager* pSrcPlugMgr;
    IWMEncPluginInfo* pPlugInfo;

    int i,j;
    long lPlugCount, lResCount;
    VARIANT_BOOL bResources, bExclusive, bHidden, bPropPage;
    WMENC_SOURCE_TYPE enumMediaType;
    WMENC_PLUGIN_TYPE enumPluginType;

// Initialize the COM library and retrieve a pointer
// to an IWMEncoder interface.

    hr = CoInitialize(NULL);
    CoCreateInstance(CLSID_WMEncoder,
                     NULL,
                     CLSCTX_INPROC_SERVER,
                     IID_IWMEncoder,
                     (void**) &pEncoder);

// Retrieve an IWMEncSourcePluginInfoManager pointer.

    hr = pEncoder->get_SourcePluginInfoManager(&pSrcPlugMgr);

// Loop through the source plug-ins. Call the Item method on each
// plug-in to retrieve an IWMEncPluginInfo object. Use the
// SchemeType property to retrieve a string containing the scheme
// type of the plug-in. If the scheme type is "DEVICE" and if the
// plug-in supports resources, call the Item method to retrieve a
// string identifying the resource. If the resource indicates that
// the plug-in captures streams from the default video device,
// retrieve registry information about the plug-in.

    hr = pSrcPlugMgr->get_Count(&lPlugCount);
    for (i=0; i<lPlugCount; i++)
    {
        hr = pSrcPlugMgr->Item(i, &pPlugInfo);
        CComBSTR bstrScheme;
        hr = pPlugInfo->get_SchemeType(&bstrScheme);
        if (_wcsicmp(bstrScheme, L"DEVICE")==0)
        {
            hr = pPlugInfo->get_Resources(&bResources);
            if (bResources==VARIANT_TRUE)
            {
                hr = pPlugInfo->get_Count(&lResCount);
                for (j=0; j<lResCount; j++)
                {
                    CComBSTR bstrResource;
                    hr = pPlugInfo->Item(j, &bstrResource);
                    if (_wcsicmp(bstrResource,
                                 L"Default_Video_Device")==0)
                    {
                     // Retrieve the GUID.
                     CComBSTR bstrCLSID;
                     hr = pPlugInfo->get_CLSID(&bstrCLSID);

                     // Retrieve the copyright information.
                     CComBSTR bstrCopyright;
                     hr = pPlugInfo->get_CLSID(&bstrCopyright);

                     // Determine whether the plug-in can be used
                     // more than once in a source group.
                     hr = pPlugInfo->get_Exclusive(&bExclusive);

                     // Determine whether the plug-in is hidden
                     // from the UI.
                     hr = pPlugInfo->get_Exclusive(&bHidden);

                     // Retrieve the URL, if any, of the Web site
                     // containing information about the plug-in.
                     CComBSTR bstrURL;
                     hr = pPlugInfo->get_InfoURL(&bstrURL);

                     // Retrieve the media types supported by the
                     // plug-in. This is a bitwise OR of the
                     // WMENC_SOURCE_TYPE enumeration type.
                     hr = pPlugInfo->get_MediaType(&enumMediaType);

                     // Retrieve the name of the plug-in.
                     CComBSTR bstrName;
                     hr = pPlugInfo->get_Name(&bstrName);

                     // Determine whether the plug-in is a source or
                     // transform type.
                     hr = pPlugInfo->get_PluginType(&enumPluginType);

                     // Determine whether the plug-in supports
                     // property pages.
                     hr = pPlugInfo->get_PropertyPage(&bPropPage);
                    }
                }
            }
        }
    }

See Also

  • IWMEncPluginInfo Interface


IWMEncPostViewCollection Interface

The IWMEncPostViewCollection interface manages a collection of encoded multiple-bit-rate video streams created from the video source stream. It can be used to specify which multiple-bit-rate output stream can be postviewed.

In addition to the methods inherited from IWMEncDataViewCollection, the IWMEncPostViewCollection interface exposes the following methods.

Method | Description
get_ViewBandwidth | Retrieves the bit rate of the preview video stream.
put_ViewBandwidth | Specifies the bit rate of the preview video stream.

See Also

  • [Visual Basic] IWMEncPostViewCollection Object
  • Interfaces (C++)


IWMEncPostViewCollection::get_ViewBandwidth

The get_ViewBandwidth method retrieves the bit rate of the preview video stream.

Syntax

HRESULT get_ViewBandwidth(
  long*  plBandwidth
);

Parameters

plBandwidth

[out] Pointer to a long containing the bit rate of the preview stream.

Return Values

If the method succeeds, it returns S_OK. If it fails, it returns an HRESULT error code.

Return code | Number | Meaning
E_POINTER | 0x80004003 | The pointer to the bit rate is NULL.

Remarks

If the encoder engine produces multiple-bit-rate streams from a single input stream, you can choose which stream to preview by using the IWMEncPostViewCollection::put_ViewBandwidth method. You can also switch between streams while the encoder engine is running. You must use the Profile Manager to determine which profiles support multiple-bit-rate streams.

Example Code

// Include libraries.

#include <windows.h>
#include <atlbase.h>
#include "wmencode.h"
#include "wmencvu.h"

// Declare variables.

    HRESULT hr;
    IWMEncoder* pEncoder;
    IWMEncDataView* pPostview;
    IWMEncDataViewCollection* pPostColl;
    IWMEncPostViewCollection* pPostViewColl;
    IWMEncSourceGroupCollection* pSrcGrpColl;
    IWMEncSourceGroup* pSrcGrp;
    IWMEncSource* pAudSrc;
    IWMEncSource* pVidSrc;
    IWMEncProfileCollection* pProColl;
    IWMEncProfile* pPro;

    long lCount;
    int i;

// Initialize the COM library and retrieve a pointer
// to an IWMEncoder interface.

    hr = CoInitialize(NULL);
    CoCreateInstance(CLSID_WMEncoder,
                     NULL,
                     CLSCTX_INPROC_SERVER,
                     IID_IWMEncoder,
                     (void**) &pEncoder);

// Retrieve a pointer to an IWMEncSourceGroupCollection
// interface.

    hr = pEncoder->get_SourceGroupCollection(&pSrcGrpColl);

// Add a source group to the collection.

    hr = pSrcGrpColl->Add(L"SG_1", &pSrcGrp);

// Add a video and audio source to the source group.

    hr = pSrcGrp->AddSource(WMENC_VIDEO, &pVidSrc);
    hr = pSrcGrp->AddSource(WMENC_AUDIO, &pAudSrc);

// Identify the capture cards.

    hr = pVidSrc->SetInput(L"DEVICE://Default_Video_Device");
    hr = pAudSrc->SetInput(L"DEVICE://Default_Audio_Device");

// Choose a profile from the collection. The following code
// example identifies a specific profile that supports
// the production of video streams at 7.0, 11.3, 24.0, and
// 87.1 Kbps.

    CComBSTR bstrName = NULL;
    CComVariant varProfile;
    varProfile.vt = VT_DISPATCH;
    hr = pEncoder->get_ProfileCollection(&pProColl);
    hr = pProColl->get_Count(&lCount);
    for (i=0; i<lCount; i++)
    {
        hr = pProColl->Item(i, &pPro);
        hr = pPro->get_Name(&bstrName);
        if (_wcsicmp(bstrName,L"Video for dial-up modems or LAN (28.8 to 100 Kbps)")==0)
        {
            // Set the profile in the source group.
            varProfile.pdispVal = pPro;
            hr = pSrcGrp->put_Profile(varProfile);
            break;
        }
    }

// Create a postview object.

    hr = CoCreateInstance( CLSID_WMEncPreview,
                           NULL,
                           CLSCTX_INPROC_SERVER,
                           IID_IWMEncDataView,
                           (void**)&pPostview);

// Retrieve a postview collection.

    hr = pVidSrc->get_PostviewCollection( &pPostColl );

// Add the postview object to the data view collection. If you set the
// cookie to -1, the encoder engine automatically generates a unique
// cookie.

    long lCookie = -1;
    hr = pPostColl->Add( pPostview, &lCookie);

// Retrieve a pointer to the IWMEncPostViewCollection object. This
// object contains the ViewBandWidth property.

    hr = pPostColl->QueryInterface(IID_IWMEncPostViewCollection,
                                  (void**) &pPostViewColl);

// Identify the video stream to preview by specifying
// the bit rate.

    hr = pPostViewColl->put_ViewBandwidth(11300);

// Continue configuring the encoder engine.
// Initialize the encoder engine.

    hr = pEncoder->PrepareToEncode(VARIANT_TRUE);

// Create a parent window for the postview, and specify the window
// settings for the encoder engine. For instance, you can create a
// window by using the Win32 API function CreateWindow() and pass the
// window handle retrieved from this function to the
// SetViewSetting() method.
// Windows Media Encoder embeds the postview window in the parent window.
// If you do not create a parent window and specify the display
// settings, Windows Media Encoder creates a default window for the
// postview.

    HWND hWnd;
    hr = pPostview->SetViewSetting((DWORD) lCookie,
                                   sizeof(hWnd),
                                  (BYTE*)&hWnd);

// Start the encoder engine.

    hr = pEncoder->Start();

// Start viewing the stream in a pop-up window.

    hr = pPostview->Start((DWORD) lCookie);

See Also

  • IWMEncPostViewCollection Interface
  • IWMEncPostViewCollection::put_ViewBandwidth
  • Running Profile Manager


IWMEncPostViewCollection::put_ViewBandwidth

The put_ViewBandwidth method specifies the bit rate of the preview video stream.

Syntax

HRESULT put_ViewBandwidth(
  long  lBandwidth
);

Parameters

lBandwidth

[in] long containing the bit rate of the preview stream.

Return Values

If the method succeeds, it returns S_OK. If it fails, it returns E_FAIL.

Remarks

If the encoder engine produces multiple-bit-rate streams from a single input stream, you can choose which stream to preview by using the put_ViewBandwidth method. Set lBandwidth equal to zero to select no video stream for the preview. You can also switch between streams while the encoder engine is running. You must use the Profile Manager to determine which profiles support multiple-bit-rate streams.

Example Code

// Include libraries.

#include <windows.h>
#include <atlbase.h>
#include "wmencode.h"
#include "wmencvu.h"

// Declare variables.

    HRESULT hr;
    IWMEncoder* pEncoder;
    IWMEncDataView* pPostview;
    IWMEncDataViewCollection* pPostColl;
    IWMEncPostViewCollection* pPostViewColl;
    IWMEncSourceGroupCollection* pSrcGrpColl;
    IWMEncSourceGroup* pSrcGrp;
    IWMEncSource* pAudSrc;
    IWMEncSource* pVidSrc;
    IWMEncProfileCollection* pProColl;
    IWMEncProfile* pPro;

    long lCount;
    int i;

// Initialize the COM library and retrieve a pointer
// to an IWMEncoder interface.

    hr = CoInitialize(NULL);
    CoCreateInstance(CLSID_WMEncoder,
                     NULL,
                     CLSCTX_INPROC_SERVER,
                     IID_IWMEncoder,
                     (void**) &pEncoder);

// Retrieve a pointer to an IWMEncSourceGroupCollection
// interface.

    hr = pEncoder->get_SourceGroupCollection(&pSrcGrpColl);

// Add a source group to the collection.

    hr = pSrcGrpColl->Add(L"SG_1", &pSrcGrp);

// Add a video and audio source to the source group.

    hr = pSrcGrp->AddSource(WMENC_VIDEO, &pVidSrc);
    hr = pSrcGrp->AddSource(WMENC_AUDIO, &pAudSrc);

// Identify the capture cards.

    hr = pVidSrc->SetInput(L"DEVICE://Default_Video_Device");
    hr = pAudSrc->SetInput(L"DEVICE://Default_Audio_Device");

// Choose a profile from the collection. The following code
// example identifies a specific profile that supports
// the production of video streams at 7.0, 11.3, 24.0, and
// 87.1 Kbps.

    CComBSTR bstrName = NULL;
    CComVariant varProfile;
    varProfile.vt = VT_DISPATCH;
    hr = pEncoder->get_ProfileCollection(&pProColl);
    hr = pProColl->get_Count(&lCount);
    for (i=0; i<lCount; i++)
    {
        hr = pProColl->Item(i, &pPro);
        hr = pPro->get_Name(&bstrName);
        if (_wcsicmp(bstrName,L"Video for dial-up modems or LAN (28.8 to 100 Kbps)")==0)
        {
            // Set the profile in the source group.
            varProfile.pdispVal = pPro;
            hr = pSrcGrp->put_Profile(varProfile);
            break;
        }
    }

// Create a postview object.

    hr = CoCreateInstance( CLSID_WMEncPreview,
                           NULL,
                           CLSCTX_INPROC_SERVER,
                           IID_IWMEncDataView,
                           (void**)&pPostview);

// Retrieve a postview collection.

    hr = pVidSrc->get_PostviewCollection( &pPostColl );

// Add the postview object to the data view collection. If you set the
// cookie to -1, the encoder engine automatically generates a unique
// cookie.

    long lCookie = -1;
    hr = pPostColl->Add( pPostview, &lCookie);

// Retrieve a pointer to the IWMEncPostViewCollection object. This
// object contains the ViewBandWidth property.

    hr = pPostColl->QueryInterface(IID_IWMEncPostViewCollection,
                                  (void**) &pPostViewColl);

// Identify the video stream to preview by specifying
// the bit rate.

    hr = pPostViewColl->put_ViewBandwidth(11300);

// Continue configuring the encoder engine.
// Initialize the encoder engine.

    hr = pEncoder->PrepareToEncode(VARIANT_TRUE);

// Create a parent window for the postview, and specify the window
// settings for the encoder engine. For instance, you can create a
// window by using the Win32 API function CreateWindow() and pass the
// window handle retrieved from this function to the
// SetViewSetting() method.
// Windows Media Encoder embeds the postview window in the parent window.
// If you do not create a parent window and specify the display
// settings, Windows Media Encoder creates a default window for the
// postview.

    HWND hWnd;
    hr = pPostview->SetViewSetting((DWORD) lCookie,
                                   sizeof(hWnd),
                                  (BYTE*)&hWnd);

// Start the encoder engine.

    hr = pEncoder->Start();

// Start viewing the stream in a pop-up window.

    hr = pPostview->Start((DWORD) lCookie);

See Also

  • IWMEncPostViewCollection::get_ViewBandwidth
  • IWMEncPostViewCollection Interface


IWMEncProfile Interface

The IWMEncProfile interface is used to retrieve the name, description and media types for a specific profile object. Windows Media Encoder compresses input streams according to a profile tailored to both the content being broadcast and the expected bandwidth of the client computer. Multiple profiles can exist during an encoding session, but only one can be applied to a source group at any time.

Profiles identify the media type of the encoded output stream, the target audience bandwidth, and whether the output stream can be encoded at multiple bit rates. Only one profile can be associated with a specific source group, and only one source group can be encoded at a time. System-defined profiles cannot be changed or removed, but user-defined profiles can be added. To edit a profile, you must use either the Profile Manager or the Windows Media Format SDK. You can use the IWMEncProfileManager interface to create the Profile Manager dialog boxes that edit and list profiles.

In addition to the methods inherited from IDispatch, the IWMEncProfile interface exposes the following methods.

Method | Description
get_Description | Retrieves a profile description.
get_MaxPacketSize | Retrieves the maximum size, in bytes, of the Windows Media data units generated during encoding.
get_MediaCount | Retrieves the number of audio, video and script streams supported by a profile.
get_MultipleBitrate | Retrieves a Boolean value indicating whether the profile supports multiple bit rate encoded output.
get_Name | Retrieves the name of the profile.
put_MaxPacketSize | Specifies the maximum size, in bytes, of the Windows Media data units generated during encoding.

See Also

  • [Visual Basic] IWMEncProfile Object
  • IWMEncProfileManager Interface
  • Interfaces (C++)


IWMEncProfile::get_Description

The get_Description method retrieves a profile description.

Syntax

HRESULT get_Description(
  BSTR*  bstrDescription
);

Parameters

bstrDescription

[out] Pointer to a BSTR containing a description of the profile.

Return Values

If the method succeeds, it returns S_OK. If it fails, it supports the IErrorInfo interface.

Remarks

Descriptive information can only be supplied when a profile is created. Use the IWMEncProfileCollection interface to acquire a specific profile.

Example Code

// Include libraries.

#include <windows.h>
#include <atlbase.h>    // Includes CComBSTR.
#include "wmencode.h"

// Declare variables.

    HRESULT hr;
    IWMEncoder* pEncoder;
    IWMEncSourceGroupCollection* pSrcGrpColl;
    IWMEncSourceGroup* pSrcGrp;
    IWMEncSource* pAudSrc;
    IWMEncSource* pVidSrc;
    IWMEncProfileCollection* pProColl;
    IWMEncProfile* pPro;
    long lCount;
    int i;

// Initialize the COM library and retrieve a pointer
// to an IWMEncoder interface.

    hr = CoInitialize(NULL);
    CoCreateInstance(CLSID_WMEncoder,
                     NULL,
                     CLSCTX_INPROC_SERVER,
                     IID_IWMEncoder,
                    (void**) &pEncoder);

// Retrieve a pointer to an IWMEncSourceGroupCollection
// interface.

    hr = pEncoder->get_SourceGroupCollection(&pSrcGrpColl);

// Add an empty source group to the collection.

    hr = pSrcGrpColl->Add(L"SG_1", &pSrcGrp);

// Add an audio and video stream to the source group.

    hr = pSrcGrp->AddSource(WMENC_AUDIO, &pAudSrc);
    hr = pSrcGrp->AddSource(WMENC_VIDEO, &pVidSrc);

// Specify an .avi source file and a .wmv output file.

    CComBSTR m_bstrInFile(L"C:\\filename.avi");
    hr = pAudSrc->SetInput(m_bstrInFile);
    hr = pVidSrc->SetInput(m_bstrInFile);

// Loop through the profile collection and retrieve a specific
// profile.

    hr = pEncoder->get_ProfileCollection(&pProColl);
    CComBSTR bstrName(L"");
    CComBSTR bstrDesc(L"");
    long lMaxPacketSize;
    short iMediaCount;
    VARIANT_BOOL vbMultiBitrate;
    CComVariant varProfile;
    varProfile.vt = VT_DISPATCH;
    hr = pProColl->get_Count(&lCount);
    for (i=0; i<lCount; i++)
    {
        hr = pProColl->Item(i, &pPro);
        hr = pPro->get_Name(&bstrName);
        if (_wcsicmp(bstrName, L"profile_name")==0)
        {
        varProfile.pdispVal = pPro;
        hr = pSrcGrp->put_Profile(varProfile);
        hr = pPro->get_Description(&bstrDesc);
        hr = pPro->get_MaxPacketSize(&lMaxPacketSize);
        hr = pPro->get_MediaCount(WMENC_VIDEO, &iMediaCount);
        hr = pPro->get_MultipleBitrate(&vbMultiBitrate);
        break;
        }
    }

// Start the encoder engine.

    hr = pEncoder->Start();

See Also

  • IWMEncProfile Interface
  • IWMEncProfileCollection Interface
  • IWMEncSource Interface
  • IWMEncSourceGroup Interface
  • IWMEncSourceGroupCollection Interface


IWMEncProfile::get_MaxPacketSize

The get_MaxPacketSize method retrieves the maximum size, in bytes, of the Windows Media data units generated during encoding.

Syntax

HRESULT get_MaxPacketSize(
  long*  plMaxPacketSize
);

Parameters

plMaxPacketSize

[out] Pointer to a long containing the maximum packet size, in bytes.

Return Values

If the method succeeds, it returns S_OK. If it fails, it supports the IErrorInfo interface and returns an HRESULT error code.

Return code | Number | Meaning
E_FAIL | 0x80004005 | An unspecified error occurred.
E_POINTER | 0x80004003 | The pointer to the packet size is NULL.

Remarks

The get_MaxPacketSize method retrieves the size of the UDP datagrams streamed by the encoder engine. This value can be either zero or a number between 100 and 65,535 (in bytes). If the value is zero, the encoder engine automatically generates packets that are no larger than 16,000 bytes. If the profile does not support uncompressed streams, the default value is zero. If the profile supports uncompressed streams the default value is 65,535. The maximum packet size does not include the networking packet header or the Windows Media packet header. Use IWMEncProfile::put_MaxPacketSize to specify the packet size.

Example Code

// Include libraries.

#include <windows.h>
#include <atlbase.h>    // Includes CComBSTR.
#include "wmencode.h"

// Declare variables.

    HRESULT hr;
    IWMEncoder* pEncoder;
    IWMEncSourceGroupCollection* pSrcGrpColl;
    IWMEncSourceGroup* pSrcGrp;
    IWMEncSource* pAudSrc;
    IWMEncSource* pVidSrc;
    IWMEncProfileCollection* pProColl;
    IWMEncProfile* pPro;
    long lCount;
    int i;

// Initialize the COM library and retrieve a pointer
// to an IWMEncoder interface.

    hr = CoInitialize(NULL);
    CoCreateInstance(CLSID_WMEncoder,
                     NULL,
                     CLSCTX_INPROC_SERVER,
                     IID_IWMEncoder,
                    (void**) &pEncoder);

// Retrieve a pointer to an IWMEncSourceGroupCollection
// interface.

    hr = pEncoder->get_SourceGroupCollection(&pSrcGrpColl);

// Add an empty source group to the collection.

    hr = pSrcGrpColl->Add(L"SG_1", &pSrcGrp);

// Add an audio and video stream to the source group.

    hr = pSrcGrp->AddSource(WMENC_AUDIO, &pAudSrc);
    hr = pSrcGrp->AddSource(WMENC_VIDEO, &pVidSrc);

// Specify an .avi source file and a .wmv output file.

    CComBSTR m_bstrInFile(L"C:\\filename.avi");
    hr = pAudSrc->SetInput(m_bstrInFile);
    hr = pVidSrc->SetInput(m_bstrInFile);

// Loop through the profile collection and retrieve a specific
// profile.

    hr = pEncoder->get_ProfileCollection(&pProColl);
    CComBSTR bstrName(L"");
    CComBSTR bstrDesc(L"");
    long lMaxPacketSize;
    short iMediaCount;
    VARIANT_BOOL vbMultiBitrate;
    CComVariant varProfile;
    varProfile.vt = VT_DISPATCH;
    hr = pProColl->get_Count(&lCount);
    for (i=0; i<lCount; i++)
    {
        hr = pProColl->Item(i, &pPro);
        hr = pPro->get_Name(&bstrName);
        if (_wcsicmp(bstrName, L"profile_name")==0)
        {
        varProfile.pdispVal = pPro;
        hr = pSrcGrp->put_Profile(varProfile);
        hr = pPro->get_Description(&bstrDesc);
        hr = pPro->get_MaxPacketSize(&lMaxPacketSize);
        hr = pPro->get_MediaCount(WMENC_VIDEO, &iMediaCount);
        hr = pPro->get_MultipleBitrate(&vbMultiBitrate);
        break;
        }
    }

// Start the encoder engine.

    hr = pEncoder->Start();

See Also

  • IWMEncProfile Interface
  • IWMEncProfileCollection Interface
  • IWMEncSource Interface
  • IWMEncSourceGroup Interface
  • IWMEncSourceGroupCollection Interface
  • IWMEncProfile::put_MaxPacketSize


IWMEncProfile::get_MediaCount

The get_MediaCount method retrieves the number of audio, video and script streams supported by a profile.

Syntax

HRESULT get_MediaCount(
  WMENC_SOURCE_TYPE  enumType
  short*  piCount
);

Parameters

enumType

[in] Member of a WMENC_SOURCE_TYPE enumeration type identifying the media stream. This must be a bitwise OR of one of the following values.

Value | Number | Meaning
WMENC_AUDIO | 1 | Identifies an audio stream.
WMENC_VIDEO | 2 | Identifies a video stream.
WMENC_SCRIPT | 4 | Identifies a text stream.

piCount

[out] Pointer to a short containing the number of stream types that the profile can support.

Return Values

If the method succeeds, it returns S_OK. If it fails, it supports the IErrorInfo interface and returns an HRESULT error code.

Return code | Number | Meaning
E_POINTER | 0x80004003 | The pointer to the count is NULL.

Example Code

// Include libraries.

#include <windows.h>
#include <atlbase.h>    // Includes CComBSTR.
#include "wmencode.h"

// Declare variables.

    HRESULT hr;
    IWMEncoder* pEncoder;
    IWMEncSourceGroupCollection* pSrcGrpColl;
    IWMEncSourceGroup* pSrcGrp;
    IWMEncSource* pAudSrc;
    IWMEncSource* pVidSrc;
    IWMEncProfileCollection* pProColl;
    IWMEncProfile* pPro;
    long lCount;
    int i;

// Initialize the COM library and retrieve a pointer
// to an IWMEncoder interface.

    hr = CoInitialize(NULL);
    CoCreateInstance(CLSID_WMEncoder,
                     NULL,
                     CLSCTX_INPROC_SERVER,
                     IID_IWMEncoder,
                    (void**) &pEncoder);

// Retrieve a pointer to an IWMEncSourceGroupCollection
// interface.

    hr = pEncoder->get_SourceGroupCollection(&pSrcGrpColl);

// Add an empty source group to the collection.

    hr = pSrcGrpColl->Add(L"SG_1", &pSrcGrp);

// Add an audio and video stream to the source group.

    hr = pSrcGrp->AddSource(WMENC_AUDIO, &pAudSrc);
    hr = pSrcGrp->AddSource(WMENC_VIDEO, &pVidSrc);

// Specify an .avi source file and a .wmv output file.

    CComBSTR m_bstrInFile(L"C:\\filename.avi");
    hr = pAudSrc->SetInput(m_bstrInFile);
    hr = pVidSrc->SetInput(m_bstrInFile);

// Loop through the profile collection and retrieve a specific
// profile.

    hr = pEncoder->get_ProfileCollection(&pProColl);
    CComBSTR bstrName(L"");
    CComBSTR bstrDesc(L"");
    long lMaxPacketSize;
    short iMediaCount;
    VARIANT_BOOL vbMultiBitrate;
    CComVariant varProfile;
    varProfile.vt = VT_DISPATCH;
    hr = pProColl->get_Count(&lCount);
    for (i=0; i<lCount; i++)
    {
        hr = pProColl->Item(i, &pPro);
        hr = pPro->get_Name(&bstrName);
        if (_wcsicmp(bstrName, L"profile_name")==0)
        {
        varProfile.pdispVal = pPro;
        hr = pSrcGrp->put_Profile(varProfile);
        hr = pPro->get_Description(&bstrDesc);
        hr = pPro->get_MaxPacketSize(&lMaxPacketSize);
        hr = pPro->get_MediaCount(WMENC_VIDEO, &iMediaCount);
        hr = pPro->get_MultipleBitrate(&vbMultiBitrate);
        break;
        }
    }

// Start the encoder engine.

    hr = pEncoder->Start();

See Also

  • IWMEncProfile Interface
  • IWMEncProfileCollection Interface
  • IWMEncSource Interface
  • IWMEncSourceGroup Interface
  • IWMEncSourceGroupCollection Interface


IWMEncProfile::get_MultipleBitrate

The get_MultipleBitrate method retrieves a Boolean value indicating whether the profile supports multiple bit rate encoded output.

Syntax

HRESULT get_MultipleBitrate(
  VARIANT_BOOL*  pbMBR
);

Parameters

pbMBR

[out] Pointer to a VARIANT_BOOL indicating whether the profile supports multiple bit rate encoded output.

Return Values

If the method succeeds, it returns S_OK. If it fails, it supports the IErrorInfo interface and returns an HRESULT error code.

Return code | Number | Meaning
E_POINTER | 0x80004003 | The pointer to the Boolean value is NULL.

Example Code

// Include libraries.

#include <windows.h>
#include <atlbase.h>    // Includes CComBSTR.
#include "wmencode.h"

// Declare variables.

    HRESULT hr;
    IWMEncoder* pEncoder;
    IWMEncSourceGroupCollection* pSrcGrpColl;
    IWMEncSourceGroup* pSrcGrp;
    IWMEncSource* pAudSrc;
    IWMEncSource* pVidSrc;
    IWMEncProfileCollection* pProColl;
    IWMEncProfile* pPro;
    long lCount;
    int i;

// Initialize the COM library and retrieve a pointer
// to an IWMEncoder interface.

    hr = CoInitialize(NULL);
    CoCreateInstance(CLSID_WMEncoder,
                     NULL,
                     CLSCTX_INPROC_SERVER,
                     IID_IWMEncoder,
                    (void**) &pEncoder);

// Retrieve a pointer to an IWMEncSourceGroupCollection
// interface.

    hr = pEncoder->get_SourceGroupCollection(&pSrcGrpColl);

// Add an empty source group to the collection.

    hr = pSrcGrpColl->Add(L"SG_1", &pSrcGrp);

// Add an audio and video stream to the source group.

    hr = pSrcGrp->AddSource(WMENC_AUDIO, &pAudSrc);
    hr = pSrcGrp->AddSource(WMENC_VIDEO, &pVidSrc);

// Specify an .avi source file and a .wmv output file.

    CComBSTR m_bstrInFile(L"C:\\filename.avi");
    hr = pAudSrc->SetInput(m_bstrInFile);
    hr = pVidSrc->SetInput(m_bstrInFile);

// Loop through the profile collection and retrieve a specific
// profile.

    hr = pEncoder->get_ProfileCollection(&pProColl);
    CComBSTR bstrName(L"");
    CComBSTR bstrDesc(L"");
    long lMaxPacketSize;
    short iMediaCount;
    VARIANT_BOOL vbMultiBitrate;
    CComVariant varProfile;
    varProfile.vt = VT_DISPATCH;
    hr = pProColl->get_Count(&lCount);
    for (i=0; i<lCount; i++)
    {
        hr = pProColl->Item(i, &pPro);
        hr = pPro->get_Name(&bstrName);
        if (_wcsicmp(bstrName, L"profile_name")==0)
        {
        varProfile.pdispVal = pPro;
        hr = pSrcGrp->put_Profile(varProfile);
        hr = pPro->get_Description(&bstrDesc);
        hr = pPro->get_MaxPacketSize(&lMaxPacketSize);
        hr = pPro->get_MediaCount(WMENC_VIDEO, &iMediaCount);
        hr = pPro->get_MultipleBitrate(&vbMultiBitrate);
        break;
        }
    }

// Start the encoder engine.

    hr = pEncoder->Start();

See Also

  • IWMEncProfile Interface
  • IWMEncProfileCollection Interface
  • IWMEncSource Interface
  • IWMEncSourceGroup Interface
  • IWMEncSourceGroupCollection Interface


IWMEncProfile::get_Name

The get_Name method retrieves the name of a profile.

Syntax

HRESULT get_Name(
  BSTR*  bstrName
);

Parameters

bstrDescription

[out] Pointer to a BSTR containing the name of the profile.

Return Values

If the method succeeds, it returns S_OK. If it fails, it supports the IErrorInfo interface.

Remarks

Use the name to retrieve a specific profile from the collection. Iterate through the collection, comparing the name retrieved for each profile with the name of the profile needed. When a match is found, use the get_Profile method in the IWMEncSourceGroup interface or the Item method in the IWMEncProfileCollection interface to return a pointer to the profile.

Example Code

// Include libraries.

#include <windows.h>
#include <atlbase.h>    // Includes CComBSTR.
#include "wmencode.h"

// Declare variables.

    HRESULT hr;
    IWMEncoder* pEncoder;
    IWMEncSourceGroupCollection* pSrcGrpColl;
    IWMEncSourceGroup* pSrcGrp;
    IWMEncSource* pAudSrc;
    IWMEncSource* pVidSrc;
    IWMEncProfileCollection* pProColl;
    IWMEncProfile* pPro;
    long lCount;
    int i;

// Initialize the COM library and retrieve a pointer
// to an IWMEncoder interface.

    hr = CoInitialize(NULL);
    CoCreateInstance(CLSID_WMEncoder,
                     NULL,
                     CLSCTX_INPROC_SERVER,
                     IID_IWMEncoder,
                    (void**) &pEncoder);

// Retrieve a pointer to an IWMEncSourceGroupCollection
// interface.

    hr = pEncoder->get_SourceGroupCollection(&pSrcGrpColl);

// Add an empty source group to the collection.

    hr = pSrcGrpColl->Add(L"SG_1", &pSrcGrp);

// Add an audio and video stream to the source group.

    hr = pSrcGrp->AddSource(WMENC_AUDIO, &pAudSrc);
    hr = pSrcGrp->AddSource(WMENC_VIDEO, &pVidSrc);

// Specify an .avi source file and a .wmv output file.

    CComBSTR m_bstrInFile(L"C:\\filename.avi");
    hr = pAudSrc->SetInput(m_bstrInFile);
    hr = pVidSrc->SetInput(m_bstrInFile);

// Loop through the profile collection and retrieve a specific
// profile.

    hr = pEncoder->get_ProfileCollection(&pProColl);
    CComBSTR bstrName(L"");
    CComBSTR bstrDesc(L"");
    long lMaxPacketSize;
    short iMediaCount;
    VARIANT_BOOL vbMultiBitrate;
    CComVariant varProfile;
    varProfile.vt = VT_DISPATCH;
    hr = pProColl->get_Count(&lCount);
    for (i=0; i<lCount; i++)
    {
        hr = pProColl->Item(i, &pPro);
        hr = pPro->get_Name(&bstrName);
        if (_wcsicmp(bstrName, L"profile_name")==0)
        {
        varProfile.pdispVal = pPro;
        hr = pSrcGrp->put_Profile(varProfile);
        hr = pPro->get_Description(&bstrDesc);
        hr = pPro->get_MaxPacketSize(&lMaxPacketSize);
        hr = pPro->get_MediaCount(WMENC_VIDEO, &iMediaCount);
        hr = pPro->get_MultipleBitrate(&vbMultiBitrate);
        break;
        }
    }

// Start the encoder engine.

    hr = pEncoder->Start();

See Also

  • IWMEncProfile Interface
  • IWMEncProfileCollection Interface
  • IWMEncProfileCollection::Item
  • IWMEncSource Interface
  • IWMEncSourceGroup::get_Profile
  • IWMEncSourceGroup Interface
  • IWMEncSourceGroupCollection Interface


IWMEncProfile::put_MaxPacketSize

The put_MaxPacketSize method specifies the maximum size, in bytes, of the Windows Media data units generated during encoding.

Syntax

HRESULT put_MaxPacketSize(
  long  lMaxPacketSize
);

Parameters

lMaxPacketSize

[in] long containing the maximum packet size.

Return Values

If the method succeeds, it returns S_OK. If it fails, it supports the IErrorInfo interface and returns an HRESULT error code.

Return code | Number | Meaning
NS_E_INVALIDCALL_WHILE_ENCODER_RUNNING | 0xC00D0011 | This method cannot be called if the encoder engine is running.
NS_E_INVALIDPACKETSIZE | 0xC00D1B75L | The packet size must be either 0, or a number between 100 and 65,535.

Remarks

The put_MaxPacketSize method specifies the size of the UDP datagrams streamed by the encoder engine. The maximum packet size can be either zero or a number between 100 and 65,535 (in bytes). If the value is zero, the encoder engine automatically generates packets that are no larger than 16,000 bytes. If the profile does not support uncompressed streams, the default value is zero. If the profile supports uncompressed streams the default value is 65,535. The maximum packet size does not include the networking packet header or the Windows Media packet header. Use the IWMEncProfile::get_MaxPacketSize to retrieve the packet size.

Example Code

// Include libraries.

#include <windows.h>
#include <atlbase.h>    // Includes CComBSTR.
#include "wmencode.h"

// Declare variables.

    HRESULT hr;
    IWMEncoder* pEncoder;
    IWMEncSourceGroupCollection* pSrcGrpColl;
    IWMEncSourceGroup* pSrcGrp;
    IWMEncSource* pAudSrc;
    IWMEncSource* pVidSrc;
    IWMEncProfileCollection* pProColl;
    IWMEncProfile* pPro;
    long lCount;
    int i;

// Initialize the COM library and retrieve a pointer
// to an IWMEncoder interface.

    hr = CoInitialize(NULL);
    CoCreateInstance(CLSID_WMEncoder,
                     NULL,
                     CLSCTX_INPROC_SERVER,
                     IID_IWMEncoder,
                    (void**) &pEncoder);

// Retrieve a pointer to an IWMEncSourceGroupCollection
// interface.

    hr = pEncoder->get_SourceGroupCollection(&pSrcGrpColl);

// Add an empty source group to the collection.

    hr = pSrcGrpColl->Add(L"SG_1", &pSrcGrp);

// Add an audio and video stream to the source group.

    hr = pSrcGrp->AddSource(WMENC_AUDIO, &pAudSrc);
    hr = pSrcGrp->AddSource(WMENC_VIDEO, &pVidSrc);

// Specify an .avi source file and a .wmv output file.

    CComBSTR m_bstrInFile(L"C:\\filename.avi");
    hr = pAudSrc->SetInput(m_bstrInFile);
    hr = pVidSrc->SetInput(m_bstrInFile);

// Loop through the profile collection and retrieve a specific
// profile.

    hr = pEncoder->get_ProfileCollection(&pProColl);
    CComBSTR bstrName(L"");
    CComBSTR bstrDesc(L"");
    long lMaxPacketSize;
    short iMediaCount;
    VARIANT_BOOL vbMultiBitrate;
    CComVariant varProfile;
    varProfile.vt = VT_DISPATCH;
    hr = pProColl->get_Count(&lCount);
    for (i=0; i<lCount; i++)
    {
        hr = pProColl->Item(i, &pPro);
        hr = pPro->get_Name(&bstrName);
        if (_wcsicmp(bstrName, L"profile_name")==0)
        {
        varProfile.pdispVal = pPro;
        hr = pSrcGrp->put_Profile(varProfile);
        hr = pPro->get_Description(&bstrDesc);
        hr = pPro->get_MaxPacketSize(&lMaxPacketSize);
        hr = pPro->get_MediaCount(WMENC_VIDEO, &iMediaCount);
        hr = pPro->get_MultipleBitrate(&vbMultiBitrate);
        break;
        }
    }

// Start the encoder engine.

    hr = pEncoder->Start();

See Also

  • IWMEncProfile::get_MaxPacketSize
  • IWMEncProfile Interface
  • IWMEncProfileCollection Interface
  • IWMEncSource Interface
  • IWMEncSourceGroup Interface
  • IWMEncSourceGroupCollection Interface


IWMEncProfileCollection Interface

The IWMEncProfileCollection interface contains all of the enumerated profiles that are available to an encoding session. In addition to the methods inherited from IDispatch, the IWMEncProfileCollection interface exposes the following methods.

Method | Description
get_Count | Retrieves the number of profiles in the collection.
get_length | Retrieves the number of profiles in the collection. This is the JScript version of get_Count.
get_ProfileDirectory | Retrieves the path of the directory containing custom profiles.
Item | Retrieves a specific profile from the collection.
Refresh | Removes the old profile collection and populates a new collection.

See Also

  • [Visual Basic] IWMEncProfileCollection Object
  • Interfaces (C++)


IWMEncProfileCollection::get_Count

The get_Count method retrieves the number of profiles in the collection.

Syntax

HRESULT get_Count(
  long*  plCount
);

Parameters

plCount

[out] Pointer to a long containing the number of profiles in the collection.

Return Values

If the method succeeds, it returns S_OK.

Remarks

This method is the C++ version of the JScript get_length method.

Example Code

// Include libraries.

#include <windows.h>
#include <atlbase.h>    // Includes CComBSTR.
#include "wmencode.h"

// Declare variables.

    HRESULT hr;
    IWMEncoder* pEncoder;
    IWMEncSourceGroupCollection* pSrcGrpColl;
    IWMEncSourceGroup* pSrcGrp;
    IWMEncSource* pAudSrc;
    IWMEncSource* pVidSrc;
    IWMEncProfileCollection* pProColl;
    IWMEncProfile* pPro;
    long lCount;
    int i;

// Initialize the COM library and retrieve a pointer
// to an IWMEncoder interface.

    hr = CoInitialize(NULL);
    CoCreateInstance(CLSID_WMEncoder,
                     NULL,
                     CLSCTX_INPROC_SERVER,
                     IID_IWMEncoder,
                    (void**) &pEncoder);

// Retrieve a pointer to an IWMEncSourceGroupCollection
// interface.

    hr = pEncoder->get_SourceGroupCollection(&pSrcGrpColl);

// Add an empty source group to the collection.

    hr = pSrcGrpColl->Add(L"SG_1", &pSrcGrp);

// Add an audio and video stream to the source group.

    hr = pSrcGrp->AddSource(WMENC_AUDIO, &pAudSrc);
    hr = pSrcGrp->AddSource(WMENC_VIDEO, &pVidSrc);

// Specify an .avi source file and a .wmv output file.

    CComBSTR m_bstrInFile(L"C:\\filename.avi");
    hr = pAudSrc->SetInput(m_bstrInFile);
    hr = pVidSrc->SetInput(m_bstrInFile);

// Loop through the profile collection and retrieve a specific
// profile.

    hr = pEncoder->get_ProfileCollection(&pProColl);
    CComBSTR bstrName(L"");
    CComBSTR bstrDesc(L"");
    long lMaxPacketSize;
    short iMediaCount;
    VARIANT_BOOL vbMultiBitrate;
    CComVariant varProfile;
    varProfile.vt = VT_DISPATCH;
    hr = pProColl->get_Count(&lCount);
    for (i=0; i<lCount; i++)
    {
        hr = pProColl->Item(i, &pPro);
        hr = pPro->get_Name(&bstrName);
        if (_wcsicmp(bstrName, L"profile_name")==0)
        {
        varProfile.pdispVal = pPro;
        hr = pSrcGrp->put_Profile(varProfile);
        hr = pPro->get_Description(&bstrDesc);
        hr = pPro->get_MaxPacketSize(&lMaxPacketSize);
        hr = pPro->get_MediaCount(WMENC_VIDEO, &iMediaCount);
        hr = pPro->get_MultipleBitrate(&vbMultiBitrate);
        break;
        }
    }

// Start the encoder engine.

    hr = pEncoder->Start();

See Also

  • IWMEncProfileCollection::get_length
  • IWMEncProfile Interface
  • IWMEncProfileCollection Interface
  • IWMEncSource Interface
  • IWMEncSourceGroup Interface
  • IWMEncSourceGroupCollection Interface


IWMEncProfileCollection::get_length

The get_length method retrieves the number of profiles in the collection.

Syntax

HRESULT get_length(
  long*  plCount
);

Parameters

plCount

[out] Pointer to a long containing the number of profiles in the collection.

Return Values

If the method succeeds, it returns S_OK.

Remarks

This method performs the same action as the get_Count method. It is included for JScript developers or developers more comfortable with JScript syntax.

Example Code

// Include libraries.

#include <windows.h>
#include <atlbase.h>    // Includes CComBSTR.
#include "wmencode.h"

// Declare variables.

    HRESULT hr;
    IWMEncoder* pEncoder;
    IWMEncSourceGroupCollection* pSrcGrpColl;
    IWMEncSourceGroup* pSrcGrp;
    IWMEncSource* pAudSrc;
    IWMEncSource* pVidSrc;
    IWMEncProfileCollection* pProColl;
    IWMEncProfile* pPro;
    long lCount;
    int i;

// Initialize the COM library and retrieve a pointer
// to an IWMEncoder interface.

    hr = CoInitialize(NULL);
    CoCreateInstance(CLSID_WMEncoder,
                     NULL,
                     CLSCTX_INPROC_SERVER,
                     IID_IWMEncoder,
                    (void**) &pEncoder);

// Retrieve a pointer to an IWMEncSourceGroupCollection
// interface.

    hr = pEncoder->get_SourceGroupCollection(&pSrcGrpColl);

// Add an empty source group to the collection.

    hr = pSrcGrpColl->Add(L"SG_1", &pSrcGrp);

// Add an audio and video stream to the source group.

    hr = pSrcGrp->AddSource(WMENC_AUDIO, &pAudSrc);
    hr = pSrcGrp->AddSource(WMENC_VIDEO, &pVidSrc);

// Specify an .avi source file and a .wmv output file.

    CComBSTR m_bstrInFile(L"C:\\filename.avi");
    hr = pAudSrc->SetInput(m_bstrInFile);
    hr = pVidSrc->SetInput(m_bstrInFile);

// Loop through the profile collection and retrieve a specific
// profile.

    hr = pEncoder->get_ProfileCollection(&pProColl);
    CComBSTR bstrName(L"");
    CComBSTR bstrDesc(L"");
    long lMaxPacketSize;
    short iMediaCount;
    VARIANT_BOOL vbMultiBitrate;
    CComVariant varProfile;
    varProfile.vt = VT_DISPATCH;
    hr = pProColl->get_Count(&lCount);
    for (i=0; i<lCount; i++)
    {
        hr = pProColl->Item(i, &pPro);
        hr = pPro->get_Name(&bstrName);
        if (_wcsicmp(bstrName, L"profile_name")==0)
        {
        varProfile.pdispVal = pPro;
        hr = pSrcGrp->put_Profile(varProfile);
        hr = pPro->get_Description(&bstrDesc);
        hr = pPro->get_MaxPacketSize(&lMaxPacketSize);
        hr = pPro->get_MediaCount(WMENC_VIDEO, &iMediaCount);
        hr = pPro->get_MultipleBitrate(&vbMultiBitrate);
        break;
        }
    }

// Start the encoder engine.

    hr = pEncoder->Start();

See Also

  • IWMEncProfileCollection::get_Count
  • IWMEncProfile Interface
  • IWMEncProfileCollection Interface
  • IWMEncSource Interface
  • IWMEncSourceGroup Interface
  • IWMEncSourceGroupCollection Interface


IWMEncProfileCollection::get_ProfileDirectory

The get_ProfileDirectory method retrieves the path of the directory containing custom profiles.

Syntax

HRESULT get_ProfileDirectory(
  BSTR*  bstrDirectory
);

Parameters

bstrDirectory

[out] Pointer to a BSTR containing the path.

Return Values

If the method succeeds, it returns S_OK.

Remarks

The default directory can be found by examining the registry key HKEY_CLASSES_ROOT\Software\Microsoft\Windows Media Tools\Encoder\Profile\Directory. The get_ProfileDirectory method does not return the name of the directory where the system profiles are stored. The file name extension for profiles is .prx.

Example Code

// Include libraries.

#include <windows.h>
#include <atlbase.h>    // Includes CComBSTR.
#include "wmencode.h"

// Declare variables.

    HRESULT hr;
    IWMEncoder* pEncoder;
    IWMEncSourceGroupCollection* pSrcGrpColl;
    IWMEncSourceGroup* pSrcGrp;
    IWMEncSource* pAudSrc;
    IWMEncSource* pVidSrc;
    IWMEncProfileCollection* pProColl;
    IWMEncProfile* pPro;
    long lCount;
    int i;

// Initialize the COM library and retrieve a pointer
// to an IWMEncoder interface.

    hr = CoInitialize(NULL);
    CoCreateInstance(CLSID_WMEncoder,
                     NULL,
                     CLSCTX_INPROC_SERVER,
                     IID_IWMEncoder,
                    (void**) &pEncoder);

// Retrieve a pointer to an IWMEncSourceGroupCollection
// interface.

    hr = pEncoder->get_SourceGroupCollection(&pSrcGrpColl);

// Add an empty source group to the collection.

    hr = pSrcGrpColl->Add(L"SG_1", &pSrcGrp);

// Add an audio and video stream to the source group.

    hr = pSrcGrp->AddSource(WMENC_AUDIO, &pAudSrc);
    hr = pSrcGrp->AddSource(WMENC_VIDEO, &pVidSrc);

// Specify an .avi source file and a .wmv output file.

    CComBSTR m_bstrInFile(L"C:\\filename.avi");
    hr = pAudSrc->SetInput(m_bstrInFile);
    hr = pVidSrc->SetInput(m_bstrInFile);

// Loop through the profile collection and retrieve a specific
// profile.

    hr = pEncoder->get_ProfileCollection(&pProColl);
    CComBSTR bstrName(L"");
    CComBSTR bstrDesc(L"");
    long lMaxPacketSize;
    short iMediaCount;
    VARIANT_BOOL vbMultiBitrate;
    CComVariant varProfile;
    varProfile.vt = VT_DISPATCH;
    hr = pProColl->get_Count(&lCount);
    for (i=0; i<lCount; i++)
    {
        hr = pProColl->Item(i, &pPro);
        hr = pPro->get_Name(&bstrName);
        if (_wcsicmp(bstrName, L"profile_name")==0)
        {
        varProfile.pdispVal = pPro;
        hr = pSrcGrp->put_Profile(varProfile);
        hr = pPro->get_Description(&bstrDesc);
        hr = pPro->get_MaxPacketSize(&lMaxPacketSize);
        hr = pPro->get_MediaCount(WMENC_VIDEO, &iMediaCount);
        hr = pPro->get_MultipleBitrate(&vbMultiBitrate);
        break;
        }
    }

// Start the encoder engine.

    hr = pEncoder->Start();

See Also

  • IWMEncProfile Interface
  • IWMEncProfileCollection Interface
  • IWMEncSource Interface
  • IWMEncSourceGroup Interface
  • IWMEncSourceGroupCollection Interface


IWMEncProfileCollection::Item

The Item method retrieves a specific profile from the collection.

Syntax

HRESULT Item(
  long  iIndex,
  IWMEncProfile**  ppProfile
);

Parameters

iIndex

[in] long containing the index into the collection.

ppProfile

[out] Pointer to a pointer to the IWMEncProfile interface corresponding to iIndex.

Return Values

If the method succeeds, it returns S_OK.

Remarks

The input parameter is an integer index into the collection. If you do not already know the index associated with the needed profile pointer, you must iterate through the collection starting at item 0. On each iteration increment iIndex and use the Item method to retrieve a pointer to a profile. Call the IWMEncProfile::get_Name method to find the name of the profile being pointed to and compare the name retrieved to that needed. Exit the loop when a match is found.

Example Code

// Include libraries.

#include <windows.h>
#include <atlbase.h>    // Includes CComBSTR.
#include "wmencode.h"

// Declare variables.

    HRESULT hr;
    IWMEncoder* pEncoder;
    IWMEncSourceGroupCollection* pSrcGrpColl;
    IWMEncSourceGroup* pSrcGrp;
    IWMEncSource* pAudSrc;
    IWMEncSource* pVidSrc;
    IWMEncProfileCollection* pProColl;
    IWMEncProfile* pPro;
    long lCount;
    int i;

// Initialize the COM library and retrieve a pointer
// to an IWMEncoder interface.

    hr = CoInitialize(NULL);
    CoCreateInstance(CLSID_WMEncoder,
                     NULL,
                     CLSCTX_INPROC_SERVER,
                     IID_IWMEncoder,
                    (void**) &pEncoder);

// Retrieve a pointer to an IWMEncSourceGroupCollection
// interface.

    hr = pEncoder->get_SourceGroupCollection(&pSrcGrpColl);

// Add an empty source group to the collection.

    hr = pSrcGrpColl->Add(L"SG_1", &pSrcGrp);

// Add an audio and video stream to the source group.

    hr = pSrcGrp->AddSource(WMENC_AUDIO, &pAudSrc);
    hr = pSrcGrp->AddSource(WMENC_VIDEO, &pVidSrc);

// Specify an .avi source file and a .wmv output file.

    CComBSTR m_bstrInFile(L"C:\\filename.avi");
    hr = pAudSrc->SetInput(m_bstrInFile);
    hr = pVidSrc->SetInput(m_bstrInFile);

// Loop through the profile collection and retrieve a specific
// profile.

    hr = pEncoder->get_ProfileCollection(&pProColl);
    CComBSTR bstrName(L"");
    CComBSTR bstrDesc(L"");
    long lMaxPacketSize;
    short iMediaCount;
    VARIANT_BOOL vbMultiBitrate;
    CComVariant varProfile;
    varProfile.vt = VT_DISPATCH;
    hr = pProColl->get_Count(&lCount);
    for (i=0; i<lCount; i++)
    {
        hr = pProColl->Item(i, &pPro);
        hr = pPro->get_Name(&bstrName);
        if (_wcsicmp(bstrName, L"profile_name")==0)
        {
        varProfile.pdispVal = pPro;
        hr = pSrcGrp->put_Profile(varProfile);
        hr = pPro->get_Description(&bstrDesc);
        hr = pPro->get_MaxPacketSize(&lMaxPacketSize);
        hr = pPro->get_MediaCount(WMENC_VIDEO, &iMediaCount);
        hr = pPro->get_MultipleBitrate(&vbMultiBitrate);
        break;
        }
    }

// Start the encoder engine.

    hr = pEncoder->Start();

See Also

  • IWMEncProfile Interface
  • IWMEncProfileCollection Interface
  • IWMEncSource Interface
  • IWMEncSourceGroup Interface
  • IWMEncSourceGroupCollection Interface


IWMEncProfileCollection::Refresh

The Refresh method removes the old profile collection and populates a new collection.

Syntax

HRESULT Refresh();

Parameters

This method takes no parameters.

Return Values

If the method succeeds, it returns S_OK.

Remarks

Use this method to reveal all of the available profiles after you have modified the collection with either the Profile Manager or the Windows Media Format SDK. You can use the IWMEncProfileManager interface to create the Profile Manager dialog boxes that edit and list profiles.

Example Code

// Include libraries.

#include <windows.h>
#include <atlbase.h>    // Includes CComBSTR.
#include "wmencode.h"

// Declare variables.

    HRESULT hr;
    IWMEncoder* pEncoder;
    IWMEncSourceGroupCollection* pSrcGrpColl;
    IWMEncSourceGroup* pSrcGrp;
    IWMEncSource* pAudSrc;
    IWMEncSource* pVidSrc;
    IWMEncProfileCollection* pProColl;
    IWMEncProfile* pPro;
    long lCount;
    int i;

// Initialize the COM library and retrieve a pointer
// to an IWMEncoder interface.

    hr = CoInitialize(NULL);
    CoCreateInstance(CLSID_WMEncoder,
                     NULL,
                     CLSCTX_INPROC_SERVER,
                     IID_IWMEncoder,
                    (void**) &pEncoder);

// Retrieve a pointer to an IWMEncSourceGroupCollection
// interface.

    hr = pEncoder->get_SourceGroupCollection(&pSrcGrpColl);

// Add an empty source group to the collection.

    hr = pSrcGrpColl->Add(L"SG_1", &pSrcGrp);

// Add an audio and video stream to the source group.

    hr = pSrcGrp->AddSource(WMENC_AUDIO, &pAudSrc);
    hr = pSrcGrp->AddSource(WMENC_VIDEO, &pVidSrc);

// Specify an .avi source file and a .wmv output file.

    CComBSTR m_bstrInFile(L"C:\\filename.avi");
    hr = pAudSrc->SetInput(m_bstrInFile);
    hr = pVidSrc->SetInput(m_bstrInFile);

// Loop through the profile collection and retrieve a specific
// profile.

    hr = pEncoder->get_ProfileCollection(&pProColl);
    CComBSTR bstrName(L"");
    CComBSTR bstrDesc(L"");
    long lMaxPacketSize;
    short iMediaCount;
    VARIANT_BOOL vbMultiBitrate;
    CComVariant varProfile;
    varProfile.vt = VT_DISPATCH;
    hr = pProColl->get_Count(&lCount);
    for (i=0; i<lCount; i++)
    {
        hr = pProColl->Item(i, &pPro);
        hr = pPro->get_Name(&bstrName);
        if (_wcsicmp(bstrName, L"profile_name")==0)
        {
        varProfile.pdispVal = pPro;
        hr = pSrcGrp->put_Profile(varProfile);
        hr = pPro->get_Description(&bstrDesc);
        hr = pPro->get_MaxPacketSize(&lMaxPacketSize);
        hr = pPro->get_MediaCount(WMENC_VIDEO, &iMediaCount);
        hr = pPro->get_MultipleBitrate(&vbMultiBitrate);
        break;
        }
    }

// Start the encoder engine.

    hr = pEncoder->Start();

See Also

  • IWMEncProfile Interface
  • IWMEncProfileCollection Interface
  • IWMEncSource Interface
  • IWMEncSourceGroup Interface
  • IWMEncSourceGroupCollection Interface


IWMEncProfileManager Interface

The IWMEncProfileManager interface creates the Profile Manager dialog boxes that allow the user to edit and list profiles. In addition to the methods inherited from IDispatch, the IWMEncProfileManager interface exposes the following methods.

Method | Description
GetDetailsString | Retrieves a string containing the details of a specific profile.
get_LastCreatedProfile | Retrieves the name of the profile most recently created by the end user during the current encoding session.
get_ProfileDirectory | Retrieves the path of the directory containing custom profiles.
WMEncProfileEdit | Creates a dialog box that enables users to create a profile.
WMEncProfileList | Creates a dialog box that displays a list of profiles.
WMEncProfileListEx | Creates a dialog box that displays a list of profiles, and automatically sets the checkboxes on a new profile.

See Also

  • [Visual Basic] IWMEncProfileManager Object
  • Interfaces (C++)


IWMEncProfileManager::GetDetailsString

The GetDetailsString method retrieves a string containing the details of a specific profile.

Syntax

HRESULT GetDetailsString(
  BSTR  bstrProfileName,
  long  lcid,
  BSTR*  bstrDetailsString
);

Parameters

bstrProfileName

[in] BSTR containing the name of the profile.

lcid

[in] long containing the locale ID identifying the language that appears in the details string. By default, the locale ID is English.

bstrDetailsString

[out] BSTR containing the details of the profile.

Return Values

If the method succeeds, it returns S_OK. If it fails, it returns an HRESULT error code.

Return code | Number | Meaning
E_FAIL | 0x80004005 | An unspecified error occurred.
E_INVALIDARG | 0x80070057 | The string containing the profile name cannot be empty.

Remarks

The output string identifies the total number of streams that will be produced by Windows Media Encoder, the bit rate of each, and the specific codecs used. It also indicates the default size, in pixels, of the output video and the number of audio channels produced. The GetDetailsString method does not create a Profile Manager dialog box.

Example Code

// Include libraries.

#include <windows.h>
#include <atlbase.h>    // Includes CComBSTR.
#include "wmencode.h"

// Declare variables.

    HRESULT hr;
    IWMEncProfileManager* pProfileMgr;

// Initialize the COM library and retrieve a pointer
// to an IWMEncProfileManager interface.

    hr = CoInitialize(NULL);
    CoCreateInstance(CLSID_WMEncProfileManager,
                     NULL,
                     CLSCTX_INPROC_SERVER,
                     IID_IWMEncProfileManager,
                     (void**) &pProfileMgr);

    CComBSTR bstrLastProfile(L"");
    CComBSTR bstrProfileDirectory(L"");
    CComBSTR bstrDetailsString(L"");
    CComBSTR bstrProfileName(L"profile_name");

// Display the dialog box that lists the profiles. Because
// you are calling WMEncProfileListEx() rather than WMEncProfileList()
// and have indicated that a new profile is audio only, if you
// open the New profile dialog box, only the audio check box is selected.

    hr = pProfileMgr->WMEncProfileListEx(WMENC_FILTER_AV,
                                         WMENC_FILTER_A,
                                         0);

// Display the New Profile dialog box. If you supply the name of an
// existing profile, the new profile will be a copy of that profile.

    hr = pProfileMgr->WMEncProfileEdit(bstrProfileName,
                                       WMENC_FILTER_AV,
                                       0);

// Retrieve a string containing the details of a specific profile.

    hr = pProfileMgr->GetDetailsString(bstrProfileName,
                                       0,
                                       &bstrDetailsString);

// Retrieve the name of last profile created by the end user
// during the current encoding session.

    hr = pProfileMgr->get_LastCreatedProfile(&bstrLastProfile);

// Retrieve a string containing the path of the directory in which
// custom profiles are stored.

    hr = pProfileMgr->get_ProfileDirectory(&bstrProfileDirectory);

See Also

  • IWMEncProfileManager Interface


IWMEncProfileManager::get_LastCreatedProfile

The get_LastCreatedProfile method retrieves the name of the profile most recently created by the end user during the current encoding session.

Syntax

HRESULT get_LastCreatedProfile(
  BSTR*  bstrProfile
);

Parameters

bstrProfile

[out] BSTR containing the profile name.

Return Values

If the method succeeds, it returns S_OK.

Remarks

You can use the get_LastCreatedProfile method to determine whether an end user has created a profile with the Profile Manager. The variable containing the name of the profile is reset when you call IWMEncProfileManager::WMEncProfileList.

Example Code

// Include libraries.

#include <windows.h>
#include <atlbase.h>    // Includes CComBSTR.
#include "wmencode.h"

// Declare variables.

    HRESULT hr;
    IWMEncProfileManager* pProfileMgr;

// Initialize the COM library and retrieve a pointer
// to an IWMEncProfileManager interface.

    hr = CoInitialize(NULL);
    CoCreateInstance(CLSID_WMEncProfileManager,
                     NULL,
                     CLSCTX_INPROC_SERVER,
                     IID_IWMEncProfileManager,
                     (void**) &pProfileMgr);

    CComBSTR bstrLastProfile(L"");
    CComBSTR bstrProfileDirectory(L"");
    CComBSTR bstrDetailsString(L"");
    CComBSTR bstrProfileName(L"profile_name");

// Display the dialog box that lists the profiles. Because
// you are calling WMEncProfileListEx() rather than WMEncProfileList()
// and have indicated that a new profile is audio only, if you
// open the New profile dialog box, only the audio check box is selected.

    hr = pProfileMgr->WMEncProfileListEx(WMENC_FILTER_AV,
                                         WMENC_FILTER_A,
                                         0);

// Display the New Profile dialog box. If you supply the name of an
// existing profile, the new profile will be a copy of that profile.

    hr = pProfileMgr->WMEncProfileEdit(bstrProfileName,
                                       WMENC_FILTER_AV,
                                       0);

// Retrieve a string containing the details of a specific profile.

    hr = pProfileMgr->GetDetailsString(bstrProfileName,
                                       0,
                                       &bstrDetailsString);

// Retrieve the name of last profile created by the end user
// during the current encoding session.

    hr = pProfileMgr->get_LastCreatedProfile(&bstrLastProfile);

// Retrieve a string containing the path of the directory in which
// custom profiles are stored.

    hr = pProfileMgr->get_ProfileDirectory(&bstrProfileDirectory);

See Also

  • IWMEncProfileManager Interface
  • IWMEncProfileManager::WMEncProfileList


IWMEncProfileManager::get_ProfileDirectory

The get_ProfileDirectory method retrieves the path of the directory containing custom profiles.

Syntax

HRESULT get_ProfileDirectory(
  BSTR*  bstrDirectory
);

Parameters

bstrDirectory

[out] Pointer to a BSTR containing the path.

Return Values

If the method succeeds, it returns S_OK.

Remarks

The default directory can be found by examining the registry key HKEY_CLASSES_ROOT\Software\Microsoft\Windows Media Tools\Encoder\Profile\Directory. The get_ProfileDirectory method does not return the name of the directory where the system profiles are stored. The file name extension for profiles is .prx.

Example Code

// Include libraries.

#include <windows.h>
#include <atlbase.h>    // Includes CComBSTR.
#include "wmencode.h"

// Declare variables.

    HRESULT hr;
    IWMEncProfileManager* pProfileMgr;

// Initialize the COM library and retrieve a pointer
// to an IWMEncProfileManager interface.

    hr = CoInitialize(NULL);
    CoCreateInstance(CLSID_WMEncProfileManager,
                     NULL,
                     CLSCTX_INPROC_SERVER,
                     IID_IWMEncProfileManager,
                     (void**) &pProfileMgr);

    CComBSTR bstrLastProfile(L"");
    CComBSTR bstrProfileDirectory(L"");
    CComBSTR bstrDetailsString(L"");
    CComBSTR bstrProfileName(L"profile_name");

// Display the dialog box that lists the profiles. Because
// you are calling WMEncProfileListEx() rather than WMEncProfileList()
// and have indicated that a new profile is audio only, if you
// open the New profile dialog box, only the audio check box is selected.

    hr = pProfileMgr->WMEncProfileListEx(WMENC_FILTER_AV,
                                         WMENC_FILTER_A,
                                         0);

// Display the New Profile dialog box. If you supply the name of an
// existing profile, the new profile will be a copy of that profile.

    hr = pProfileMgr->WMEncProfileEdit(bstrProfileName,
                                       WMENC_FILTER_AV,
                                       0);

// Retrieve a string containing the details of a specific profile.

    hr = pProfileMgr->GetDetailsString(bstrProfileName,
                                       0,
                                       &bstrDetailsString);

// Retrieve the name of last profile created by the end user
// during the current encoding session.

    hr = pProfileMgr->get_LastCreatedProfile(&bstrLastProfile);

// Retrieve a string containing the path of the directory in which
// custom profiles are stored.

    hr = pProfileMgr->get_ProfileDirectory(&bstrProfileDirectory);

See Also

  • IWMEncProfileManager Interface


IWMEncProfileManager::WMEncProfileEdit

The WMEncProfileEdit method creates a dialog box that enables users to create a profile.

Syntax

HRESULT WMEncProfileEdit(
  BSTR  bstrProfileName,
  WMENC_MEDIA_FILTER  lfilter,
  long  lcid
);

Parameters

bstrProfileName

[in] BSTR containing the name of the profile. Supply an empty string to create a profile.

lfilter

[in] Member of a WMENC_MEDIA_FILTER enumeration type identifying the type of input streams for which the profile is defined. This must be one of the following values.

Value | Number | Description
WMENC_FILTER_NONE | 0 | The profile is not defined for an input stream.
WMENC_FILTER_A | 1 | The profile is defined for one audio input stream.
WMENC_FILTER_AV | 3 | The profile is defined for one audio and one video input stream.
WMENC_FILTER_AS | 4 | The profile is defined for one audio and one text input stream.
WMENC_FILTER_AVS | 5 | The profile is defined for one audio, one video and one text input stream.

lcid

[in] long containing the locale ID identifying the language that appears in the Profile Manager. By default, the locale ID is English.

Return Values

If the method succeeds, it returns S_OK.

Example Code

// Include libraries.

#include <windows.h>
#include <atlbase.h>    // Includes CComBSTR.
#include "wmencode.h"

// Declare variables.

    HRESULT hr;
    IWMEncProfileManager* pProfileMgr;

// Initialize the COM library and retrieve a pointer
// to an IWMEncProfileManager interface.

    hr = CoInitialize(NULL);
    CoCreateInstance(CLSID_WMEncProfileManager,
                     NULL,
                     CLSCTX_INPROC_SERVER,
                     IID_IWMEncProfileManager,
                     (void**) &pProfileMgr);

    CComBSTR bstrLastProfile(L"");
    CComBSTR bstrProfileDirectory(L"");
    CComBSTR bstrDetailsString(L"");
    CComBSTR bstrProfileName(L"profile_name");

// Display the dialog box that lists the profiles. Because
// you are calling WMEncProfileListEx() rather than WMEncProfileList()
// and have indicated that a new profile is audio only, if you
// open the New profile dialog box, only the audio check box is selected.

    hr = pProfileMgr->WMEncProfileListEx(WMENC_FILTER_AV,
                                         WMENC_FILTER_A,
                                         0);

// Display the New Profile dialog box. If you supply the name of an
// existing profile, the new profile will be a copy of that profile.

    hr = pProfileMgr->WMEncProfileEdit(bstrProfileName,
                                       WMENC_FILTER_AV,
                                       0);

// Retrieve a string containing the details of a specific profile.

    hr = pProfileMgr->GetDetailsString(bstrProfileName,
                                       0,
                                       &bstrDetailsString);

// Retrieve the name of last profile created by the end user
// during the current encoding session.

    hr = pProfileMgr->get_LastCreatedProfile(&bstrLastProfile);

// Retrieve a string containing the path of the directory in which
// custom profiles are stored.

    hr = pProfileMgr->get_ProfileDirectory(&bstrProfileDirectory);

See Also

  • IWMEncProfileManager Interface
  • IWMEncProfileManager::WMEncProfileList


IWMEncProfileManager::WMEncProfileList

The WMEncProfileList method creates a dialog box that displays a list of profiles.

Syntax

HRESULT WMEncProfileList(
  WMENC_MEDIA_FILTER  filter,
  long  lcid
);

Parameters

filter

[in] Member of a WMENC_MEDIA_FILTER enumeration type identifying the type of input streams for which the profiles in the list are defined. This must be one of the following values.

Value | Number | Description
WMENC_FILTER_NONE | 0 | The profile is not defined for an input stream.
WMENC_FILTER_A | 1 | The profile is defined for one audio input stream.
WMENC_FILTER_AV | 3 | The profile is defined for one audio and one video input stream.
WMENC_FILTER_AS | 4 | The profile is defined for one audio and one text input stream.
WMENC_FILTER_AVS | 5 | The profile is defined for one audio, one video and one text input stream.

lcid

[in] long containing the locale ID identifying the language that appears in the Profile Manager. The locale ID for English is zero.

Return Values

If the method succeeds, it returns S_OK.

Example Code

// Include libraries.

#include <windows.h>
#include <atlbase.h>    // Includes CComBSTR.
#include "wmencode.h"

// Declare variables.

    HRESULT hr;
    IWMEncProfileManager* pProfileMgr;

// Initialize the COM library and retrieve a pointer
// to an IWMEncProfileManager interface.

    hr = CoInitialize(NULL);
    CoCreateInstance(CLSID_WMEncProfileManager,
                     NULL,
                     CLSCTX_INPROC_SERVER,
                     IID_IWMEncProfileManager,
                     (void**) &pProfileMgr);

    CComBSTR bstrLastProfile(L"");
    CComBSTR bstrProfileDirectory(L"");
    CComBSTR bstrDetailsString(L"");
    CComBSTR bstrProfileName(L"profile_name");

// Display the dialog box that lists the profiles. Because
// you are calling WMEncProfileListEx() rather than WMEncProfileList()
// and have indicated that a new profile is audio only, if you
// open the New profile dialog box, only the audio checkbox is selected.

    hr = pProfileMgr->WMEncProfileListEx(WMENC_FILTER_AV,
                                         WMENC_FILTER_A,
                                         0);

// Display the New Profile dialog box. If you supply the name of an
// existing profile, the new profile will be a copy of that profile.

    hr = pProfileMgr->WMEncProfileEdit(bstrProfileName,
                                       WMENC_FILTER_AV,
                                       0);

// Retrieve a string containing the details of a specific profile.

    hr = pProfileMgr->GetDetailsString(bstrProfileName,
                                       0,
                                       &bstrDetailsString);

// Retrieve the name of last profile created by the end user
// during the current encoding session.

    hr = pProfileMgr->get_LastCreatedProfile(&bstrLastProfile);

// Retrieve a string containing the path of the directory in which
// custom profiles are stored.

    hr = pProfileMgr->get_ProfileDirectory(&bstrProfileDirectory);

See Also

  • IWMEncProfileManager Interface
  • IWMEncProfileManager::WMEncProfileEdit


IWMEncProfileManager::WMEncProfileListEx

The WMEncProfileListEx method creates a dialog box that displays a list of profiles, and automatically sets the checkboxes on a new profile.

Syntax

HRESULT WMEncProfileListEx(
  WMENC_MEDIA_FILTER  filter,
  WMENC_MEDIA_FILTER  newDefault,
  long  lcid
);

Parameters

filter

[in] Member of a WMENC_MEDIA_FILTER enumeration type identifying the type of input streams for which the profiles in the list are defined. This must be one of the following values.

Value | Number | Description
WMENC_FILTER_NONE | 0 | The profile is not defined for an input stream.
WMENC_FILTER_A | 1 | The profile is defined for one audio input stream.
WMENC_FILTER_AV | 3 | The profile is defined for one audio and one video input stream.
WMENC_FILTER_AS | 4 | The profile is defined for one audio and one text input stream.
WMENC_FILTER_AVS | 5 | The profile is defined for one audio, one video and one text input stream.

newDefault

[in] Member of a WMENC_MEDIA_FILTER enumeration type identifying the type of input streams for which a new profile will be defined. This must be one of the following values.

Value | Number | Description
WMENC_FILTER_NONE | 0 | The profile is not defined for an input stream.
WMENC_FILTER_A | 1 | The profile is defined for one audio input stream.
WMENC_FILTER_AV | 3 | The profile is defined for one audio and one video input stream.
WMENC_FILTER_AS | 4 | The profile is defined for one audio and one text input stream.
WMENC_FILTER_AVS | 5 | The profile is defined for one audio, one video, and one text input stream.

lcid

[in] long containing the locale ID identifying the language that appears in the Profile Manager. The locale ID for English is zero.

Return Values

If the method succeeds, it returns S_OK.

Remarks

When the end user selects New to create a profile, the check boxes in the dialog box are set according to the filter selected for newDefault.

Example Code

// Include libraries.

#include <windows.h>
#include <atlbase.h>    // Includes CComBSTR.
#include "wmencode.h"

// Declare variables.

    HRESULT hr;
    IWMEncProfileManager* pProfileMgr;

// Initialize the COM library and retrieve a pointer
// to an IWMEncProfileManager interface.

    hr = CoInitialize(NULL);
    CoCreateInstance(CLSID_WMEncProfileManager,
                     NULL,
                     CLSCTX_INPROC_SERVER,
                     IID_IWMEncProfileManager,
                     (void**) &pProfileMgr);

    CComBSTR bstrLastProfile(L"");
    CComBSTR bstrProfileDirectory(L"");
    CComBSTR bstrDetailsString(L"");
    CComBSTR bstrProfileName(L"profile_name");

// Display the dialog box that lists the profiles. Because
// you are calling WMEncProfileListEx() rather than WMEncProfileList()
// and have indicated that a new profile is audio only, if you
// open the New profile dialog box, only the audio check box is selected.

    hr = pProfileMgr->WMEncProfileListEx(WMENC_FILTER_AV,
                                         WMENC_FILTER_A,
                                         0);

// Display the New Profile dialog box. If you supply the name of an
// existing profile, the new profile will be a copy of that profile.

    hr = pProfileMgr->WMEncProfileEdit(bstrProfileName,
                                       WMENC_FILTER_AV,
                                       0);

// Retrieve a string containing the details of a specific profile.

    hr = pProfileMgr->GetDetailsString(bstrProfileName,
                                       0,
                                       &bstrDetailsString);

// Retrieve the name of last profile created by the end user
// during the current encoding session.

    hr = pProfileMgr->get_LastCreatedProfile(&bstrLastProfile);

// Retrieve a string containing the path of the directory in which
// custom profiles are stored.

    hr = pProfileMgr->get_ProfileDirectory(&bstrProfileDirectory);

See Also

  • IWMEncProfileManager Interface
  • IWMEncProfileManager::WMEncProfileList


IWMEncSource Interface

The IWMEncSource interface loads a source capture plug-in, trims and repeats a specific stream, and retrieves transformation plug-ins and data view objects. In addition to the methods inherited from IDispatch, the IWMEncSource interface exposes the following methods.

Method | Description
GetInput | Retrieves the stream capture source. This is usually either a file or a plug-in.
get_MarkIn | Retrieves the starting point of a media stream.
get_MarkOut | Retrieves the end point of a media stream.
get_PostviewCollection | Retrieves a collection of postview objects for the source stream.
get_PreviewCollection | Retrieves a collection of preview objects for the source stream.
get_Repeat | Retrieves the repeat property of a stream.
GetSourcePlugin | Retrieves the source plug-in associated with the source stream. This is not an Automation-compliant method.
get_TransformCollection | Retrieves the collection of all registered transform plug-ins.
GetTransformPlugin | Retrieves a specific transform plug-in, by index, for the source stream. This is a non-Automation compliant method.
GetTransformPluginCount | Retrieves the number of transform plug-ins that can be applied to the source stream.
get_Type | Retrieves the type of the input media stream.
put_MarkIn | Specifies the starting point of a media stream.
put_MarkOut | Specifies the end point of a media stream.
put_Repeat | Specifies the repeat property of a stream.
SetInput | Specifies the stream capture source.

See Also

  • [Visual Basic] IWMEncSource Object
  • Interfaces (C++)


IWMEncSource::GetInput

The GetInput method retrieves the stream capture source.

Syntax

HRESULT GetInput(
  BSTR*  pbstrStreamName,
  BSTR*  pbstrScheme,
  BSTR*  pbstrInput
);

Parameters

pbstrStreamName

[out] Pointer to a BSTR containing the name of the input source.

pbstrScheme

[out] Pointer to a BSTR containing the scheme type.

pbstrInput

[out] Pointer to a BSTR containing the full name of a plug-in or file from which the source stream is captured.

Return Values

If the method succeeds, it returns S_OK. If it fails, it returns an HRESULT error code.

Return code | Number | Meaning
E_OUTOFMEMORY | 0x8007000E | Memory cannot be allocated

Examples

// Include libraries.

#include <windows.h>
#include <atlbase.h>   //Contains CComBSTR and CComVariant
#include "wmencode.h"

// Declare variables.

    HRESULT hr;
    IWMEncoder* pEncoder;
    IWMEncSourceGroupCollection* pSrcGrpColl;
    IWMEncSourceGroup* pSrcGrp;
    IWMEncSource* pAudSrc;
    IWMEncSource* pVidSrc;
    IWMEncProfileCollection* pProColl;
    IWMEncProfile* pPro;

    long lCount;
    int i;

// Initialize the COM library and retrieve a pointer
// to an IWMEncoder interface.

    hr = CoInitialize(NULL);
    CoCreateInstance(CLSID_WMEncoder,
                     NULL,
                     CLSCTX_INPROC_SERVER,
                     IID_IWMEncoder,
                     (void**) &pEncoder);

// Retrieve a pointer to an IWMEncSourceGroupCollection
// interface.

    hr = pEncoder->get_SourceGroupCollection(&pSrcGrpColl);

// Add a new source group to the collection.

    hr = pSrcGrpColl->Add(L"SG_1", &pSrcGrp);

// Add an audio and video stream to the source group.

    hr = pSrcGrp->AddSource(WMENC_AUDIO, &pAudSrc);
    hr = pSrcGrp->AddSource(WMENC_VIDEO, &pVidSrc);

// Loop through the profile collection and retrieve a specific
// profile.

    hr = pEncoder->get_ProfileCollection(&pProColl);
    CComBSTR bstrName = NULL;
    CComVariant varProfile;
    varProfile.vt = VT_DISPATCH;
    hr = pProColl->get_Count(&lCount);
    for (i=0; i<lCount; i++)
    {
        hr = pProColl->Item(i, &pPro);
        hr = pPro->get_Name(&bstrName);
        if (_wcsicmp(bstrName, L"profile name")==0)
        {
            varProfile.pdispVal = pPro;
            pSrcGrp->put_Profile(varProfile);
            break;
        }
    }

// Specify live stream capture from the installed
// audio and video cards.

    hr = pVidSrc->SetInput(L"DEVICE://Default_Video_Device");
    hr = pAudSrc->SetInput(L"DEVICE://Default_Audio_Device");

// Initialize the encoder engine.

    hr = pSrcGrp->PrepareToEncode(VARIANT_TRUE);

// Verify that the repeat property is turned off.

    hr = pVidSrc->put_Repeat(VARIANT_FALSE);
    hr = pAudSrc->put_Repeat(VARIANT_FALSE);

// Start the encoding process 10 seconds after the source
// has started, and stop the encoding process 25 seconds
// after the source has started.

    hr =pVidSrc->put_MarkIn(10);
    hr =pAudSrc->put_MarkIn(10);
    hr =pVidSrc->put_MarkOut(25);
    hr =pAudSrc->put_MarkOut(25);

See Also

  • IWMEncSource Interface
  • IWMEncSource::SetInput


IWMEncSource::get_MarkIn

The get_MarkIn method retrieves the starting point of a stream, in milliseconds, from the start of the original stream.

Syntax

HRESULT get_MarkIn(
  long*  plMarkIn
);

Parameters

plMarkIn

[out] Pointer to a long containing the starting point of the stream.

Return Values

If the method succeeds, it returns S_OK.

Remarks

Use IWMEncSource::put_MarkIn to specify a starting point.

Examples

// Include libraries.

#include <windows.h>
#include <atlbase.h>   //Contains CComBSTR and CComVariant
#include "wmencode.h"

// Declare variables.

    HRESULT hr;
    IWMEncoder* pEncoder;
    IWMEncSourceGroupCollection* pSrcGrpColl;
    IWMEncSourceGroup* pSrcGrp;
    IWMEncSource* pAudSrc;
    IWMEncSource* pVidSrc;
    IWMEncProfileCollection* pProColl;
    IWMEncProfile* pPro;

    long lCount;
    int i;

// Initialize the COM library and retrieve a pointer
// to an IWMEncoder interface.

    hr = CoInitialize(NULL);
    CoCreateInstance(CLSID_WMEncoder,
                     NULL,
                     CLSCTX_INPROC_SERVER,
                     IID_IWMEncoder,
                     (void**) &pEncoder);

// Retrieve a pointer to an IWMEncSourceGroupCollection
// interface.

    hr = pEncoder->get_SourceGroupCollection(&pSrcGrpColl);

// Add a new source group to the collection.

    hr = pSrcGrpColl->Add(L"SG_1", &pSrcGrp);

// Add an audio and video stream to the source group.

    hr = pSrcGrp->AddSource(WMENC_AUDIO, &pAudSrc);
    hr = pSrcGrp->AddSource(WMENC_VIDEO, &pVidSrc);

// Loop through the profile collection and retrieve a specific
// profile.

    hr = pEncoder->get_ProfileCollection(&pProColl);
    CComBSTR bstrName = NULL;
    CComVariant varProfile;
    varProfile.vt = VT_DISPATCH;
    hr = pProColl->get_Count(&lCount);
    for (i=0; i<lCount; i++)
    {
        hr = pProColl->Item(i, &pPro);
        hr = pPro->get_Name(&bstrName);
        if (_wcsicmp(bstrName, L"profile name")==0)
        {
            varProfile.pdispVal = pPro;
            pSrcGrp->put_Profile(varProfile);
            break;
        }
    }

// Specify live stream capture from the installed
// audio and video cards.

    hr = pVidSrc->SetInput(L"DEVICE://Default_Video_Device");
    hr = pAudSrc->SetInput(L"DEVICE://Default_Audio_Device");

// Initialize the encoder engine.

    hr = pSrcGrp->PrepareToEncode(VARIANT_TRUE);

// Verify that the repeat property is turned off.

    hr = pVidSrc->put_Repeat(VARIANT_FALSE);
    hr = pAudSrc->put_Repeat(VARIANT_FALSE);

// Start the encoding process 10 seconds after the source
// has started, and stop the encoding process 25 seconds
// after the source has started.

    hr =pVidSrc->put_MarkIn(10);
    hr =pAudSrc->put_MarkIn(10);
    hr =pVidSrc->put_MarkOut(25);
    hr =pAudSrc->put_MarkOut(25);

See Also

  • IWMEncSource::get_MarkOut
  • IWMEncSource Interface
  • IWMEncSource::put_MarkIn
  • IWMEncSource::put_MarkOut


IWMEncSource::get_MarkOut

The get_MarkOut method retrieves the end point of a media stream, in milliseconds (ms), from the start of the original stream.

Syntax

HRESULT get_MarkOut(
  long*  plMarkOut
);

Parameters

plMarkOut

[out] Pointer to a long containing the end point of the stream.

Return Values

If the method succeeds, it returns S_OK.

Remarks

Use the IWMEncSource::put_MarkOut method to specify the end point.

Examples

// Include libraries.

#include <windows.h>
#include <atlbase.h>   //Contains CComBSTR and CComVariant
#include "wmencode.h"

// Declare variables.

    HRESULT hr;
    IWMEncoder* pEncoder;
    IWMEncSourceGroupCollection* pSrcGrpColl;
    IWMEncSourceGroup* pSrcGrp;
    IWMEncSource* pAudSrc;
    IWMEncSource* pVidSrc;
    IWMEncProfileCollection* pProColl;
    IWMEncProfile* pPro;

    long lCount;
    int i;

// Initialize the COM library and retrieve a pointer
// to an IWMEncoder interface.

    hr = CoInitialize(NULL);
    CoCreateInstance(CLSID_WMEncoder,
                     NULL,
                     CLSCTX_INPROC_SERVER,
                     IID_IWMEncoder,
                     (void**) &pEncoder);

// Retrieve a pointer to an IWMEncSourceGroupCollection
// interface.

    hr = pEncoder->get_SourceGroupCollection(&pSrcGrpColl);

// Add a new source group to the collection.

    hr = pSrcGrpColl->Add(L"SG_1", &pSrcGrp);

// Add an audio and video stream to the source group.

    hr = pSrcGrp->AddSource(WMENC_AUDIO, &pAudSrc);
    hr = pSrcGrp->AddSource(WMENC_VIDEO, &pVidSrc);

// Loop through the profile collection and retrieve a specific
// profile.

    hr = pEncoder->get_ProfileCollection(&pProColl);
    CComBSTR bstrName = NULL;
    CComVariant varProfile;
    varProfile.vt = VT_DISPATCH;
    hr = pProColl->get_Count(&lCount);
    for (i=0; i<lCount; i++)
    {
        hr = pProColl->Item(i, &pPro);
        hr = pPro->get_Name(&bstrName);
        if (_wcsicmp(bstrName, L"profile name")==0)
        {
            varProfile.pdispVal = pPro;
            pSrcGrp->put_Profile(varProfile);
            break;
        }
    }

// Specify live stream capture from the installed
// audio and video cards.

    hr = pVidSrc->SetInput(L"DEVICE://Default_Video_Device");
    hr = pAudSrc->SetInput(L"DEVICE://Default_Audio_Device");

// Initialize the encoder engine.

    hr = pSrcGrp->PrepareToEncode(VARIANT_TRUE);

// Verify that the repeat property is turned off.

    hr = pVidSrc->put_Repeat(VARIANT_FALSE);
    hr = pAudSrc->put_Repeat(VARIANT_FALSE);

// Start the encoding process 10 seconds after the source
// has started, and stop the encoding process 25 seconds
// after the source has started.

    hr =pVidSrc->put_MarkIn(10);
    hr =pAudSrc->put_MarkIn(10);
    hr =pVidSrc->put_MarkOut(25);
    hr =pAudSrc->put_MarkOut(25);

See Also

  • IWMEncSource::get_MarkIn
  • IWMEncSource Interface
  • IWMEncSource::put_MarkIn
  • IWMEncSource::put_MarkOut


IWMEncSource::get_PostviewCollection

The get_PostviewCollection method retrieves the collection of postview objects for the source stream.

Syntax

HRESULT get_PostviewCollection(
  IWMEncDataViewCollection**  ppDataViewCollection
);

Parameters

ppDataViewCollection

[out] Pointer to a pointer to a collection of postview objects.

Return Values

If the method succeeds, it returns S_OK. If it fails, it supports the IErrorInfo interface and returns an HRESULT error code.

Return code | Number | Meaning
E_POINTER | 0x80004003 | The indirect pointer to the data view collection is NULL.

Remarks

A postview is an IWMEncDataView object that renders content in a window after the content has been both compressed and decompressed. Thus, postviews more closely approximate the appearance of the output in Windows Media Player.

Example Code

// Include libraries.

#include <windows.h>
#include "wmencode.h"
#include "wmencvu.h"

// Declare variables.

    HRESULT hr;
    IWMEncoder* pEncoder;
    IWMEncDataView* pPreview;
    IWMEncDataView* pPostview;
    IWMEncDataViewCollection* pPreviewColl;
    IWMEncDataViewCollection* pPostviewColl;
    IWMEncSource* pSrcVid;

// Initialize the COM library and retrieve a pointer
// to an IWMEncoder interface.

    hr = CoInitialize(NULL);
    CoCreateInstance(CLSID_WMEncoder,
                     NULL,
                     CLSCTX_INPROC_SERVER,
                     IID_IWMEncoder,
                     (void**) &pEncoder);

// Retrieve pointers to both a preview and a postview object.

    hr = CoCreateInstance( CLSID_WMEncPreview,
                           NULL,
                           CLSCTX_INPROC_SERVER,
                           IID_IWMEncDataView,
                           (void**)&pPreview);

    hr = CoCreateInstance( CLSID_WMEncPreview,
                           NULL,
                           CLSCTX_INPROC_SERVER,
                           IID_IWMEncDataView,
                           (void**)&pPostview);

// Retrieve preview and postview collections.
// You must create a source group and a video source.

    hr = pSrcVid->get_PreviewCollection(&pPreviewColl);
    hr = pSrcVid->get_PostviewCollection(&pPostviewColl);

// Add the preview and postview objects to the preview and postview
// collections. If you set the cookies equal to -1, the encoder engine
// automatically generates a unique cookie for each object.

    long lCookiePreview = -1;
    hr = pPreviewColl->Add( pPreview, &lCookiePreview);

    long lCookiePostview = -1;
    hr = pPostviewColl->Add( pPostview, &lCookiePostview);

// Initialize the encoder engine.

    hr = pEncoder->PrepareToEncode(VARIANT_TRUE);

// Create a parent window for the preview and postview objects, and specify the
// window settings for the encoder engine. For instance, you can create
// windows by using the Win32 API function CreateWindow() and pass the
// window handles retrieved from this function to the
// SetViewSetting() method.
// Windows Media Encoder embeds the preview and postview windows in the
// parent windows. If you do not create parent windows, and do not
// specify the display settings, Windows Media Encoder creates a
//default window for the preview.

    HWND m_hWndPreview, m_hWndPostview;
    hr = pPreview->SetViewSetting((DWORD)lCookiePreview,
                                  sizeof(m_hWndPreview),
                                  (BYTE*)&m_hWndPreview);
    hr = pPostview->SetViewSetting((DWORD)lCookiePostview,
                                  sizeof(m_hWndPostview),
                                  (BYTE*)&m_hWndPostview);

// Start the encoder engine.

    hr = pEncoder->Start();

// Start previewing and postviewing the stream.

    hr = pPreview->Start((DWORD) lCookiePreview);
    hr = pPreview->Start((DWORD) lCookiePostview);

See Also

  • IWMEncSource Interface


IWMEncSource::get_PreviewCollection

The get_PreviewCollection method retrieves the collection of preview objects for the source stream.

Syntax

HRESULT get_PreviewCollection(
  IWMEncDataViewCollection**  ppDataViewCollection
);

Parameters

ppDataViewCollection

[out] Pointer to a pointer to a collection of preview objects.

Return Values

If the method succeeds, it returns S_OK. If it fails, it supports the IErrorInfo interface and returns an HRESULT error code.

Return code | Number | Meaning
E_POINTER | 0x80004003 | The indirect pointer to the data view collection is NULL.

Remarks

A preview is an IWMEncDataview object that renders content in a window before compression.

Example Code

// Include libraries.

#include <windows.h>
#include "wmencode.h"
#include "wmencvu.h"

// Declare variables.

    HRESULT hr;
    IWMEncoder* pEncoder;
    IWMEncDataView* pPreview;
    IWMEncDataView* pPostview;
    IWMEncDataViewCollection* pPreviewColl;
    IWMEncDataViewCollection* pPostviewColl;
    IWMEncSource* pSrcVid;

// Initialize the COM library and retrieve a pointer
// to an IWMEncoder interface.

    hr = CoInitialize(NULL);
    CoCreateInstance(CLSID_WMEncoder,
                     NULL,
                     CLSCTX_INPROC_SERVER,
                     IID_IWMEncoder,
                     (void**) &pEncoder);

// Retrieve pointers to both a preview and a postview object.

    hr = CoCreateInstance( CLSID_WMEncPreview,
                           NULL,
                           CLSCTX_INPROC_SERVER,
                           IID_IWMEncDataView,
                           (void**)&pPreview);

    hr = CoCreateInstance( CLSID_WMEncPreview,
                           NULL,
                           CLSCTX_INPROC_SERVER,
                           IID_IWMEncDataView,
                           (void**)&pPostview);

// Retrieve preview and postview collections.
// You must create a source group and a video source.

    hr = pSrcVid->get_PreviewCollection(&pPreviewColl);
    hr = pSrcVid->get_PostviewCollection(&pPostviewColl);

// Add the preview and postview objects to the preview and postview
// collections. If you set the cookies equal to -1, the encoder engine
// automatically generates a unique cookie for each object.

    long lCookiePreview = -1;
    hr = pPreviewColl->Add( pPreview, &lCookiePreview);

   long lCookiePostview = -1;
    hr = pPostviewColl->Add( pPostview, &lCookiePostview);

// Initialize the encoder engine.

    hr = pEncoder->PrepareToEncode(VARIANT_TRUE);

// Create a parent window for the preview and postview objects, and specify the
// window settings for the encoder engine. For instance, you can create
// windows by using the Win32 API function CreateWindow() and pass the
// window handles retrieved from this function to the
// SetViewSetting() method.
// Windows Media Encoder embeds the preview and postview windows in the
// parent windows. If you do not create parent windows, and do not
// specify the display settings, Windows Media Encoder creates a
//default window for the preview.

    HWND m_hWndPreview, m_hWndPostview;
    hr = pPreview->SetViewSetting((DWORD)lCookiePreview,
                                  sizeof(m_hWndPreview),
                                  (BYTE*)&m_hWndPreview);
    hr = pPostview->SetViewSetting((DWORD)lCookiePostview,
                                  sizeof(m_hWndPostview),
                                  (BYTE*)&m_hWndPostview);

// Start the encoder engine.

    hr = pEncoder->Start();

// Start previewing and postviewing the stream.

    hr = pPreview->Start((DWORD) lCookiePreview);
    hr = pPreview->Start((DWORD) lCookiePostview);

See Also

  • IWMEncSource Interface


IWMEncSource::get_Repeat

The get_Repeat method retrieves the repeat property of a stream.

Syntax

HRESULT get_Repeat(
  VARIANT_BOOL*  pbRepeat
);

Parameters

pbRepeat

[out] Pointer to a VARIANT_BOOL indicating whether the stream repeat property is set.

Return Values

If the method succeeds, it returns S_OK.

Remarks

Use the IWMEncSource::put_Repeat method to specify the repeat property. Set this property to VARIANT_TRUE to repeatedly capture input from the same source.

Examples

// Include libraries.

#include <windows.h>
#include <atlbase.h>   //Contains CComBSTR and CComVariant
#include "wmencode.h"

// Declare variables.

    HRESULT hr;
    IWMEncoder* pEncoder;
    IWMEncSourceGroupCollection* pSrcGrpColl;
    IWMEncSourceGroup* pSrcGrp;
    IWMEncSource* pAudSrc;
    IWMEncSource* pVidSrc;
    IWMEncProfileCollection* pProColl;
    IWMEncProfile* pPro;

    long lCount;
    int i;

// Initialize the COM library and retrieve a pointer
// to an IWMEncoder interface.

    hr = CoInitialize(NULL);
    CoCreateInstance(CLSID_WMEncoder,
                     NULL,
                     CLSCTX_INPROC_SERVER,
                     IID_IWMEncoder,
                     (void**) &pEncoder);

// Retrieve a pointer to an IWMEncSourceGroupCollection
// interface.

    hr = pEncoder->get_SourceGroupCollection(&pSrcGrpColl);

// Add a new source group to the collection.

    hr = pSrcGrpColl->Add(L"SG_1", &pSrcGrp);

// Add an audio and video stream to the source group.

    hr = pSrcGrp->AddSource(WMENC_AUDIO, &pAudSrc);
    hr = pSrcGrp->AddSource(WMENC_VIDEO, &pVidSrc);

// Loop through the profile collection and retrieve a specific
// profile.

    hr = pEncoder->get_ProfileCollection(&pProColl);
    CComBSTR bstrName = NULL;
    CComVariant varProfile;
    varProfile.vt = VT_DISPATCH;
    hr = pProColl->get_Count(&lCount);
    for (i=0; i<lCount; i++)
    {
        hr = pProColl->Item(i, &pPro);
        hr = pPro->get_Name(&bstrName);
        if (_wcsicmp(bstrName, L"profile name")==0)
        {
            varProfile.pdispVal = pPro;
            pSrcGrp->put_Profile(varProfile);
            break;
        }
    }

// Specify live stream capture from the installed
// audio and video cards.

    hr = pVidSrc->SetInput(L"DEVICE://Default_Video_Device");
    hr = pAudSrc->SetInput(L"DEVICE://Default_Audio_Device");

// Initialize the encoder engine.

    hr = pSrcGrp->PrepareToEncode(VARIANT_TRUE);

// Verify that the repeat property is turned off.

    hr = pVidSrc->put_Repeat(VARIANT_FALSE);
    hr = pAudSrc->put_Repeat(VARIANT_FALSE);

// Start the encoding process 10 seconds after the source
// has started, and stop the encoding process 25 seconds
// after the source has started.

    hr =pVidSrc->put_MarkIn(10);
    hr =pAudSrc->put_MarkIn(10);
    hr =pVidSrc->put_MarkOut(25);
    hr =pAudSrc->put_MarkOut(25);

See Also

  • IWMEncSource Interface
  • IWMEncSource::put_Repeat


IWMEncSource::GetSourcePlugin

The GetSourcePlugin method retrieves the source plug-in associated with the source stream.

Syntax

HRESULT GetSourcePlugin(
  IUnknown**  ppUnkPlugin
);

Parameters

ppUnkPlugin

[out] Pointer to a pointer to the source plug-in object.

Return Values

If the method succeeds, it returns S_OK.

Remarks

Use the IWMEncSource::SetInput method to specify the plug-in to be associated with a source stream. Windows Media Encoder creates the plug-in object when the IWMEncoder::PrepareToEncode method is called.

Examples

// Include libraries.

#include <windows.h>
#include <atlbase.h>   //Contains CComBSTR and CComVariant
#include "wmencode.h"

// Declare variables.

    HRESULT hr;
    IWMEncoder* pEncoder;
    IWMEncSourceGroupCollection* pSrcGrpColl;
    IWMEncSourceGroup* pSrcGrp;
    IWMEncSource* pAudSrc;
    IWMEncSource* pVidSrc;
    IWMEncProfileCollection* pProColl;
    IWMEncProfile* pPro;

    long lCount;
    int i;

// Initialize the COM library and retrieve a pointer
// to an IWMEncoder interface.

    hr = CoInitialize(NULL);
    CoCreateInstance(CLSID_WMEncoder,
                     NULL,
                     CLSCTX_INPROC_SERVER,
                     IID_IWMEncoder,
                     (void**) &pEncoder);

// Retrieve a pointer to an IWMEncSourceGroupCollection
// interface.

    hr = pEncoder->get_SourceGroupCollection(&pSrcGrpColl);

// Add a new source group to the collection.

    hr = pSrcGrpColl->Add(L"SG_1", &pSrcGrp);

// Add an audio and video stream to the source group.

    hr = pSrcGrp->AddSource(WMENC_AUDIO, &pAudSrc);
    hr = pSrcGrp->AddSource(WMENC_VIDEO, &pVidSrc);

// Loop through the profile collection and retrieve a specific
// profile.

    hr = pEncoder->get_ProfileCollection(&pProColl);
    CComBSTR bstrName = NULL;
    CComVariant varProfile;
    varProfile.vt = VT_DISPATCH;
    hr = pProColl->get_Count(&lCount);
    for (i=0; i<lCount; i++)
    {
        hr = pProColl->Item(i, &pPro);
        hr = pPro->get_Name(&bstrName);
        if (_wcsicmp(bstrName, L"profile name")==0)
        {
            varProfile.pdispVal = pPro;
            pSrcGrp->put_Profile(varProfile);
            break;
        }
    }

// Specify live stream capture from the installed
// audio and video cards.

    hr = pVidSrc->SetInput(L"DEVICE://Default_Video_Device");
    hr = pAudSrc->SetInput(L"DEVICE://Default_Audio_Device");

// Initialize the encoder engine.

    hr = pSrcGrp->PrepareToEncode(VARIANT_TRUE);

// Verify that the repeat property is turned off.

    hr = pVidSrc->put_Repeat(VARIANT_FALSE);
    hr = pAudSrc->put_Repeat(VARIANT_FALSE);

// Start the encoding process 10 seconds after the source
// has started, and stop the encoding process 25 seconds
// after the source has started.

    hr =pVidSrc->put_MarkIn(10);
    hr =pAudSrc->put_MarkIn(10);
    hr =pVidSrc->put_MarkOut(25);
    hr =pAudSrc->put_MarkOut(25);

See Also

  • IWMEncoder::PrepareToEncode
  • IWMEncSource Interface
  • IWMEncSource::SetInput


IWMEncSource::get_TransformCollection

The get_TransformCollection method retrieves a collection of transform plug-ins.

Syntax

HRESULT get_TransformCollection(
  IWMEncTransformCollection**  ppTransformCollection
);

Parameters

ppTransformCollection

[out] Pointer to a pointer to a transform collection object.

Return Values

If the method succeeds, it returns S_OK. If it fails, it returns an HRESULT error code.

Return code | Number | Meaning
E_POINTER | 0x80004003 | The indirect pointer to the transform collection object is NULL.

Remarks

The current release of the Windows Media Encoder SDK does not contain source level transform plug-ins. Therefore, this method will return NULL.

See Also

  • IWMEncSource Interface


IWMEncSource::GetTransformPlugin

The GetTransformPlugin method retrieves a specific transform plug-in, by index, for the source stream.

Syntax

HRESULT GetTransformPlugin(
  DWORD  dwIndex,
  IUnknown**  ppUnkTransformPlugin
);

Parameters

dwIndex

[in] DWORD containing the zero-based index of the plug-in.

ppUnkTransformPlugin

[out] Pointer to a pointer to a transform plug-in object.

Return Values

If the method succeeds, it returns S_OK. If it fails, it returns an error code.

Return code | Number | Meaning
E_INVALIDARG | 0x80070057 | The plug-in index is not valid.
E_POINTER | 0x80004003 | The indirect pointer to the transform plug-in object is NULL.
NS_E_INVALID_INDEX | 0xC00D1B66 | No plug-in corresponds to the index.

Remarks

The current release of the Windows Media Encoder SDK does not contain source level transform plug-ins. Therefore, this method will return NULL.

See Also

  • IWMEncSource Interface


IWMEncSource::GetTransformPluginCount

The GetTransformPluginCount method retrieves the number of transform plug-ins that can be applied to the source stream.

Syntax

HRESULT GetTransformPluginCount(
  DWORD*  pdwCount
);

Parameters

pdwCount

[out] Pointer to a DWORD containing the plug-in count.

Return Values

If the method succeeds, it returns S_OK. If it fails, it returns an HRESULT error code.

Return code | Number | Meaning
E_POINTER | 0x80004003 | The pointer to the count is NULL.

Remarks

The current release of the Windows Media Encoder SDK does not contain source level transform plug-ins. Therefore, this method will return zero (0).

See Also

  • IWMEncSource::GetTransformPlugin
  • IWMEncSource Interface


IWMEncSource::get_Type

The get_Type method retrieves the media stream type.

Syntax

HRESULT get_Type(
  WMENC_SOURCE_TYPE*  enumType
);

Parameters

enumType

[out] Member of a WMENC_SOURCE_TYPE enumeration type identifying the media type of the source stream. This must be one of the following values.

Value | Number | Meaning
WMENC_AUDIO | 1 | Identifies an audio stream.
WMENC_VIDEO | 2 | Identifies a video stream.
WMENC_SCRIPT | 4 | Identifies a text stream.

Return Values

If the method succeeds, it returns S_OK. If it fails, it returns E_FAIL.

Examples

// Include libraries.

#include <windows.h>
#include <atlbase.h>   //Contains CComBSTR and CComVariant
#include "wmencode.h"

// Declare variables.

    HRESULT hr;
    IWMEncoder* pEncoder;
    IWMEncSourceGroupCollection* pSrcGrpColl;
    IWMEncSourceGroup* pSrcGrp;
    IWMEncSource* pAudSrc;
    IWMEncSource* pVidSrc;
    IWMEncProfileCollection* pProColl;
    IWMEncProfile* pPro;

    long lCount;
    int i;

// Initialize the COM library and retrieve a pointer
// to an IWMEncoder interface.

    hr = CoInitialize(NULL);
    CoCreateInstance(CLSID_WMEncoder,
                     NULL,
                     CLSCTX_INPROC_SERVER,
                     IID_IWMEncoder,
                     (void**) &pEncoder);

// Retrieve a pointer to an IWMEncSourceGroupCollection
// interface.

    hr = pEncoder->get_SourceGroupCollection(&pSrcGrpColl);

// Add a new source group to the collection.

    hr = pSrcGrpColl->Add(L"SG_1", &pSrcGrp);

// Add an audio and video stream to the source group.

    hr = pSrcGrp->AddSource(WMENC_AUDIO, &pAudSrc);
    hr = pSrcGrp->AddSource(WMENC_VIDEO, &pVidSrc);

// Loop through the profile collection and retrieve a specific
// profile.

    hr = pEncoder->get_ProfileCollection(&pProColl);
    CComBSTR bstrName = NULL;
    CComVariant varProfile;
    varProfile.vt = VT_DISPATCH;
    hr = pProColl->get_Count(&lCount);
    for (i=0; i<lCount; i++)
    {
        hr = pProColl->Item(i, &pPro);
        hr = pPro->get_Name(&bstrName);
        if (_wcsicmp(bstrName, L"profile name")==0)
        {
            varProfile.pdispVal = pPro;
            pSrcGrp->put_Profile(varProfile);
            break;
        }
    }

// Specify live stream capture from the installed
// audio and video cards.

    hr = pVidSrc->SetInput(L"DEVICE://Default_Video_Device");
    hr = pAudSrc->SetInput(L"DEVICE://Default_Audio_Device");

// Initialize the encoder engine.

    hr = pSrcGrp->PrepareToEncode(VARIANT_TRUE);

// Verify that the repeat property is turned off.

    hr = pVidSrc->put_Repeat(VARIANT_FALSE);
    hr = pAudSrc->put_Repeat(VARIANT_FALSE);

// Start the encoding process 10 seconds after the source
// has started, and stop the encoding process 25 seconds
// after the source has started.

    hr =pVidSrc->put_MarkIn(10);
    hr =pAudSrc->put_MarkIn(10);
    hr =pVidSrc->put_MarkOut(25);
    hr =pAudSrc->put_MarkOut(25);

See Also

  • IWMEncSource Interface


IWMEncSource::put_MarkIn

The put_MarkIn method assigns the starting point of a media stream, in milliseconds (ms), from the start of the original stream.

Syntax

HRESULT put_MarkIn(
  long  lMarkIn
);

Parameters

lMarkIn

[in] long containing the the entry point into the stream.

Return Values

If the method succeeds, it returns S_OK. If it fails, it returns an HRESULT error code.

Return code | Number | Meaning
NS_E_BAD_MARKIN | 0xC00D1B58 | The specified starting point is less than 0 or greater than the end point.
NS_E_INVALIDCALL_WHILE_ENCODER_RUNNING | 0xC00D0011 | This method cannot be called if the encoder engine is running.
NS_E_INVALID_REQUEST | 0xC00D002B | You must index the Windows Media file before calling this method.

Remarks

The put_MarkIn method specifies the starting point of a stream in milliseconds (ms) from the start of the original stream. Use IWMEncSource::get_MarkIn to retrieve the starting point.

Examples

// Include libraries.

#include <windows.h>
#include <atlbase.h>   //Contains CComBSTR and CComVariant
#include "wmencode.h"

// Declare variables.

    HRESULT hr;
    IWMEncoder* pEncoder;
    IWMEncSourceGroupCollection* pSrcGrpColl;
    IWMEncSourceGroup* pSrcGrp;
    IWMEncSource* pAudSrc;
    IWMEncSource* pVidSrc;
    IWMEncProfileCollection* pProColl;
    IWMEncProfile* pPro;

    long lCount;
    int i;

// Initialize the COM library and retrieve a pointer
// to an IWMEncoder interface.

    hr = CoInitialize(NULL);
    CoCreateInstance(CLSID_WMEncoder,
                     NULL,
                     CLSCTX_INPROC_SERVER,
                     IID_IWMEncoder,
                     (void**) &pEncoder);

// Retrieve a pointer to an IWMEncSourceGroupCollection
// interface.

    hr = pEncoder->get_SourceGroupCollection(&pSrcGrpColl);

// Add a new source group to the collection.

    hr = pSrcGrpColl->Add(L"SG_1", &pSrcGrp);

// Add an audio and video stream to the source group.

    hr = pSrcGrp->AddSource(WMENC_AUDIO, &pAudSrc);
    hr = pSrcGrp->AddSource(WMENC_VIDEO, &pVidSrc);

// Loop through the profile collection and retrieve a specific
// profile.

    hr = pEncoder->get_ProfileCollection(&pProColl);
    CComBSTR bstrName = NULL;
    CComVariant varProfile;
    varProfile.vt = VT_DISPATCH;
    hr = pProColl->get_Count(&lCount);
    for (i=0; i<lCount; i++)
    {
        hr = pProColl->Item(i, &pPro);
        hr = pPro->get_Name(&bstrName);
        if (_wcsicmp(bstrName, L"profile name")==0)
        {
            varProfile.pdispVal = pPro;
            pSrcGrp->put_Profile(varProfile);
            break;
        }
    }

// Specify live stream capture from the installed
// audio and video cards.

    hr = pVidSrc->SetInput(L"DEVICE://Default_Video_Device");
    hr = pAudSrc->SetInput(L"DEVICE://Default_Audio_Device");

// Initialize the encoder engine.

    hr = pSrcGrp->PrepareToEncode(VARIANT_TRUE);

// Verify that the repeat property is turned off.

    hr = pVidSrc->put_Repeat(VARIANT_FALSE);
    hr = pAudSrc->put_Repeat(VARIANT_FALSE);

// Start the encoding process 10 seconds after the source
// has started, and stop the encoding process 25 seconds
// after the source has started.

    hr =pVidSrc->put_MarkIn(10);
    hr =pAudSrc->put_MarkIn(10);
    hr =pVidSrc->put_MarkOut(25);
    hr =pAudSrc->put_MarkOut(25);

See Also

  • IWMEncSource::get_MarkIn
  • IWMEncSource::get_MarkOut
  • IWMEncSource Interface
  • IWMEncSource::put_MarkOut


IWMEncSource::put_MarkOut

The put_MarkOut method specifies the end point of a media stream, in milliseconds (ms), from the start of the original stream.

Syntax

HRESULT put_MarkOut(
  long  lMarkOut
);

Parameters

lMarkOut

[in] long containing the end point of a stream.

Return Values

If the method succeeds, it returns S_OK. If it fails, it returns an HRESULT error code.

Return code | Number | Meaning
NS_E_BAD_MARKOUT | 0xC00D1B59 | The specified ending point is either less than 0 or less than the starting point.
NS_E_INVALIDCALL_WHILE_ENCODER_RUNNING | 0xC00D0011 | This method cannot be called if the encoder engine is running.
NS_E_INVALID_REQUEST | 0xC00D002B | You must index the Windows Media file before calling this method.

Remarks

Use the IWMEncSource::get_MarkOut method to retrieve the end point.

Examples

// Include libraries.

#include <windows.h>
#include <atlbase.h>   //Contains CComBSTR and CComVariant
#include "wmencode.h"

// Declare variables.

    HRESULT hr;
    IWMEncoder* pEncoder;
    IWMEncSourceGroupCollection* pSrcGrpColl;
    IWMEncSourceGroup* pSrcGrp;
    IWMEncSource* pAudSrc;
    IWMEncSource* pVidSrc;
    IWMEncProfileCollection* pProColl;
    IWMEncProfile* pPro;

    long lCount;
    int i;

// Initialize the COM library and retrieve a pointer
// to an IWMEncoder interface.

    hr = CoInitialize(NULL);
    CoCreateInstance(CLSID_WMEncoder,
                     NULL,
                     CLSCTX_INPROC_SERVER,
                     IID_IWMEncoder,
                     (void**) &pEncoder);

// Retrieve a pointer to an IWMEncSourceGroupCollection
// interface.

    hr = pEncoder->get_SourceGroupCollection(&pSrcGrpColl);

// Add a new source group to the collection.

    hr = pSrcGrpColl->Add(L"SG_1", &pSrcGrp);

// Add an audio and video stream to the source group.

    hr = pSrcGrp->AddSource(WMENC_AUDIO, &pAudSrc);
    hr = pSrcGrp->AddSource(WMENC_VIDEO, &pVidSrc);

// Loop through the profile collection and retrieve a specific
// profile.

    hr = pEncoder->get_ProfileCollection(&pProColl);
    CComBSTR bstrName = NULL;
    CComVariant varProfile;
    varProfile.vt = VT_DISPATCH;
    hr = pProColl->get_Count(&lCount);
    for (i=0; i<lCount; i++)
    {
        hr = pProColl->Item(i, &pPro);
        hr = pPro->get_Name(&bstrName);
        if (_wcsicmp(bstrName, L"profile name")==0)
        {
            varProfile.pdispVal = pPro;
            pSrcGrp->put_Profile(varProfile);
            break;
        }
    }

// Specify live stream capture from the installed
// audio and video cards.

    hr = pVidSrc->SetInput(L"DEVICE://Default_Video_Device");
    hr = pAudSrc->SetInput(L"DEVICE://Default_Audio_Device");

// Initialize the encoder engine.

    hr = pSrcGrp->PrepareToEncode(VARIANT_TRUE);

// Verify that the repeat property is turned off.

    hr = pVidSrc->put_Repeat(VARIANT_FALSE);
    hr = pAudSrc->put_Repeat(VARIANT_FALSE);

// Start the encoding process 10 seconds after the source
// has started, and stop the encoding process 25 seconds
// after the source has started.

    hr =pVidSrc->put_MarkIn(10);
    hr =pAudSrc->put_MarkIn(10);
    hr =pVidSrc->put_MarkOut(25);
    hr =pAudSrc->put_MarkOut(25);

See Also

  • IWMEncSource::get_MarkOut
  • IWMEncSource Interface
  • IWMEncSource::put_MarkIn


IWMEncSource::put_Repeat

The put_Repeat method specifies the repeat property of a stream.

Syntax

HRESULT put_Repeat(
  VARIANT_BOOL  bRepeat
);

Parameters

bRepeat

[in] VARIANT_BOOL that sets the repeat property of a stream.

Return Values

If the method succeeds, it returns S_OK. If it fails, it returns an HRESULT error code.

Return code | Number | Meaning
NS_E_INVALIDCALL_WHILE_ENCODER_RUNNING | 0xC00D0011 | This method cannot be called if the encoder engine is running.

Remarks

Set this property to VARIANT_TRUE to repeatedly capture input from the same source. Use the IWMEncSource::get_Repeat method to retrieve the repeat property.

Examples

// Include libraries.

#include <windows.h>
#include <atlbase.h>   //Contains CComBSTR and CComVariant
#include "wmencode.h"

// Declare variables.

    HRESULT hr;
    IWMEncoder* pEncoder;
    IWMEncSourceGroupCollection* pSrcGrpColl;
    IWMEncSourceGroup* pSrcGrp;
    IWMEncSource* pAudSrc;
    IWMEncSource* pVidSrc;
    IWMEncProfileCollection* pProColl;
    IWMEncProfile* pPro;

    long lCount;
    int i;

// Initialize the COM library and retrieve a pointer
// to an IWMEncoder interface.

    hr = CoInitialize(NULL);
    CoCreateInstance(CLSID_WMEncoder,
                     NULL,
                     CLSCTX_INPROC_SERVER,
                     IID_IWMEncoder,
                     (void**) &pEncoder);

// Retrieve a pointer to an IWMEncSourceGroupCollection
// interface.

    hr = pEncoder->get_SourceGroupCollection(&pSrcGrpColl);

// Add a new source group to the collection.

    hr = pSrcGrpColl->Add(L"SG_1", &pSrcGrp);

// Add an audio and video stream to the source group.

    hr = pSrcGrp->AddSource(WMENC_AUDIO, &pAudSrc);
    hr = pSrcGrp->AddSource(WMENC_VIDEO, &pVidSrc);

// Loop through the profile collection and retrieve a specific
// profile.

    hr = pEncoder->get_ProfileCollection(&pProColl);
    CComBSTR bstrName = NULL;
    CComVariant varProfile;
    varProfile.vt = VT_DISPATCH;
    hr = pProColl->get_Count(&lCount);
    for (i=0; i<lCount; i++)
    {
        hr = pProColl->Item(i, &pPro);
        hr = pPro->get_Name(&bstrName);
        if (_wcsicmp(bstrName, L"profile name")==0)
        {
            varProfile.pdispVal = pPro;
            pSrcGrp->put_Profile(varProfile);
            break;
        }
    }

// Specify live stream capture from the installed
// audio and video cards.

    hr = pVidSrc->SetInput(L"DEVICE://Default_Video_Device");
    hr = pAudSrc->SetInput(L"DEVICE://Default_Audio_Device");

// Initialize the encoder engine.

    hr = pSrcGrp->PrepareToEncode(VARIANT_TRUE);

// Verify that the repeat property is turned off.

    hr = pVidSrc->put_Repeat(VARIANT_FALSE);
    hr = pAudSrc->put_Repeat(VARIANT_FALSE);

// Start the encoding process 10 seconds after the source
// has started, and stop the encoding process 25 seconds
// after the source has started.

    hr =pVidSrc->put_MarkIn(10);
    hr =pAudSrc->put_MarkIn(10);
    hr =pVidSrc->put_MarkOut(25);
    hr =pAudSrc->put_MarkOut(25);

See Also

  • IWMEncSource::get_Repeat
  • IWMEncSource Interface


IWMEncSource::SetInput

The SetInput method specifies the stream capture source.

Syntax

HRESULT SetInput(
  BSTR  bstrInput,
  BSTR  bstrScheme,
  BSTR  bstrStreamName
);

Parameters

pbstrInput

[in] BSTR containing the full name of a plug-in or file from which the source stream is captured. Specify a plug-in name in the "scheme://resource" format. If you put only the "resource" in bstrInput, and not the full path, Windows Media Encoder examines pbstrScheme to find the scheme type.

pbstrScheme

[in] BSTR containing the scheme type. If you supply a value for this parameter, Windows Media Encoder examines bstrInput to form a "scheme://resource" plug-in identifier without parsing the stream. This is useful if the "resource" part of the string contains special characters or symbols that cannot be interpreted as part of a standard URL.

pbstrStreamName

[in] BSTR containing the name of a stream. Use this parameter to identify specific information for a plug-in object. In the current version of Windows Media Encoder, this parameter is not used.

Return Values

If the method succeeds, it returns S_OK. If it fails, it returns an HRESULT error code.

Return code | Number | Meaning
NS_E_INVALIDCALL_WHILE_ENCODER_RUNNING | 0xC00D0011 | This method cannot be called if the encoder engine is running.

Examples

// Include libraries.

#include <windows.h>
#include <atlbase.h>   //Contains CComBSTR and CComVariant
#include "wmencode.h"

// Declare variables.

    HRESULT hr;
    IWMEncoder* pEncoder;
    IWMEncSourceGroupCollection* pSrcGrpColl;
    IWMEncSourceGroup* pSrcGrp;
    IWMEncSource* pAudSrc;
    IWMEncSource* pVidSrc;
    IWMEncProfileCollection* pProColl;
    IWMEncProfile* pPro;

    long lCount;
    int i;

// Initialize the COM library and retrieve a pointer
// to an IWMEncoder interface.

    hr = CoInitialize(NULL);
    CoCreateInstance(CLSID_WMEncoder,
                     NULL,
                     CLSCTX_INPROC_SERVER,
                     IID_IWMEncoder,
                     (void**) &pEncoder);

// Retrieve a pointer to an IWMEncSourceGroupCollection
// interface.

    hr = pEncoder->get_SourceGroupCollection(&pSrcGrpColl);

// Add a new source group to the collection.

    hr = pSrcGrpColl->Add(L"SG_1", &pSrcGrp);

// Add an audio and video stream to the source group.

    hr = pSrcGrp->AddSource(WMENC_AUDIO, &pAudSrc);
    hr = pSrcGrp->AddSource(WMENC_VIDEO, &pVidSrc);

// Loop through the profile collection and retrieve a specific
// profile.

    hr = pEncoder->get_ProfileCollection(&pProColl);
    CComBSTR bstrName = NULL;
    CComVariant varProfile;
    varProfile.vt = VT_DISPATCH;
    hr = pProColl->get_Count(&lCount);
    for (i=0; i<lCount; i++)
    {
        hr = pProColl->Item(i, &pPro);
        hr = pPro->get_Name(&bstrName);
        if (_wcsicmp(bstrName, L"profile name")==0)
        {
            varProfile.pdispVal = pPro;
            pSrcGrp->put_Profile(varProfile);
            break;
        }
    }

// Specify live stream capture from the installed
// audio and video cards.

    hr = pVidSrc->SetInput(L"DEVICE://Default_Video_Device");
    hr = pAudSrc->SetInput(L"DEVICE://Default_Audio_Device");

// Initialize the encoder engine.

    hr = pSrcGrp->PrepareToEncode(VARIANT_TRUE);

// Verify that the repeat property is turned off.

    hr = pVidSrc->put_Repeat(VARIANT_FALSE);
    hr = pAudSrc->put_Repeat(VARIANT_FALSE);

// Start the encoding process 10 seconds after the source
// has started, and stop the encoding process 25 seconds
// after the source has started.

    hr =pVidSrc->put_MarkIn(10);
    hr =pAudSrc->put_MarkIn(10);
    hr =pVidSrc->put_MarkOut(25);
    hr =pAudSrc->put_MarkOut(25);

See Also

  • IWMEncSource::GetInput
  • IWMEncSource Interface


IWMEncSourceGroup Interface

The IWMEncSourceGroup interface manages a source group of media streams. Currently, a source group can contain no more than one audio, one script and one video stream. Only one source group can be encoded at a time, and a source group can be associated with only one profile.

In addition to the methods inherited from IDispatch, the IWMEncSourceGroup interface exposes the following methods.

Method | Description
AddSource | Adds a media stream to the source group.
AutoSetFileSource | Automatically parses a multimedia file and adds up to one audio and one video stream from that file to the source group.
get_AutoArchive | Retrieves an enumeration type that indicates the nature of the archiving operation if IWMEncoder::put_EnableAutoArchive is set to VARIANT_TRUE.
get_GroupTransformCollection | Retrieves a collection of transform plug-ins for the source group.
GetGroupTransformPlugin | Retrieves a specific group level transform plug-in.
GetGroupTransformPluginCount | Retrieves the number of transform plug-ins that can be applied to the source group.
get_Name | Retrieves the name of the source group.
get_Profile | Retrieves a profile for the source group.
get_Source | Retrieves a specific media stream from the source group.
get_SourceCount | Retrieves the number of streams of a specific type in the source group. Currently, this cannot exceed one.
PrepareToEncode | Creates an encoding session and initializes Windows Media Encoder.
put_AutoArchive | Specifies an enumeration type that indicates the nature of the archiving operation if IWMEncoder::put_EnableAutoArchive is set to VARIANT_TRUE.
put_Name | Specifies a name for the source group.
put_Profile | Associates a specific profile with the source group.
RemoveSource | Removes a media stream from the source group.

See Also

  • [Visual Basic] IWMEncSourceGroup Object
  • Interfaces (C++)


IWMEncSourceGroup::AddSource

The AddSource method adds a media stream to the source group.

Syntax

HRESULT AddSource(
  WMENC_SOURCE_TYPE  enumType,
  IWMEncSource**  ppSource
);

Parameters

enumType

[in] Member of a WMENC_SOURCE_TYPE enumeration type identifying the type of the media stream being added. This must be one of the following values.

Value | Number | Meaning
WMENC_AUDIO | 1 | The source being added is an audio stream.
WMENC_VIDEO | 2 | The source being added is a video stream.
WMENC_SCRIPT | 4 | The source being added is a script stream.

ppSource

[out] Pointer to a pointer to a IWMEncSource interface.

Return Values

If the method succeeds, it returns S_OK. If it fails, it supports the IErrorInfo interface and returns an HRESULT error code.

Return code | Number | Meaning
E_POINTER | 0x80004003 | The indirect pointer to the source object is NULL.
E_OUTOFMEMORY | 0x8007000E | Memory cannot be allocated
NS_E_INVALIDCALL_WHILE_ENCODER_RUNNING | 0xC00D0011 | This method cannot be called if the encoder engine is running.
NS_E_UNSUPPORTED_SOURCETYPE | 0xC00D1B5B | The input source type must be either audio, video, or script.

Remarks

Only one audio, one video, and one script stream can be added to a source group.

Example Code

// Include libraries.

#include <windows.h>
#include <atlbase.h>
#include "wmencode.h"

// Declare variables.

    HRESULT hr;
    IWMEncoder* pEncoder;
    IWMEncSourceGroupCollection* pSrcGrpColl;
    IWMEncSourceGroup* pSrcGrp;
    IWMEncSource* pAudSrc;
    IWMEncSource* pVidSrc;
    IWMEncProfileCollection* pProColl;
    IWMEncProfile* pPro;

    long lCount;
    short iAudCount, iVidCount;
    int i;

// Initialize the COM library and retrieve a pointer
// to an IWMEncoder interface.

    hr = CoInitialize(NULL);
    CoCreateInstance(CLSID_WMEncoder,
                     NULL,
                     CLSCTX_INPROC_SERVER,
                     IID_IWMEncoder,
                     (void**) &pEncoder);

// Retrieve a pointer to an IWMEncSourceGroupCollection
// interface.

    hr = pEncoder->get_SourceGroupCollection(&pSrcGrpColl);

// Add a new source group to the collection.

    hr = pSrcGrpColl->Add(L"SG_1", &pSrcGrp);

// Add an audio and video stream to the source group.

    hr = pSrcGrp->AddSource(WMENC_AUDIO, &pAudSrc);
    hr = pSrcGrp->AddSource(WMENC_VIDEO, &pVidSrc);

// Specify an .avi source file and a .wmv output file.

    CComBSTR bstrInFile(L"C:\\filename.avi");
    hr = pAudSrc->SetInput(bstrInFile);
    hr = pVidSrc->SetInput(bstrInFile);

// You can also use the AutoSetFileSource method to automatically
// parse a file and add the source streams to the source group.
//
//    hr = pSrcGrp->AutoSetFileSource(bstrInFile);

// Loop through the profile collection and retrieve a specific
// profile.

    hr = pEncoder->get_ProfileCollection(&pProColl);
    CComBSTR bstrName = NULL;
    CComVariant varProfile;
    varProfile.vt = VT_DISPATCH;
    hr = pProColl->get_Count(&lCount);
    for (i=0; i<lCount; i++)
    {
        hr = pProColl->Item(i, &pPro);
        hr = pPro->get_Name(&bstrName);
        if (_wcsicmp(bstrName, L"profile name")==0)
        {
            varProfile.pdispVal = pPro;
            pSrcGrp->put_Profile(varProfile);
            break;
        }
    }

// Change the name of the source group.

    CComBSTR bstrSGName(L"Music Only");
    hr = pSrcGrp->put_Name(bstrSGName);

// Retrieve the number of audio and video streams in
// the source group.

    hr = pSrcGrp->get_SourceCount(WMENC_AUDIO, &iAudCount);
    hr = pSrcGrp->get_SourceCount(WMENC_VIDEO, &iVidCount);

// Remove the video stream. In the current release of the
// Windows Media Encoder SDK, a source group can contain
// at most only one audio, one video, and one script stream.
// You must verify that the count is not zero before deleting
// the source stream.

    CComVariant varIndex;
    varIndex.vt = VT_I2;
    varIndex.iVal = 0;
    if (iVidCount != 0)
    {
        hr = pSrcGrp->RemoveSource(WMENC_VIDEO, varIndex);
    }

// Specify automatic archiving when the source group is active.

    hr = pSrcGrp->put_AutoArchive(WMENC_ARCHIVE_LOCAL,
                                  WMENC_ARCHIVE_START);

See Also

  • IWMEncSourceGroup Interface
  • IWMEncSourceGroup::RemoveSource


IWMEncSourceGroup::AutoSetFileSource

The AutoSetFileSource method automatically parses a multimedia file and adds up to one audio and one video stream from that file to the source group.

Syntax

HRESULT AutoSetFileSource(
  BSTR  bstrFileName
);

Parameters

bstrFileName

[in] BSTR containing the name of the multimedia file.

Return Values

If the method succeeds, it returns S_OK. If it fails, it supports the IErrorInfo interface and returns an HRESULT error code.

Return code | Number | Meaning
E_INVALIDARG | 0x80070057 | The string identifying the file name is NULL.
NS_E_INVALIDCALL_WHILE_ENCODER_RUNNING | 0xC00D0011 | This method cannot be called if the encoder engine is running.

Example Code

// Include libraries.

#include <windows.h>
#include <atlbase.h>
#include "wmencode.h"

// Declare variables.

    HRESULT hr;
    IWMEncoder* pEncoder;
    IWMEncSourceGroupCollection* pSrcGrpColl;
    IWMEncSourceGroup* pSrcGrp;
    IWMEncSource* pAudSrc;
    IWMEncSource* pVidSrc;
    IWMEncProfileCollection* pProColl;
    IWMEncProfile* pPro;

    long lCount;
    short iAudCount, iVidCount;
    int i;

// Initialize the COM library and retrieve a pointer
// to an IWMEncoder interface.

    hr = CoInitialize(NULL);
    CoCreateInstance(CLSID_WMEncoder,
                     NULL,
                     CLSCTX_INPROC_SERVER,
                     IID_IWMEncoder,
                     (void**) &pEncoder);

// Retrieve a pointer to an IWMEncSourceGroupCollection
// interface.

    hr = pEncoder->get_SourceGroupCollection(&pSrcGrpColl);

// Add a new source group to the collection.

    hr = pSrcGrpColl->Add(L"SG_1", &pSrcGrp);

// Add an audio and video stream to the source group.

    hr = pSrcGrp->AddSource(WMENC_AUDIO, &pAudSrc);
    hr = pSrcGrp->AddSource(WMENC_VIDEO, &pVidSrc);

// Specify an .avi source file and a .wmv output file.

    CComBSTR bstrInFile(L"C:\\filename.avi");
    hr = pAudSrc->SetInput(bstrInFile);
    hr = pVidSrc->SetInput(bstrInFile);

// You can also use the AutoSetFileSource method to automatically
// parse a file and add the source streams to the source group.
//
//    hr = pSrcGrp->AutoSetFileSource(bstrInFile);

// Loop through the profile collection and retrieve a specific
// profile.

    hr = pEncoder->get_ProfileCollection(&pProColl);
    CComBSTR bstrName = NULL;
    CComVariant varProfile;
    varProfile.vt = VT_DISPATCH;
    hr = pProColl->get_Count(&lCount);
    for (i=0; i<lCount; i++)
    {
        hr = pProColl->Item(i, &pPro);
        hr = pPro->get_Name(&bstrName);
        if (_wcsicmp(bstrName, L"profile name")==0)
        {
            varProfile.pdispVal = pPro;
            pSrcGrp->put_Profile(varProfile);
            break;
        }
    }

// Change the name of the source group.

    CComBSTR bstrSGName(L"Music Only");
    hr = pSrcGrp->put_Name(bstrSGName);

// Retrieve the number of audio and video streams in
// the source group.

    hr = pSrcGrp->get_SourceCount(WMENC_AUDIO, &iAudCount);
    hr = pSrcGrp->get_SourceCount(WMENC_VIDEO, &iVidCount);

// Remove the video stream. In the current release of the
// Windows Media Encoder SDK, a source group can contain
// at most only one audio, one video, and one script stream.
// You must verify that the count is not zero before deleting
// the source stream.

    CComVariant varIndex;
    varIndex.vt = VT_I2;
    varIndex.iVal = 0;
    if (iVidCount != 0)
    {
        hr = pSrcGrp->RemoveSource(WMENC_VIDEO, varIndex);
    }

// Specify automatic archiving when the source group is active.

    hr = pSrcGrp->put_AutoArchive(WMENC_ARCHIVE_LOCAL,
                                  WMENC_ARCHIVE_START);

See Also

  • IWMEncSourceGroup Interface


IWMEncSourceGroup::get_AutoArchive

The get_AutoArchive method retrieves an enumeration type that indicates the nature of the archiving operation if IWMEncoder::put_EnableAutoArchive is set to VARIANT_TRUE.

Syntax

HRESULT get_AutoArchive(
  WMENC_ARCHIVE_TYPE  enumArchiveType,
  WMENC_ARCHIVE_OPERATION*  penumArchiveOp
);

Parameters

enumArchiveType

[in] Member of a WMENC_ARCHIVE_TYPE enumeration type indicating where content can be archived. This must be the following value.

Value | Number | Description
WMENC_ARCHIVE_LOCAL | 1 | The encoded content can only be saved to a local destination defined as the computer on which the content was originated and the network on which that computer is located.

penumArchiveOp

[out] Member of a WMENC_ARCHIVE_OPERATION enumeration type indicating whether encoded content will be archived when the source group is made active and the encoder engine starts. This must be one of the following values.

Value | Number | Description
WMENC_ARCHIVE_START | 1 | The encoded content from the source group will be archived.
WMENC_ARCHIVE_STOP | 2 | The archiving process for the source group is stopped.
WMENC_ARCHIVE_PAUSE | 3 | The archiving process for the source group will be paused.

Return Values

If the method succeeds, it returns S_OK. If it fails, it supports the IErrorInfo interface and returns an HRESULT error code.

Return code | Number | Meaning
E_POINTER | 0x80004003 | The pointer to the operating state of the archiving process is NULL.
NS_E_UNSUPPORTED_ARCHIVETYPE | 0xC00D1B77 | You can save encoded content only to a local file.

Remarks

Use the IWMEncSourceGroup::put_AutoArchive method to selectively archive source groups. For instance, if you are encoding a static welcome screen, a live presentation and a static goodbye screen, you can utilize disk space more efficiently by only archiving the live presentation. Use the IWMEncoder::put_EnableAutoArchive property to specify whether archiving will automatically occur when the encoder engine starts. Use the IWMEncoder::Archive method to manually control the archiving process.

Example Code

// Include libraries.

#include <windows.h>
#include <atlbase.h>
#include "wmencode.h"

// Declare variables.

    HRESULT hr;
    IWMEncoder* pEncoder;
    IWMEncSourceGroupCollection* pSrcGrpColl;
    IWMEncSourceGroup* pSrcGrp;
    IWMEncSource* pAudSrc;
    IWMEncSource* pVidSrc;
    IWMEncProfileCollection* pProColl;
    IWMEncProfile* pPro;

    long lCount;
    short iAudCount, iVidCount;
    int i;

// Initialize the COM library and retrieve a pointer
// to an IWMEncoder interface.

    hr = CoInitialize(NULL);
    CoCreateInstance(CLSID_WMEncoder,
                     NULL,
                     CLSCTX_INPROC_SERVER,
                     IID_IWMEncoder,
                     (void**) &pEncoder);

// Retrieve a pointer to an IWMEncSourceGroupCollection
// interface.

    hr = pEncoder->get_SourceGroupCollection(&pSrcGrpColl);

// Add a new source group to the collection.

    hr = pSrcGrpColl->Add(L"SG_1", &pSrcGrp);

// Add an audio and video stream to the source group.

    hr = pSrcGrp->AddSource(WMENC_AUDIO, &pAudSrc);
    hr = pSrcGrp->AddSource(WMENC_VIDEO, &pVidSrc);

// Specify an .avi source file and a .wmv output file.

    CComBSTR bstrInFile(L"C:\\filename.avi");
    hr = pAudSrc->SetInput(bstrInFile);
    hr = pVidSrc->SetInput(bstrInFile);

// You can also use the AutoSetFileSource method to automatically
// parse a file and add the source streams to the source group.
//
//    hr = pSrcGrp->AutoSetFileSource(bstrInFile);

// Loop through the profile collection and retrieve a specific
// profile.

    hr = pEncoder->get_ProfileCollection(&pProColl);
    CComBSTR bstrName = NULL;
    CComVariant varProfile;
    varProfile.vt = VT_DISPATCH;
    hr = pProColl->get_Count(&lCount);
    for (i=0; i<lCount; i++)
    {
        hr = pProColl->Item(i, &pPro);
        hr = pPro->get_Name(&bstrName);
        if (_wcsicmp(bstrName, L"profile name")==0)
        {
            varProfile.pdispVal = pPro;
            pSrcGrp->put_Profile(varProfile);
            break;
        }
    }

// Change the name of the source group.

    CComBSTR bstrSGName(L"Music Only");
    hr = pSrcGrp->put_Name(bstrSGName);

// Retrieve the number of audio and video streams in
// the source group.

    hr = pSrcGrp->get_SourceCount(WMENC_AUDIO, &iAudCount);
    hr = pSrcGrp->get_SourceCount(WMENC_VIDEO, &iVidCount);

// Remove the video stream. In the current release of the
// Windows Media Encoder SDK, a source group can contain
// at most only one audio, one video, and one script stream.
// You must verify that the count is not zero before deleting
// the source stream.

    CComVariant varIndex;
    varIndex.vt = VT_I2;
    varIndex.iVal = 0;
    if (iVidCount != 0)
    {
        hr = pSrcGrp->RemoveSource(WMENC_VIDEO, varIndex);
    }

// Specify automatic archiving when the source group is active.

    hr = pSrcGrp->put_AutoArchive(WMENC_ARCHIVE_LOCAL,
                                  WMENC_ARCHIVE_START);

// Initialize the encoder engine.

See Also

  • IWMEncoder::Archive
  • IWMEncoder::put_EnableAutoArchive
  • IWMEncSourceGroup Interface
  • IWMEncSourceGroup::put_AutoArchive


IWMEncSourceGroup::get_Name

The get_Name method retrieves the name of the source group.

Syntax

HRESULT get_Name(
  BSTR*  pbstrName
);

Parameters

pbstrName

[out] Pointer to a BSTR containing the source group name.

Return Values

If the method succeeds, it returns S_OK. If it fails, it supports the IErrorInfo interface and returns an HRESULT error code.

Return code | Number | Meaning
E_POINTER | 0x80004003 | The pointer to the name is NULL.

Remarks

Use the IWMEncSourceGroup::put_Name method to specify a name for the source group.

Example Code

// Include libraries.

#include <windows.h>
#include <atlbase.h>
#include "wmencode.h"

// Declare variables.

    HRESULT hr;
    IWMEncoder* pEncoder;
    IWMEncSourceGroupCollection* pSrcGrpColl;
    IWMEncSourceGroup* pSrcGrp;
    IWMEncSource* pAudSrc;
    IWMEncSource* pVidSrc;
    IWMEncProfileCollection* pProColl;
    IWMEncProfile* pPro;

    long lCount;
    short iAudCount, iVidCount;
    int i;

// Initialize the COM library and retrieve a pointer
// to an IWMEncoder interface.

    hr = CoInitialize(NULL);
    CoCreateInstance(CLSID_WMEncoder,
                     NULL,
                     CLSCTX_INPROC_SERVER,
                     IID_IWMEncoder,
                     (void**) &pEncoder);

// Retrieve a pointer to an IWMEncSourceGroupCollection
// interface.

    hr = pEncoder->get_SourceGroupCollection(&pSrcGrpColl);

// Add a new source group to the collection.

    hr = pSrcGrpColl->Add(L"SG_1", &pSrcGrp);

// Add an audio and video stream to the source group.

    hr = pSrcGrp->AddSource(WMENC_AUDIO, &pAudSrc);
    hr = pSrcGrp->AddSource(WMENC_VIDEO, &pVidSrc);

// Specify an .avi source file and a .wmv output file.

    CComBSTR bstrInFile(L"C:\\filename.avi");
    hr = pAudSrc->SetInput(bstrInFile);
    hr = pVidSrc->SetInput(bstrInFile);

// You can also use the AutoSetFileSource method to automatically
// parse a file and add the source streams to the source group.
//
//    hr = pSrcGrp->AutoSetFileSource(bstrInFile);

// Loop through the profile collection and retrieve a specific
// profile.

    hr = pEncoder->get_ProfileCollection(&pProColl);
    CComBSTR bstrName = NULL;
    CComVariant varProfile;
    varProfile.vt = VT_DISPATCH;
    hr = pProColl->get_Count(&lCount);
    for (i=0; i<lCount; i++)
    {
        hr = pProColl->Item(i, &pPro);
        hr = pPro->get_Name(&bstrName);
        if (_wcsicmp(bstrName, L"profile name")==0)
        {
            varProfile.pdispVal = pPro;
            pSrcGrp->put_Profile(varProfile);
            break;
        }
    }

// Change the name of the source group.

    CComBSTR bstrSGName(L"Music Only");
    hr = pSrcGrp->put_Name(bstrSGName);

// Retrieve the number of audio and video streams in
// the source group.

    hr = pSrcGrp->get_SourceCount(WMENC_AUDIO, &iAudCount);
    hr = pSrcGrp->get_SourceCount(WMENC_VIDEO, &iVidCount);

// Remove the video stream. In the current release of the
// Windows Media Encoder SDK, a source group can contain
// at most only one audio, one video, and one script stream.
// You must verify that the count is not zero before deleting
// the source stream.

    CComVariant varIndex;
    varIndex.vt = VT_I2;
    varIndex.iVal = 0;
    if (iVidCount != 0)
    {
        hr = pSrcGrp->RemoveSource(WMENC_VIDEO, varIndex);
    }

// Specify automatic archiving when the source group is active.

    hr = pSrcGrp->put_AutoArchive(WMENC_ARCHIVE_LOCAL,
                                  WMENC_ARCHIVE_START);

See Also

  • IWMEncSourceGroup Interface
  • IWMEncSourceGroup::put_Name


IWMEncSourceGroup::get_Profile

The get_Profile method retrieves a profile for the source group.

Syntax

HRESULT get_Profile(
  IWMEncProfile**  ppProfile
);

Parameters

ppProfile

[out] Pointer to a pointer to a profile object.

Return Values

If the method succeeds, it returns S_OK. If it fails, it supports the IErrorInfo interface and returns an HRESULT error code.

Return code | Number | Meaning
E_POINTER | 0x80004003 | The indirect pointer to the profile object is NULL.
NS_E_NO_PROFILE_IN_SOURCEGROUP | 0xC00D1B67 | You must specify a profile for the source group.

Remarks

Only one profile at a time can be associated with a source group. The system contains several predefined profiles, which cannot be either removed or changed. You can use the IWMEncProfileManager interface to create the Profile Manager dialog boxes that edit and list profiles. Use the IWMEncSourceGroup::put_Profile method to associate a profile with a source group.

Example Code

// Include libraries.

#include <windows.h>
#include <atlbase.h>
#include "wmencode.h"

// Declare variables.

    HRESULT hr;
    IWMEncoder* pEncoder;
    IWMEncSourceGroupCollection* pSrcGrpColl;
    IWMEncSourceGroup* pSrcGrp;
    IWMEncSource* pAudSrc;
    IWMEncSource* pVidSrc;
    IWMEncProfileCollection* pProColl;
    IWMEncProfile* pPro;

    long lCount;
    short iAudCount, iVidCount;
    int i;

// Initialize the COM library and retrieve a pointer
// to an IWMEncoder interface.

    hr = CoInitialize(NULL);
    CoCreateInstance(CLSID_WMEncoder,
                     NULL,
                     CLSCTX_INPROC_SERVER,
                     IID_IWMEncoder,
                     (void**) &pEncoder);

// Retrieve a pointer to an IWMEncSourceGroupCollection
// interface.

    hr = pEncoder->get_SourceGroupCollection(&pSrcGrpColl);

// Add a new source group to the collection.

    hr = pSrcGrpColl->Add(L"SG_1", &pSrcGrp);

// Add an audio and video stream to the source group.

    hr = pSrcGrp->AddSource(WMENC_AUDIO, &pAudSrc);
    hr = pSrcGrp->AddSource(WMENC_VIDEO, &pVidSrc);

// Specify an .avi source file and a .wmv output file.

    CComBSTR bstrInFile(L"C:\\filename.avi");
    hr = pAudSrc->SetInput(bstrInFile);
    hr = pVidSrc->SetInput(bstrInFile);

// You can also use the AutoSetFileSource method to automatically
// parse a file and add the source streams to the source group.
//
//    hr = pSrcGrp->AutoSetFileSource(bstrInFile);

// Loop through the profile collection and retrieve a specific
// profile.

    hr = pEncoder->get_ProfileCollection(&pProColl);
    CComBSTR bstrName = NULL;
    CComVariant varProfile;
    varProfile.vt = VT_DISPATCH;
    hr = pProColl->get_Count(&lCount);
    for (i=0; i<lCount; i++)
    {
        hr = pProColl->Item(i, &pPro);
        hr = pPro->get_Name(&bstrName);
        if (_wcsicmp(bstrName, L"profile name")==0)
        {
            varProfile.pdispVal = pPro;
            pSrcGrp->put_Profile(varProfile);
            break;
        }
    }

// Change the name of the source group.

    CComBSTR bstrSGName(L"Music Only");
    hr = pSrcGrp->put_Name(bstrSGName);

// Retrieve the number of audio and video streams in
// the source group.

    hr = pSrcGrp->get_SourceCount(WMENC_AUDIO, &iAudCount);
    hr = pSrcGrp->get_SourceCount(WMENC_VIDEO, &iVidCount);

// Remove the video stream. In the current release of the
// Windows Media Encoder SDK, a source group can contain
// at most only one audio, one video, and one script stream.
// You must verify that the count is not zero before deleting
// the source stream.

    CComVariant varIndex;
    varIndex.vt = VT_I2;
    varIndex.iVal = 0;
    if (iVidCount != 0)
    {
        hr = pSrcGrp->RemoveSource(WMENC_VIDEO, varIndex);
    }

// Specify automatic archiving when the source group is active.

    hr = pSrcGrp->put_AutoArchive(WMENC_ARCHIVE_LOCAL,
                                  WMENC_ARCHIVE_START);

See Also

  • IWMEncProfileManager Interface
  • IWMEncSourceGroup Interface
  • IWMEncSourceGroup::put_Profile


IWMEncSourceGroup::get_Source

The get_Source method retrieves a specific media stream from the source group.

Syntax

HRESULT get_Source(
  WMENC_SOURCE_TYPE  enumType,
  short  iIndex,
  IWMEncSource**  ppSource
);

Parameters

enumType

[in] Member of a WMENC_SOURCE_TYPE enumeration type identifying the media type of the source stream. This parameter must be one of the following values.

Value | Number | Meaning
WMENC_AUDIO | 1 | Identifies an audio stream.
WMENC_VIDEO | 2 | Identifies a video stream.
WMENC_SCRIPT | 4 | Identifies a text stream

iIndex

[in] short containing an index used to identify a stream when multiple streams of the same type exist. Since a source group cannot currently support multiple streams of the same type, this parameter must be zero.

ppSource

[out] Pointer to a pointer to a source stream.

Return Values

If the method succeeds, it returns S_OK. If it fails, it supports the IErrorInfo interface and returns an HRESULT error code.

Return code | Number | Meaning
NS_E_NOMATCHING_MEDIASOURCE | 0xC00D1B5A | No matching media source is found in source group.

See Also

  • IWMEncSourceGroup::get_SourceCount
  • IWMEncSourceGroup Interface


IWMEncSourceGroup::get_SourceCount

The get_SourceCount method retrieves the number of streams of a specific type in the source group.

Syntax

HRESULT get_SourceCount(
  WMENC_SOURCE_TYPE  enumType,
  short*  iSourceCount
);

Parameters

enumType

[in] Member of a WMENC_SOURCE_TYPE enumeration type identifying the media type. This parameter must be one of the following values.

Value | Number | Meaning
WMENC_AUDIO | 1 | Identifies an audio stream.
WMENC_VIDEO | 2 | Identifies a video stream.
WMENC_SCRIPT | 4 | Identifies a text stream.

iSourceCount

[out] Pointer to a short containing the number of enumType streams.

Return Values

If the method succeeds, it returns S_OK. If it fails, it supports the IErrorInfo interface and returns an HRESULT error code.

Return code | Number | Meaning
E_POINTER | 0x80004003 | The address of the variable containing the source count is NULL.

Remarks

A source group can currently contain one audio, one video, and one script stream. Therefore, iSourceCount can be either 0 or 1.

Example Code

// Include libraries.

#include <windows.h>
#include <atlbase.h>
#include "wmencode.h"

// Declare variables.

    HRESULT hr;
    IWMEncoder* pEncoder;
    IWMEncSourceGroupCollection* pSrcGrpColl;
    IWMEncSourceGroup* pSrcGrp;
    IWMEncSource* pAudSrc;
    IWMEncSource* pVidSrc;
    IWMEncProfileCollection* pProColl;
    IWMEncProfile* pPro;

    long lCount;
    short iAudCount, iVidCount;
    int i;

// Initialize the COM library and retrieve a pointer
// to an IWMEncoder interface.

    hr = CoInitialize(NULL);
    CoCreateInstance(CLSID_WMEncoder,
                     NULL,
                     CLSCTX_INPROC_SERVER,
                     IID_IWMEncoder,
                     (void**) &pEncoder);

// Retrieve a pointer to an IWMEncSourceGroupCollection
// interface.

    hr = pEncoder->get_SourceGroupCollection(&pSrcGrpColl);

// Add a new source group to the collection.

    hr = pSrcGrpColl->Add(L"SG_1", &pSrcGrp);

// Add an audio and video stream to the source group.

    hr = pSrcGrp->AddSource(WMENC_AUDIO, &pAudSrc);
    hr = pSrcGrp->AddSource(WMENC_VIDEO, &pVidSrc);

// Specify an .avi source file and a .wmv output file.

    CComBSTR bstrInFile(L"C:\\filename.avi");
    hr = pAudSrc->SetInput(bstrInFile);
    hr = pVidSrc->SetInput(bstrInFile);

// You can also use the AutoSetFileSource method to automatically
// parse a file and add the source streams to the source group.
//
//    hr = pSrcGrp->AutoSetFileSource(bstrInFile);

// Loop through the profile collection and retrieve a specific
// profile.

    hr = pEncoder->get_ProfileCollection(&pProColl);
    CComBSTR bstrName = NULL;
    CComVariant varProfile;
    varProfile.vt = VT_DISPATCH;
    hr = pProColl->get_Count(&lCount);
    for (i=0; i<lCount; i++)
    {
        hr = pProColl->Item(i, &pPro);
        hr = pPro->get_Name(&bstrName);
        if (_wcsicmp(bstrName, L"profile name")==0)
        {
            varProfile.pdispVal = pPro;
            pSrcGrp->put_Profile(varProfile);
            break;
        }
    }

// Change the name of the source group.

    CComBSTR bstrSGName(L"Music Only");
    hr = pSrcGrp->put_Name(bstrSGName);

// Retrieve the number of audio and video streams in
// the source group.

    hr = pSrcGrp->get_SourceCount(WMENC_AUDIO, &iAudCount);
    hr = pSrcGrp->get_SourceCount(WMENC_VIDEO, &iVidCount);

// Remove the video stream. In the current release of the
// Windows Media Encoder SDK, a source group can contain
// at most only one audio, one video, and one script stream.
// You must verify that the count is not zero before deleting
// the source stream.

    CComVariant varIndex;
    varIndex.vt = VT_I2;
    varIndex.iVal = 0;
    if (iVidCount != 0)
    {
        hr = pSrcGrp->RemoveSource(WMENC_VIDEO, varIndex);
    }

// Specify automatic archiving when the source group is active.

    hr = pSrcGrp->put_AutoArchive(WMENC_ARCHIVE_LOCAL,
                                  WMENC_ARCHIVE_START);

See Also

  • IWMEncSourceGroup::get_Source
  • IWMEncSourceGroup Interface


IWMEncSourceGroup::get_GroupTransformCollection

The get_GroupTransformCollection method retrieves a collection of transform plug-ins for the source group.

Syntax

HRESULT get_GroupTransformCollection(
  IWMEncTransformCollection**  ppTransformCollection
);

Parameters

ppTransformCollection

[out] Pointer to a pointer to an IWMEncTransformCollection interface.

Return Values

If the method succeeds, it returns S_OK. If it fails, it returns an HRESULT error code.

Return code | Number | Meaning
E_POINTER | 0x80004003 | The indirect pointer to the transform plug-in collection is NULL.

Remarks

The IWMEncTransformCollection interface does not acquire the plug-in object, but it enables you to retrieve the name. You can use the name in the GetInput method.of the IWMEncTransform interface to tell Windows Media Encoder which plug-in to run.

See Also

  • IWMEncSourceGroup Interface
  • IWMEncTransformCollection Interface


IWMEncSourceGroup::GetGroupTransformPlugin

The GetGroupTransformPlugin method retrieves a specific group level transform plug-in.

Syntax

HRESULT GetGroupTransformPlugin(
  DWORD  dwIndex,
  IUnknown**  ppUnkPlugin
);

Parameters

dwIndex

[in] DWORD containing the index of the plug-in to retrieve.

ppUnkPlugin

[out] Pointer to a pointer to the plug-in.

Return Values

If the method succeeds, it returns S_OK. If it fails, it returns an HRESULT error code.

Return code | Number | Meaning
E_POINTER | 0x80004003 | The indirect pointer to the group transform plug-in is NULL.
NS_E_INVALID_REQUEST | 0xC00D002 | The request is not valid for the current state of the encoder engine.

See Also

  • IWMEncSourceGroup::GetGroupTransformPluginCount
  • IWMEncSourceGroup Interface


IWMEncSourceGroup::GetGroupTransformPluginCount

The GetGroupTransformPluginCount method retrieves the number of transform plug-ins that can be applied to the source group.

Syntax

HRESULT GetGroupTransformPluginCount(
  DWORD*  pdwCount
);

Parameters

pdwCount

[out] Pointer to a DWORD containing the count.

Return Values

If the method succeeds, If it fails, it returns an HRESULT error code.

Return code | Number | Meaning
E_POINTER | 0x80004003 | The pointer to the count is NULL.

See Also

  • IWMEncSourceGroup::GetGroupTransformPlugin
  • IWMEncSourceGroup Interface


IWMEncSourceGroup::PrepareToEncode

The PrepareToEncode method initializes the source group in the encoding session.

Syntax

HRESULT PrepareToEncode(
  VARIANT_BOOL  bPrepare
);

Parameters

bPrepare

[in] VARIANT_BOOL indicating whether to initiate a Windows Media Encoder session.

Return Values

If the method succeeds, it returns S_OK. If it fails, it supports the IErrorInfo interface and returns an HRESULT error code.

Return code | Number | Meaning
E_OUTOFMEMORY | 0x8007000E | Memory cannot be allocated.
NS_E_INVALIDCALL_WHILE_ENCODER_RUNNING | 0xC00D0011 | This method cannot be called if the encoder engine is running.
NS_E_INVALID_REQUEST | 0xC00D002 | The request is not valid for the current state of the encoder engine.
NS_E_NO_PROFILE_IN_SOURCEGROUP | 0xC00D1B67 | You must specify a profile for the source group.

Remarks

You can use this method to prepare the encoding session on a source group by source group basis. You can also use this method during a running encoding session to create and initialize source groups without affecting the operation of the encoder engine.

Example Code

// Include libraries.

#include <windows.h>
#include <atlbase.h>
#include "wmencode.h"

// Declare variables.

    HRESULT hr;
    IWMEncoder* pEncoder;
    IWMEncSourceGroupCollection* pSrcGrpColl;
    IWMEncSourceGroup* pSrcGrp;
    IWMEncSource* pAudSrc;
    IWMEncSource* pVidSrc;
    IWMEncProfileCollection* pProColl;
    IWMEncProfile* pPro;

    long lCount;
    short iAudCount, iVidCount;
    int i;

// Initialize the COM library and retrieve a pointer
// to an IWMEncoder interface.

    hr = CoInitialize(NULL);
    CoCreateInstance(CLSID_WMEncoder,
                     NULL,
                     CLSCTX_INPROC_SERVER,
                     IID_IWMEncoder,
                     (void**) &pEncoder);

// Retrieve a pointer to an IWMEncSourceGroupCollection
// interface.

    hr = pEncoder->get_SourceGroupCollection(&pSrcGrpColl);

// Add a new source group to the collection.

    hr = pSrcGrpColl->Add(L"SG_1", &pSrcGrp);

// Add an audio and video stream to the source group.

    hr = pSrcGrp->AddSource(WMENC_AUDIO, &pAudSrc);
    hr = pSrcGrp->AddSource(WMENC_VIDEO, &pVidSrc);

// Specify an .avi source file and a .wmv output file.

    CComBSTR bstrInFile(L"C:\\filename.avi");
    hr = pAudSrc->SetInput(bstrInFile);
    hr = pVidSrc->SetInput(bstrInFile);

// You can also use the AutoSetFileSource method to automatically
// parse a file and add the source streams to the source group.
//
//    hr = pSrcGrp->AutoSetFileSource(bstrInFile);

// Loop through the profile collection and retrieve a specific
// profile.

    hr = pEncoder->get_ProfileCollection(&pProColl);
    CComBSTR bstrName = NULL;
    CComVariant varProfile;
    varProfile.vt = VT_DISPATCH;
    hr = pProColl->get_Count(&lCount);
    for (i=0; i<lCount; i++)
    {
        hr = pProColl->Item(i, &pPro);
        hr = pPro->get_Name(&bstrName);
        if (_wcsicmp(bstrName, L"profile name")==0)
        {
            varProfile.pdispVal = pPro;
            pSrcGrp->put_Profile(varProfile);
            break;
        }
    }

// Change the name of the source group.

    CComBSTR bstrSGName(L"Music Only");
    hr = pSrcGrp->put_Name(bstrSGName);

// Retrieve the number of audio and video streams in
// the source group.

    hr = pSrcGrp->get_SourceCount(WMENC_AUDIO, &iAudCount);
    hr = pSrcGrp->get_SourceCount(WMENC_VIDEO, &iVidCount);

// Remove the video stream. In the current release of the
// Windows Media Encoder SDK, a source group can contain
// at most only one audio, one video, and one script stream.
// You must verify that the count is not zero before deleting
// the source stream.

    CComVariant varIndex;
    varIndex.vt = VT_I2;
    varIndex.iVal = 0;
    if (iVidCount != 0)
    {
        hr = pSrcGrp->RemoveSource(WMENC_VIDEO, varIndex);
    }

// Specify automatic archiving when the source group is active.

    hr = pSrcGrp->put_AutoArchive(WMENC_ARCHIVE_LOCAL,
                                  WMENC_ARCHIVE_START);

See Also

  • IWMEncoder Interface
  • IWMEncoder::Start
  • IWMEncSourceGroup Interface


IWMEncSourceGroup::put_AutoArchive

The put_AutoArchive method specifies an enumeration type that indicates the nature of the archiving operation if IWMEncoder::put_EnableAutoArchive is set to VARIANT_TRUE.

Syntax

HRESULT put_AutoArchive(
  WMENC_ARCHIVE_TYPE  enumArchiveType,
  WMENC_ARCHIVE_OPERATION  enumArchiveOp
);

Parameters

enumArchiveType

[in] Member of a WMENC_ARCHIVE_TYPE enumeration type indicating where content can be archived. This must be the following value.

Value | Number | Description
WMENC_ARCHIVE_LOCAL | 1 | The encoded content can only be saved to a local destination defined as the computer on which the content was originated and the network on which that computer is located.

penumArchiveOp

[out] Member of a WMENC_ARCHIVE_OPERATION enumeration type indicating whether encoded content will be archived when the source group is made active and the encoder engine starts. This must be one of the following values.

Value | Number | Description
WMENC_ARCHIVE_START | 1 | The encoded content from the source group will be archived.
WMENC_ARCHIVE_STOP | 2 | The archiving process for the source group is stopped.
WMENC_ARCHIVE_PAUSE | 3 | The archiving process for the source group will be paused.

Return Values

If the method succeeds, it returns S_OK. If it fails, it supports the IErrorInfo interface and returns an HRESULT error code.

Return code | Number | Meaning
NS_E_UNSUPPORTED_ARCHIVETYPE | 0xC00D1B77 | You can save encoded content only to a local file.
NS_E_UNSUPPORTED_ARCHIVEOPERATION | 0xC00D1B78 | You can only start, stop, or pause the archiving process.

Remarks

Use the put_AutoArchive method to selectively archive source groups. For instance, if you are encoding a static welcome screen, a live presentation and a static goodbye screen, you can utilize disk space more efficiently by only archiving the live presentation. Use the IWMEncoder::put_EnableAutoArchive method to specify whether archiving will automatically occur when the encoder engine starts. Use the IWMEncoder::Archive method to manually control the archiving process.

Example Code

// Include libraries.

#include <windows.h>
#include <atlbase.h>
#include "wmencode.h"

// Declare variables.

    HRESULT hr;
    IWMEncoder* pEncoder;
    IWMEncSourceGroupCollection* pSrcGrpColl;
    IWMEncSourceGroup* pSrcGrp;
    IWMEncSource* pAudSrc;
    IWMEncSource* pVidSrc;
    IWMEncProfileCollection* pProColl;
    IWMEncProfile* pPro;

    long lCount;
    short iAudCount, iVidCount;
    int i;

// Initialize the COM library and retrieve a pointer
// to an IWMEncoder interface.

    hr = CoInitialize(NULL);
    CoCreateInstance(CLSID_WMEncoder,
                     NULL,
                     CLSCTX_INPROC_SERVER,
                     IID_IWMEncoder,
                     (void**) &pEncoder);

// Retrieve a pointer to an IWMEncSourceGroupCollection
// interface.

    hr = pEncoder->get_SourceGroupCollection(&pSrcGrpColl);

// Add a new source group to the collection.

    hr = pSrcGrpColl->Add(L"SG_1", &pSrcGrp);

// Add an audio and video stream to the source group.

    hr = pSrcGrp->AddSource(WMENC_AUDIO, &pAudSrc);
    hr = pSrcGrp->AddSource(WMENC_VIDEO, &pVidSrc);

// Specify an .avi source file and a .wmv output file.

    CComBSTR bstrInFile(L"C:\\filename.avi");
    hr = pAudSrc->SetInput(bstrInFile);
    hr = pVidSrc->SetInput(bstrInFile);

// You can also use the AutoSetFileSource method to automatically
// parse a file and add the source streams to the source group.
//
//    hr = pSrcGrp->AutoSetFileSource(bstrInFile);

// Loop through the profile collection and retrieve a specific
// profile.

    hr = pEncoder->get_ProfileCollection(&pProColl);
    CComBSTR bstrName = NULL;
    CComVariant varProfile;
    varProfile.vt = VT_DISPATCH;
    hr = pProColl->get_Count(&lCount);
    for (i=0; i<lCount; i++)
    {
        hr = pProColl->Item(i, &pPro);
        hr = pPro->get_Name(&bstrName);
        if (_wcsicmp(bstrName, L"profile name")==0)
        {
            varProfile.pdispVal = pPro;
            pSrcGrp->put_Profile(varProfile);
            break;
        }
    }

// Change the name of the source group.

    CComBSTR bstrSGName(L"Music Only");
    hr = pSrcGrp->put_Name(bstrSGName);

// Retrieve the number of audio and video streams in
// the source group.

    hr = pSrcGrp->get_SourceCount(WMENC_AUDIO, &iAudCount);
    hr = pSrcGrp->get_SourceCount(WMENC_VIDEO, &iVidCount);

// Remove the video stream. In the current release of the
// Windows Media Encoder SDK, a source group can contain
// at most only one audio, one video, and one script stream.
// You must verify that the count is not zero before deleting
// the source stream.

    CComVariant varIndex;
    varIndex.vt = VT_I2;
    varIndex.iVal = 0;
    if (iVidCount != 0)
    {
        hr = pSrcGrp->RemoveSource(WMENC_VIDEO, varIndex);
    }

// Specify automatic archiving when the source group is active.

    hr = pSrcGrp->put_AutoArchive(WMENC_ARCHIVE_LOCAL,
                                  WMENC_ARCHIVE_START);

See Also

  • IWMEncoder::Archive
  • IWMEncoder Interface
  • IWMEncoder::put_EnableAutoArchive
  • IWMEncSourceGroup::get_AutoArchive
  • IWMEncSourceGroup Interface


IWMEncSourceGroup::put_Name

The put_Name method specifies a name for the source group.

Syntax

HRESULT put_Name(
  BSTR  bstrName
);

Parameters

bstrName

[in] BSTR containing the source group name.

Return Values

If the method succeeds, it returns S_OK. If it fails, it supports the IErrorInfo interface.

Example Code

// Include libraries.

#include <windows.h>
#include <atlbase.h>
#include "wmencode.h"

// Declare variables.

    HRESULT hr;
    IWMEncoder* pEncoder;
    IWMEncSourceGroupCollection* pSrcGrpColl;
    IWMEncSourceGroup* pSrcGrp;
    IWMEncSource* pAudSrc;
    IWMEncSource* pVidSrc;
    IWMEncProfileCollection* pProColl;
    IWMEncProfile* pPro;

    long lCount;
    short iAudCount, iVidCount;
    int i;

// Initialize the COM library and retrieve a pointer
// to an IWMEncoder interface.

    hr = CoInitialize(NULL);
    CoCreateInstance(CLSID_WMEncoder,
                     NULL,
                     CLSCTX_INPROC_SERVER,
                     IID_IWMEncoder,
                     (void**) &pEncoder);

// Retrieve a pointer to an IWMEncSourceGroupCollection
// interface.

    hr = pEncoder->get_SourceGroupCollection(&pSrcGrpColl);

// Add a new source group to the collection.

    hr = pSrcGrpColl->Add(L"SG_1", &pSrcGrp);

// Add an audio and video stream to the source group.

    hr = pSrcGrp->AddSource(WMENC_AUDIO, &pAudSrc);
    hr = pSrcGrp->AddSource(WMENC_VIDEO, &pVidSrc);

// Specify an .avi source file and a .wmv output file.

    CComBSTR bstrInFile(L"C:\\filename.avi");
    hr = pAudSrc->SetInput(bstrInFile);
    hr = pVidSrc->SetInput(bstrInFile);

// You can also use the AutoSetFileSource method to automatically
// parse a file and add the source streams to the source group.
//
//    hr = pSrcGrp->AutoSetFileSource(bstrInFile);

// Loop through the profile collection and retrieve a specific
// profile.

    hr = pEncoder->get_ProfileCollection(&pProColl);
    CComBSTR bstrName = NULL;
    CComVariant varProfile;
    varProfile.vt = VT_DISPATCH;
    hr = pProColl->get_Count(&lCount);
    for (i=0; i<lCount; i++)
    {
        hr = pProColl->Item(i, &pPro);
        hr = pPro->get_Name(&bstrName);
        if (_wcsicmp(bstrName, L"profile name")==0)
        {
            varProfile.pdispVal = pPro;
            pSrcGrp->put_Profile(varProfile);
            break;
        }
    }

// Change the name of the source group.

    CComBSTR bstrSGName(L"Music Only");
    hr = pSrcGrp->put_Name(bstrSGName);

// Retrieve the number of audio and video streams in
// the source group.

    hr = pSrcGrp->get_SourceCount(WMENC_AUDIO, &iAudCount);
    hr = pSrcGrp->get_SourceCount(WMENC_VIDEO, &iVidCount);

// Remove the video stream. In the current release of the
// Windows Media Encoder SDK, a source group can contain
// at most only one audio, one video, and one script stream.
// You must verify that the count is not zero before deleting
// the source stream.

    CComVariant varIndex;
    varIndex.vt = VT_I2;
    varIndex.iVal = 0;
    if (iVidCount != 0)
    {
        hr = pSrcGrp->RemoveSource(WMENC_VIDEO, varIndex);
    }

// Specify automatic archiving when the source group is active.

    hr = pSrcGrp->put_AutoArchive(WMENC_ARCHIVE_LOCAL,
                                  WMENC_ARCHIVE_START);

See Also

  • IWMEncSourceGroup::get_Name
  • IWMEncSourceGroup Interface


IWMEncSourceGroup::put_Profile

The put_Profile method associates a specific profile with the source group.

Syntax

HRESULT put_Profile(
  VARIANT  var
);

Parameters

pProfile

[in] VARIANT containing one of the following:

  • A string specifying the path and name of a profile. File names must end with a .prx file name extension.
  • An index into the profile collection.
  • A pointer to a WMEncProfile object.
  • A pointer to a custom WMProfile object created using the Windows Media Format SDK.

Return Values

If the method succeeds, it returns S_OK. If it fails, it supports the IErrorInfo interface and returns an HRESULT error code.

Return code | Number | Meaning
NS_E_INVALIDCALL_WHILE_ENCODER_RUNNING | 0xC00D0011 | This method cannot be called if the encoder engine is running.
NS_E_MISMATCHED_MEDIACONTENT | 0xC00D1B5F | The media content defined in the profile does not match the media content defined in the source group.

Remarks

If you use the Windows Media Format SDK to create a custom profile and then use the put_Profile method to add that profile to a source group, it is possible that Windows Media Encoder will return E_NOINTERFACE. Windows Media Encoder marshals components when necessary, but because custom WMProfile objects are not COM-compliant, they cannot be marshaled, and Windows Media Encoder generates this error. If the put_Profile method returns E_NOINTERFACE, save your custom profile to a .prx file and call put_Profile again, specifying the path and name of the file rather than a pointer to the custom WMProfile object.

Only one profile at a time can be associated with a source group and an encoding session. Use the IWMEncSourceGroup::get_Profile method to retrieve the associated profile.

Example Code

// Include libraries.

#include <windows.h>
#include <atlbase.h>
#include "wmencode.h"

// Declare variables.

    HRESULT hr;
    IWMEncoder* pEncoder;
    IWMEncSourceGroupCollection* pSrcGrpColl;
    IWMEncSourceGroup* pSrcGrp;
    IWMEncSource* pAudSrc;
    IWMEncSource* pVidSrc;
    IWMEncProfileCollection* pProColl;
    IWMEncProfile* pPro;

    long lCount;
    short iAudCount, iVidCount;
    int i;

// Initialize the COM library and retrieve a pointer
// to an IWMEncoder interface.

    hr = CoInitialize(NULL);
    CoCreateInstance(CLSID_WMEncoder,
                     NULL,
                     CLSCTX_INPROC_SERVER,
                     IID_IWMEncoder,
                     (void**) &pEncoder);

// Retrieve a pointer to an IWMEncSourceGroupCollection
// interface.

    hr = pEncoder->get_SourceGroupCollection(&pSrcGrpColl);

// Add a new source group to the collection.

    hr = pSrcGrpColl->Add(L"SG_1", &pSrcGrp);

// Add an audio and video stream to the source group.

    hr = pSrcGrp->AddSource(WMENC_AUDIO, &pAudSrc);
    hr = pSrcGrp->AddSource(WMENC_VIDEO, &pVidSrc);

// Specify an .avi source file and a .wmv output file.

    CComBSTR bstrInFile(L"C:\\filename.avi");
    hr = pAudSrc->SetInput(bstrInFile);
    hr = pVidSrc->SetInput(bstrInFile);

// You can also use the AutoSetFileSource method to automatically
// parse a file and add the source streams to the source group.
//
//    hr = pSrcGrp->AutoSetFileSource(bstrInFile);

// Loop through the profile collection and retrieve a specific
// profile.

    hr = pEncoder->get_ProfileCollection(&pProColl);
    CComBSTR bstrName = NULL;
    CComVariant varProfile;
    varProfile.vt = VT_DISPATCH;
    hr = pProColl->get_Count(&lCount);
    for (i=0; i<lCount; i++)
    {
        hr = pProColl->Item(i, &pPro);
        hr = pPro->get_Name(&bstrName);
        if (_wcsicmp(bstrName, L"profile name")==0)
        {
            varProfile.pdispVal = pPro;
            pSrcGrp->put_Profile(varProfile);
            break;
        }
    }

// Change the name of the source group.

    CComBSTR bstrSGName(L"Music Only");
    hr = pSrcGrp->put_Name(bstrSGName);

// Retrieve the number of audio and video streams in
// the source group.

    hr = pSrcGrp->get_SourceCount(WMENC_AUDIO, &iAudCount);
    hr = pSrcGrp->get_SourceCount(WMENC_VIDEO, &iVidCount);

// Remove the video stream. In the current release of the
// Windows Media Encoder SDK, a source group can contain
// at most only one audio, one video, and one script stream.
// You must verify that the count is not zero before deleting
// the source stream.

    CComVariant varIndex;
    varIndex.vt = VT_I2;
    varIndex.iVal = 0;
    if (iVidCount != 0)
    {
        hr = pSrcGrp->RemoveSource(WMENC_VIDEO, varIndex);
    }

// Specify automatic archiving when the source group is active.

    hr = pSrcGrp->put_AutoArchive(WMENC_ARCHIVE_LOCAL,
                                  WMENC_ARCHIVE_START);

// Initialize the encoder engine.

    hr = pSrcGrp->PrepareToEncode(VARIANT_TRUE);

See Also

  • IWMEncSourceGroup::get_Profile
  • IWMEncSourceGroup Interface


IWMEncSourceGroup::RemoveSource

The RemoveSource method removes a media stream from the source group.

Syntax

HRESULT RemoveSource(
  WMENC_SOURCE_TYPE  enumType,
  VARIANT  var
);

Parameters

enumType

[in] Member of a WMENC_SOURCE_TYPE enumeration type identifying the media type of the stream being removed. This must be one of the following values.

Value | Number | Meaning
WMENC_AUDIO | 1 | Identifies an audio stream.
WMENC_VIDEO | 2 | Identifies a video stream.
WMENC_SCRIPT | 4 | Identifies a text stream.

var

[in] VARIANT containing the index of the media source. . Each type of media stream has a separate index. In the current release of the Windows Media Encoder SDK, all index values must be zero (0).

Return Values

If the method succeeds, it returns S_OK. If it fails, it supports the IErrorInfo interface and returns an HRESULT error code.

Return code | Number | Meaning
NS_E_INVALIDCALL_WHILE_ENCODER_RUNNING | 0xC00D0011 | This method cannot be called if the encoder engine is running.
NS_E_MISMATCHED_MEDIACONTENT | 0xC00D1B5F | The media content defined in the profile does not match the media content defined in the source group.

Example Code

// Include libraries.

#include <windows.h>
#include <atlbase.h>
#include "wmencode.h"

// Declare variables.

    HRESULT hr;
    IWMEncoder* pEncoder;
    IWMEncSourceGroupCollection* pSrcGrpColl;
    IWMEncSourceGroup* pSrcGrp;
    IWMEncSource* pAudSrc;
    IWMEncSource* pVidSrc;
    IWMEncProfileCollection* pProColl;
    IWMEncProfile* pPro;

    long lCount;
    short iAudCount, iVidCount;
    int i;

// Initialize the COM library and retrieve a pointer
// to an IWMEncoder interface.

    hr = CoInitialize(NULL);
    CoCreateInstance(CLSID_WMEncoder,
                     NULL,
                     CLSCTX_INPROC_SERVER,
                     IID_IWMEncoder,
                     (void**) &pEncoder);

// Retrieve a pointer to an IWMEncSourceGroupCollection
// interface.

    hr = pEncoder->get_SourceGroupCollection(&pSrcGrpColl);

// Add a new source group to the collection.

    hr = pSrcGrpColl->Add(L"SG_1", &pSrcGrp);

// Add an audio and video stream to the source group.

    hr = pSrcGrp->AddSource(WMENC_AUDIO, &pAudSrc);
    hr = pSrcGrp->AddSource(WMENC_VIDEO, &pVidSrc);

// Specify an .avi source file and a .wmv output file.

    CComBSTR bstrInFile(L"C:\\filename.avi");
    hr = pAudSrc->SetInput(bstrInFile);
    hr = pVidSrc->SetInput(bstrInFile);

// You can also use the AutoSetFileSource method to automatically
// parse a file and add the source streams to the source group.
//
//    hr = pSrcGrp->AutoSetFileSource(bstrInFile);

// Loop through the profile collection and retrieve a specific
// profile.

    hr = pEncoder->get_ProfileCollection(&pProColl);
    CComBSTR bstrName = NULL;
    CComVariant varProfile;
    varProfile.vt = VT_DISPATCH;
    hr = pProColl->get_Count(&lCount);
    for (i=0; i<lCount; i++)
    {
        hr = pProColl->Item(i, &pPro);
        hr = pPro->get_Name(&bstrName);
        if (_wcsicmp(bstrName, L"profile name")==0)
        {
            varProfile.pdispVal = pPro;
            pSrcGrp->put_Profile(varProfile);
            break;
        }
    }

// Change the name of the source group.

    CComBSTR bstrSGName(L"Music Only");
    hr = pSrcGrp->put_Name(bstrSGName);

// Retrieve the number of audio and video streams in
// the source group.

    hr = pSrcGrp->get_SourceCount(WMENC_AUDIO, &iAudCount);
    hr = pSrcGrp->get_SourceCount(WMENC_VIDEO, &iVidCount);

// Remove the video stream. In the current release of the
// Windows Media Encoder SDK, a source group can contain
// at most only one audio, one video, and one script stream.
// You must verify that the count is not zero before deleting
// the source stream.

    CComVariant varIndex;
    varIndex.vt = VT_I2;
    varIndex.iVal = 0;
    if (iVidCount != 0)
    {
        hr = pSrcGrp->RemoveSource(WMENC_VIDEO, varIndex);
    }

// Specify automatic archiving when the source group is active.

    hr = pSrcGrp->put_AutoArchive(WMENC_ARCHIVE_LOCAL,
                                  WMENC_ARCHIVE_START);

See Also

  • IWMEncSourceGroup::AddSource
  • IWMEncSourceGroup Interface


IWMEncSourceGroupCollection Interface

The IWMEncSourceGroupCollection interface contains the enumerated source groups that are available to an encoding session. In addition to the methods inherited from IDispatch, the IWMEncSourceGroupCollection interface exposes the following methods.

Method | Description
Add | Appends a new source group to the collection.
get_Active | Retrieves the active source group.
get_Count | Retrieves the number of source groups in the collection.
get_length | Retrieves the number of source groups in the collection. This is the JScript version of get_Count.
Item | Retrieves the source group identified by a specific integer index.
Move | Repositions a specific source group directly in front of another in the collection.
put_Active | Selects a source group.
Remove | Removes a source group from the collection.

See Also

  • [Visual Basic] IWMEncSourceGroupCollection Object
  • Interfaces (C++)


IWMEncSourceGroupCollection::Add

The Add method appends a new source group to the collection.

Syntax

HRESULT Add(
  BSTR  bstrName,
  IWMEncSourceGroup**  ppSourceGroup
);

Parameters

bstrName

[in] BSTR containing the name of the source group to be added to the collection.

ppSourceGroup

[out] Pointer to a pointer to the source group.

Return Values

If the method succeeds, it returns S_OK. If it fails, it supports the IErrorInfo interface and returns an HRESULT error code.

Return code | Number | Meaning
E_FAIL | 0x80004005 | An unspecified error occurred.
E_INVALIDARG | 0x80070057 | The string containing the name of the source group cannot be empty.
E_OUTOFMEMORY | 0x8007000E | Memory cannot be allocated.
E_POINTER | 0x80004003 | The indirect pointer to the source group is NULL.

Remarks

The source group being added must be identified by a valid name assigned with the put_Name method in the IWMEncSourceGroup interface. The Add method creates a source group object for the input name, adds the source group to the collection and returns it to the caller.

Example

// Include libraries.

#include <windows.h>
#include <atlbase.h>        // Includes CComBSTR and CComVariant
#include "wmencode.h"

int main()
{
    HRESULT hr;
    IWMEncoder* pEncoder;
    IWMEncSourceGroupCollection* pSrcGrpColl;
    IWMEncSourceGroup* pSrcGrp;
    IWMEncSourceGroup* pSrcGrp1;
    IWMEncSourceGroup* pSrcGrp2;
    IWMEncSourceGroup* pSrcGrp3;

    long lCount;
    int i;

// Initialize the COM library and retrieve a pointer
// to an IWMEncoder interface.

    hr = CoInitialize(NULL);
    CoCreateInstance(CLSID_WMEncoder,
                     NULL,
                     CLSCTX_INPROC_SERVER,
                     IID_IWMEncoder,
                     (void**) &pEncoder);

// Retrieve a pointer to an IWMEncSourceGroupCollection
// interface.

    hr = pEncoder->get_SourceGroupCollection(&pSrcGrpColl);

// Add new source groups to the collection.

    hr = pSrcGrpColl->Add(L"SG_1", &pSrcGrp1);
    hr = pSrcGrpColl->Add(L"SG_2", &pSrcGrp2);
    hr = pSrcGrpColl->Add(L"SG_2", &pSrcGrp3);

// Loop through the collection to find a specific source
// group, and make that source group active.

    CComBSTR bstrName = NULL;
    CComVariant varIndex;
    varIndex.vt = VT_I2;
    hr = pSrcGrpColl->get_Count(&lCount);
    for (i=0; i<lCount; i++)
    {
        varIndex.iVal = i;
        hr = pSrcGrpColl->Item(varIndex, &pSrcGrp);
        hr = pSrcGrp->get_Name(&bstrName);
        if ((_wcsicmp(bstrName, L"SG_3")==0))
        {
            // Move SG_3 in front of SG_1.
            hr = pSrcGrpColl->Move(pSrcGrp3, pSrcGrp1);
            // Make SG_3 active.
            hr = pSrcGrpColl->put_Active(pSrcGrp3);
        }
    }

// Remove SG_2, by index, from the collection.

    varIndex.iVal = 2;
    hr = pSrcGrpColl->Remove(varIndex);

See Also

  • IWMEncSourceGroupCollection Interface
  • IWMEncSourceGroupCollection::Remove
  • IWMEncSourceGroup Interface
  • IWMEncSourceGroup::put_Name


IWMEncSourceGroupCollection::get_Active

The get_Active method retrieves the active source group.

Syntax

HRESULT get_Active(
  IWMEncSourceGroup**  ppSourceGroup
);

Parameters

ppSourceGroup

[out] Pointer to a pointer to the active source group.

Return Values

If the method succeeds, it returns S_OK. If it fails, it supports the IErrorInfo interface and returns an HRESULT error code.

Return code | Number | Meaning
NS_E_NO_ACTIVE_SOURCEGROUP | 0xC00D1B72 | No source group is currently active.

Remarks

The active source group is the one currently being encoded. Only one group can be active at a time. The active state of any source group in the collection can be set by the IWMEncSourceGroupCollection::put_Active method.

Example

// Include libraries.

#include <windows.h>
#include <atlbase.h>        // Includes CComBSTR and CComVariant
#include "wmencode.h"

// Declare variables.

    HRESULT hr;
    IWMEncoder* pEncoder;
    IWMEncSourceGroupCollection* pSrcGrpColl;
    IWMEncSourceGroup* pSrcGrp;
    IWMEncSourceGroup* pSrcGrp1;
    IWMEncSourceGroup* pSrcGrp2;
    IWMEncSourceGroup* pSrcGrp3;

    long lCount;
    int i;

// Initialize the COM library and retrieve a pointer
// to an IWMEncoder interface.

    hr = CoInitialize(NULL);
    CoCreateInstance(CLSID_WMEncoder,
                     NULL,
                     CLSCTX_INPROC_SERVER,
                     IID_IWMEncoder,
                     (void**) &pEncoder);

// Retrieve a pointer to an IWMEncSourceGroupCollection
// interface.

    hr = pEncoder->get_SourceGroupCollection(&pSrcGrpColl);

// Add new source groups to the collection.

    hr = pSrcGrpColl->Add(L"SG_1", &pSrcGrp1);
    hr = pSrcGrpColl->Add(L"SG_2", &pSrcGrp2);
    hr = pSrcGrpColl->Add(L"SG_2", &pSrcGrp3);

// Loop through the collection to find a specific source
// group, and make that source group active.

    CComBSTR bstrName = NULL;
    CComVariant varIndex;
    varIndex.vt = VT_I2;
    hr = pSrcGrpColl->get_Count(&lCount);
    for (i=0; i<lCount; i++)
    {
        varIndex.iVal = i;
        hr = pSrcGrpColl->Item(varIndex, &pSrcGrp);
        hr = pSrcGrp->get_Name(&bstrName);
        if ((_wcsicmp(bstrName, L"SG_3")==0))
        {
            // Move SG_3 in front of SG_1.
            hr = pSrcGrpColl->Move(pSrcGrp3, pSrcGrp1);
            // Make SG_3 active.
            hr = pSrcGrpColl->put_Active(pSrcGrp3);
        }
    }

// Remove SG_2, by index, from the collection.

    varIndex.iVal = 2;
    hr = pSrcGrpColl->Remove(varIndex);

See Also

  • IWMEncSourceGroupCollection Interface
  • IWMEncSourceGroupCollection::put_Active
  • IWMEncSourceGroup Interface


IWMEncSourceGroupCollection::get_Count

The get_Count method retrieves the number of source groups in the collection.

Syntax

HRESULT get_Count(
  long*  plCount
);

Parameters

plCount

[out] Pointer to a long containing the number of source groups in the collection.

Return Values

If the method succeeds, it returns S_OK.

Remarks

This method is the C++ version of the JScript get_Length method.

Example

// Include libraries.

#include <windows.h>
#include <atlbase.h>        // Includes CComBSTR and CComVariant
#include "wmencode.h"

// Declare variables.

    HRESULT hr;
    IWMEncoder* pEncoder;
    IWMEncSourceGroupCollection* pSrcGrpColl;
    IWMEncSourceGroup* pSrcGrp;
    IWMEncSourceGroup* pSrcGrp1;
    IWMEncSourceGroup* pSrcGrp2;
    IWMEncSourceGroup* pSrcGrp3;

    long lCount;
    int i;

// Initialize the COM library and retrieve a pointer
// to an IWMEncoder interface.

    hr = CoInitialize(NULL);
    CoCreateInstance(CLSID_WMEncoder,
                     NULL,
                     CLSCTX_INPROC_SERVER,
                     IID_IWMEncoder,
                     (void**) &pEncoder);

// Retrieve a pointer to an IWMEncSourceGroupCollection
// interface.

    hr = pEncoder->get_SourceGroupCollection(&pSrcGrpColl);

// Add new source groups to the collection.

    hr = pSrcGrpColl->Add(L"SG_1", &pSrcGrp1);
    hr = pSrcGrpColl->Add(L"SG_2", &pSrcGrp2);
    hr = pSrcGrpColl->Add(L"SG_2", &pSrcGrp3);

// Loop through the collection to find a specific source
// group, and make that source group active.

    CComBSTR bstrName = NULL;
    CComVariant varIndex;
    varIndex.vt = VT_I2;
    hr = pSrcGrpColl->get_Count(&lCount);
    for (i=0; i<lCount; i++)
    {
        varIndex.iVal = i;
        hr = pSrcGrpColl->Item(varIndex, &pSrcGrp);
        hr = pSrcGrp->get_Name(&bstrName);
        if ((_wcsicmp(bstrName, L"SG_3")==0))
        {
            // Move SG_3 in front of SG_1.
            hr = pSrcGrpColl->Move(pSrcGrp3, pSrcGrp1);
            // Make SG_3 active.
            hr = pSrcGrpColl->put_Active(pSrcGrp3);
        }
    }

// Remove SG_2, by index, from the collection.

    varIndex.iVal = 2;
    hr = pSrcGrpColl->Remove(varIndex);

See Also

  • IWMEncSourceGroupCollection::get_Length
  • IWMEncSourceGroupCollection Interface


IWMEncSourceGroupCollection::get_length

The get_length method retrieves the number of source groups in the collection.

Syntax

HRESULT get_length(
  long*  plCount
);

Parameters

plCount

[out] Pointer to a long containing the number of source groups in the collection.

Return Values

If the method succeeds, it returns S_OK.

Remarks

This method performs the same action as the get_Count method. It is included for JScript developers or developers more comfortable with JScript syntax.

Example

// Include libraries.

#include <windows.h>
#include <atlbase.h>        // Includes CComBSTR and CComVariant
#include "wmencode.h"

// Declare variables.

    HRESULT hr;
    IWMEncoder* pEncoder;
    IWMEncSourceGroupCollection* pSrcGrpColl;
    IWMEncSourceGroup* pSrcGrp;
    IWMEncSourceGroup* pSrcGrp1;
    IWMEncSourceGroup* pSrcGrp2;
    IWMEncSourceGroup* pSrcGrp3;

    long lCount;
    int i;

// Initialize the COM library and retrieve a pointer
// to an IWMEncoder interface.

    hr = CoInitialize(NULL);
    CoCreateInstance(CLSID_WMEncoder,
                     NULL,
                     CLSCTX_INPROC_SERVER,
                     IID_IWMEncoder,
                     (void**) &pEncoder);

// Retrieve a pointer to an IWMEncSourceGroupCollection
// interface.

    hr = pEncoder->get_SourceGroupCollection(&pSrcGrpColl);

// Add new source groups to the collection.

    hr = pSrcGrpColl->Add(L"SG_1", &pSrcGrp1);
    hr = pSrcGrpColl->Add(L"SG_2", &pSrcGrp2);
    hr = pSrcGrpColl->Add(L"SG_2", &pSrcGrp3);

// Loop through the collection to find a specific source
// group, and make that source group active.

    CComBSTR bstrName = NULL;
    CComVariant varIndex;
    varIndex.vt = VT_I2;
    hr = pSrcGrpColl->get_Count(&lCount);
    for (i=0; i<lCount; i++)
    {
        varIndex.iVal = i;
        hr = pSrcGrpColl->Item(varIndex, &pSrcGrp);
        hr = pSrcGrp->get_Name(&bstrName);
        if ((_wcsicmp(bstrName, L"SG_3")==0))
        {
            // Move SG_3 in front of SG_1.
            hr = pSrcGrpColl->Move(pSrcGrp3, pSrcGrp1);
            // Make SG_3 active.
            hr = pSrcGrpColl->put_Active(pSrcGrp3);
        }
    }

// Remove SG_2, by index, from the collection.

    varIndex.iVal = 2;
    hr = pSrcGrpColl->Remove(varIndex);

See Also

  • IWMEncSourceGroupCollection::get_Count
  • IWMEncSourceGroupCollection Interface


IWMEncSourceGroupCollection::Item

The Item method retrieves the source group identified by a specific integer index within the source group collection.

Syntax

HRESULT Item(
  VARIANT  var,
  IWMEncSourceGroup**  ppSourceGroup
);

Parameters

var

[in] VARIANT containing either the index or name of the source group to retrieve.

ppSourceGroup

[out] Pointer to a pointer to a source group object corresponding to iIndex.

Return Values

If the method succeeds, it returns S_OK. If it fails, it supports the IErrorInfo interface and returns an HRESULT error code.

Return code | Number | Meaning
E_POINTER | 0x80004003 | The indirect pointer to the source group is NULL.

Remarks

The input parameter can be either an integer index into the collection or the name of a source group. If a name is used, the first source group that matches the name is returned. If you do not already know the index associated with the required source group pointer, you must iterate through the collection, starting at item 0. On each iteration increment the index and use the Item method to retrieve a pointer to the source group. Call IWMEncSourceGroup::get_Name method to find the name of the source group being pointed to and compare the name retrieved to that needed. Exit the loop when a match is found.

Example

// Include libraries.

#include <windows.h>
#include <atlbase.h>        // Includes CComBSTR and CComVariant
#include "wmencode.h"

// Declare variables.

    HRESULT hr;
    IWMEncoder* pEncoder;
    IWMEncSourceGroupCollection* pSrcGrpColl;
    IWMEncSourceGroup* pSrcGrp;
    IWMEncSourceGroup* pSrcGrp1;
    IWMEncSourceGroup* pSrcGrp2;
    IWMEncSourceGroup* pSrcGrp3;

    long lCount;
    int i;

// Initialize the COM library and retrieve a pointer
// to an IWMEncoder interface.

    hr = CoInitialize(NULL);
    CoCreateInstance(CLSID_WMEncoder,
                     NULL,
                     CLSCTX_INPROC_SERVER,
                     IID_IWMEncoder,
                     (void**) &pEncoder);

// Retrieve a pointer to an IWMEncSourceGroupCollection
// interface.

    hr = pEncoder->get_SourceGroupCollection(&pSrcGrpColl);

// Add new source groups to the collection.

    hr = pSrcGrpColl->Add(L"SG_1", &pSrcGrp1);
    hr = pSrcGrpColl->Add(L"SG_2", &pSrcGrp2);
    hr = pSrcGrpColl->Add(L"SG_2", &pSrcGrp3);

// Loop through the collection to find a specific source
// group, and make that source group active.

    CComBSTR bstrName = NULL;
    CComVariant varIndex;
    varIndex.vt = VT_I2;
    hr = pSrcGrpColl->get_Count(&lCount);
    for (i=0; i<lCount; i++)
    {
        varIndex.iVal = i;
        hr = pSrcGrpColl->Item(varIndex, &pSrcGrp);
        hr = pSrcGrp->get_Name(&bstrName);
        if ((_wcsicmp(bstrName, L"SG_3")==0))
        {
            // Move SG_3 in front of SG_1.
            hr = pSrcGrpColl->Move(pSrcGrp3, pSrcGrp1);
            // Make SG_3 active.
            hr = pSrcGrpColl->put_Active(pSrcGrp3);
        }
    }

// Remove SG_2, by index, from the collection.

    varIndex.iVal = 2;
    hr = pSrcGrpColl->Remove(varIndex);

See Also

  • IWMEncSourceGroup::get_Name
  • IWMEncSourceGroupCollection Interface


IWMEncSourceGroupCollection::Move

The Move method repositions a specified source group directly in front of another source group in the collection.

Syntax

HRESULT Move(
  IWMEncSourceGroup*  pSourceGroup,
  IWMEncSourceGroup*  pSourceGroupInfront
);

Parameters

pSourceGroup

[in] Pointer to the repositioned source group object.

pSourceGroupInfront

[in] Pointer to the source group before which pSourceGroup is placed.

Return Values

If the method succeeds, it returns S_OK. If it fails, it supports the IErrorInfo interface and returns an HRESULT error code.

Return code | Number | Meaning
E_POINTER | 0x80004003 | The pointer to either source group is NULL.

Remarks

Use the IWMEncSourceGroupCollection::Add method to add a source group. Use the IWMEncSourceGroupCollection::Item method to retrieve both pSourceGroup and pSourceGroupInfront.

Example

// Include libraries.

#include <windows.h>
#include <atlbase.h>        // Includes CComBSTR and CComVariant
#include "wmencode.h"

// Declare variables.

    HRESULT hr;
    IWMEncoder* pEncoder;
    IWMEncSourceGroupCollection* pSrcGrpColl;
    IWMEncSourceGroup* pSrcGrp;
    IWMEncSourceGroup* pSrcGrp1;
    IWMEncSourceGroup* pSrcGrp2;
    IWMEncSourceGroup* pSrcGrp3;

    long lCount;
    int i;

// Initialize the COM library and retrieve a pointer
// to an IWMEncoder interface.

    hr = CoInitialize(NULL);
    CoCreateInstance(CLSID_WMEncoder,
                     NULL,
                     CLSCTX_INPROC_SERVER,
                     IID_IWMEncoder,
                     (void**) &pEncoder);

// Retrieve a pointer to an IWMEncSourceGroupCollection
// interface.

    hr = pEncoder->get_SourceGroupCollection(&pSrcGrpColl);

// Add new source groups to the collection.

    hr = pSrcGrpColl->Add(L"SG_1", &pSrcGrp1);
    hr = pSrcGrpColl->Add(L"SG_2", &pSrcGrp2);
    hr = pSrcGrpColl->Add(L"SG_2", &pSrcGrp3);

// Loop through the collection to find a specific source
// group, and make that source group active.

    CComBSTR bstrName = NULL;
    CComVariant varIndex;
    varIndex.vt = VT_I2;
    hr = pSrcGrpColl->get_Count(&lCount);
    for (i=0; i<lCount; i++)
    {
        varIndex.iVal = i;
        hr = pSrcGrpColl->Item(varIndex, &pSrcGrp);
        hr = pSrcGrp->get_Name(&bstrName);
        if ((_wcsicmp(bstrName, L"SG_3")==0))
        {
            // Move SG_3 in front of SG_1.
            hr = pSrcGrpColl->Move(pSrcGrp3, pSrcGrp1);
            // Make SG_3 active.
            hr = pSrcGrpColl->put_Active(pSrcGrp3);
        }
    }

// Remove SG_2, by index, from the collection.

    varIndex.iVal = 2;
    hr = pSrcGrpColl->Remove(varIndex);

See Also

  • IWMEncSourceGroupCollection::Add
  • IWMEncSourceGroupCollection::Item
  • IWMEncSourceGroupCollection Interface


IWMEncSourceGroupCollection::put_Active

The put_Active method specifies the active source group.

Syntax

HRESULT put_Active(
  IWMEncSourceGroup*  pSourceGroup
);

Parameters

pSourceGroup

[in] Pointer to the source group that is being activated.

Return Values

If the method succeeds, it returns S_OK. If it fails, it supports the IErrorInfo interface.

Remarks

The active source group is the one currently being encoded. Only one group can be active at a time. Use the IWMEncSourceGroupCollection::get_Active method to retrieve the active source group. Only one group can be active at a time.

Example

// Include libraries.

#include <windows.h>
#include <atlbase.h>        // Includes CComBSTR and CComVariant
#include "wmencode.h"

// Declare variables.

    HRESULT hr;
    IWMEncoder* pEncoder;
    IWMEncSourceGroupCollection* pSrcGrpColl;
    IWMEncSourceGroup* pSrcGrp;
    IWMEncSourceGroup* pSrcGrp1;
    IWMEncSourceGroup* pSrcGrp2;
    IWMEncSourceGroup* pSrcGrp3;

    long lCount;
    int i;

// Initialize the COM library and retrieve a pointer
// to an IWMEncoder interface.

    hr = CoInitialize(NULL);
    CoCreateInstance(CLSID_WMEncoder,
                     NULL,
                     CLSCTX_INPROC_SERVER,
                     IID_IWMEncoder,
                     (void**) &pEncoder);

// Retrieve a pointer to an IWMEncSourceGroupCollection
// interface.

    hr = pEncoder->get_SourceGroupCollection(&pSrcGrpColl);

// Add new source groups to the collection.

    hr = pSrcGrpColl->Add(L"SG_1", &pSrcGrp1);
    hr = pSrcGrpColl->Add(L"SG_2", &pSrcGrp2);
    hr = pSrcGrpColl->Add(L"SG_2", &pSrcGrp3);

// Loop through the collection to find a specific source
// group, and make that source group active.

    CComBSTR bstrName = NULL;
    CComVariant varIndex;
    varIndex.vt = VT_I2;
    hr = pSrcGrpColl->get_Count(&lCount);
    for (i=0; i<lCount; i++)
    {
        varIndex.iVal = i;
        hr = pSrcGrpColl->Item(varIndex, &pSrcGrp);
        hr = pSrcGrp->get_Name(&bstrName);
        if ((_wcsicmp(bstrName, L"SG_3")==0))
        {
            // Move SG_3 in front of SG_1.
            hr = pSrcGrpColl->Move(pSrcGrp3, pSrcGrp1);
            // Make SG_3 active.
            hr = pSrcGrpColl->put_Active(pSrcGrp3);
        }
    }

// Remove SG_2, by index, from the collection.

    varIndex.iVal = 2;
    hr = pSrcGrpColl->Remove(varIndex);

See Also

  • IWMEncSourceGroupCollection::get_Active
  • IWMEncSourceGroupCollection Interface
  • IWMEncSourceGroup Interface


IWMEncSourceGroupCollection::Remove

The Remove method removes a source group from the collection.

Syntax

HRESULT Remove(
  VARIANT  var
);

Parameters

var

[in] VARIANT containing either the index, name, or 128-bit object ID of the source group.

Return Values

If the method succeeds, it returns S_OK. If it fails, it supports the IErrorInfo interface and returns an HRESULT error code.

Return code | Number | Meaning
NS_E_CANNOT_DELETE_ACTIVE_SOURCEGROUP | 0xC00D1B60 | The active source group cannot be deleted while the encoder engine is running.

Example

// Include libraries.

#include <windows.h>
#include <atlbase.h>        // Includes CComBSTR and CComVariant
#include "wmencode.h"

// Declare variables.

    HRESULT hr;
    IWMEncoder* pEncoder;
    IWMEncSourceGroupCollection* pSrcGrpColl;
    IWMEncSourceGroup* pSrcGrp;
    IWMEncSourceGroup* pSrcGrp1;
    IWMEncSourceGroup* pSrcGrp2;
    IWMEncSourceGroup* pSrcGrp3;

    long lCount;
    int i;

// Initialize the COM library and retrieve a pointer
// to an IWMEncoder interface.

    hr = CoInitialize(NULL);
    CoCreateInstance(CLSID_WMEncoder,
                     NULL,
                     CLSCTX_INPROC_SERVER,
                     IID_IWMEncoder,
                     (void**) &pEncoder);

// Retrieve a pointer to an IWMEncSourceGroupCollection
// interface.

    hr = pEncoder->get_SourceGroupCollection(&pSrcGrpColl);

// Add new source groups to the collection.

    hr = pSrcGrpColl->Add(L"SG_1", &pSrcGrp1);
    hr = pSrcGrpColl->Add(L"SG_2", &pSrcGrp2);
    hr = pSrcGrpColl->Add(L"SG_2", &pSrcGrp3);

// Loop through the collection to find a specific source
// group, and make that source group active.

    CComBSTR bstrName = NULL;
    CComVariant varIndex;
    varIndex.vt = VT_I2;
    hr = pSrcGrpColl->get_Count(&lCount);
    for (i=0; i<lCount; i++)
    {
        varIndex.iVal = i;
        hr = pSrcGrpColl->Item(varIndex, &pSrcGrp);
        hr = pSrcGrp->get_Name(&bstrName);
        if ((_wcsicmp(bstrName, L"SG_3")==0))
        {
            // Move SG_3 in front of SG_1.
            hr = pSrcGrpColl->Move(pSrcGrp3, pSrcGrp1);
            // Make SG_3 active.
            hr = pSrcGrpColl->put_Active(pSrcGrp3);
        }
    }

// Remove SG_2, by index, from the collection.

    varIndex.iVal = 2;
    hr = pSrcGrpColl->Remove(varIndex);

See Also

  • IWMEncSourceGroupCollection::Add
  • IWMEncSourceGroupCollection Interface


IWMEncSourcePluginInfoManager Interface

The IWMEncSourcePluginInfoManager interface searches the plug-in registration information to populate a collection of source IWMEncPluginInfo objects. In addition to the methods inherited from IDispatch, the IWMEncSourcePluginInfoManager interface exposes the following methods.

Method | Description
get_Count | Retrieves the number of installed source plug-ins.
get_length | Retrieves the number of installed source plug-ins. This is the JScript version of the get_Count method.
Item | Retrieves information about a specific plug-in object in the collection.
Refresh | Removes the old collection and populates a new collection of source plug-in information structures.

See Also

  • [Visual Basic] IWMEncSourcePluginInfoManager Object
  • Interfaces (C++)
  • IWMEncPluginInfo Interface


IWMEncSourcePluginInfoManager::get_Count

The get_Count method retrieves the number of installed source plug-ins.

Syntax

HRESULT get_Count(
  long*  plCount
);

Parameters

plCount

[out] Pointer to a long containing the number of registered source plug-ins.

Return Values

If the method succeeds, it returns S_OK.

Example Code

// Include libraries.

#include <windows.h>
#include <atlbase.h>
#include "wmencode.h"

// Declare variables.

    HRESULT hr;
    IWMEncoder* pEncoder;
    IWMEncSourcePluginInfoManager* pSrcPlugMgr;
    IWMEncPluginInfo* pPlugInfo;

    int i,j;
    long lPlugCount, lResCount;
    VARIANT_BOOL bResources;

// Initialize the COM library and retrieve a pointer
// to an IWMEncoder interface.

    hr = CoInitialize(NULL);
    CoCreateInstance(CLSID_WMEncoder,
                     NULL,
                     CLSCTX_INPROC_SERVER,
                     IID_IWMEncoder,
                     (void**) &pEncoder);

// Retrieve an IWMEncSourcePluginInfoManager pointer.

    hr = pEncoder->get_SourcePluginInfoManager(&pSrcPlugMgr);

// Loop through the source plug-ins. Call the Item method on each
// plug-in to retrieve an IWMEncPluginInfo object. Use the
// SchemeType property to retrieve a string containing the scheme
// type of the plug-in. If the scheme type is "DEVICE" and if the
// plug-in supports resources, call the Item method to retrieve a
// string identifying the resource.
// To capture streams from an attached device, you must choose a
// specific device plug-in.

    hr = pSrcPlugMgr->get_Count(&lPlugCount);
    for (i=0; i<lPlugCount; i++)
    {
        hr = pSrcPlugMgr->Item(i, &pPlugInfo);
        CComBSTR bstrScheme;
        hr = pPlugInfo->get_SchemeType(&bstrScheme);
        if (_wcsicmp(bstrScheme, L"DEVICE")==0)
        {
            hr = pPlugInfo->get_Resources(&bResources);
            if (bResources==VARIANT_TRUE)
            {
                hr = pPlugInfo->get_Count(&lResCount);
                for (j=0; j<lResCount; j++)
                {
                    CComBSTR bstrResource;
                    hr = pPlugInfo->Item(j, &bstrResource);
                }
            }
        }
    }

See Also

  • IWMEncSourcePluginInfoManager Interface


IWMEncSourcePluginInfoManager::get_length

The get_length method retrieves the number of installed source plug-ins.

Syntax

HRESULT get_length(
  long*  plCount
);

Parameters

plCount

[out] Pointer to a long integer containing the number of registered source plug-ins.

Return Values

If the method succeeds, it returns S_OK.

Remarks

This is the JScript version of the get_Count method. It is provided for JScript developers or developers more accustomed to JScript syntax.

Example Code

// Include libraries.

#include <windows.h>
#include <atlbase.h>
#include "wmencode.h"

// Declare variables.

    HRESULT hr;
    IWMEncoder* pEncoder;
    IWMEncSourcePluginInfoManager* pSrcPlugMgr;
    IWMEncPluginInfo* pPlugInfo;

    int i,j;
    long lPlugCount, lResCount;
    VARIANT_BOOL bResources;

// Initialize the COM library and retrieve a pointer
// to an IWMEncoder interface.

    hr = CoInitialize(NULL);
    CoCreateInstance(CLSID_WMEncoder,
                     NULL,
                     CLSCTX_INPROC_SERVER,
                     IID_IWMEncoder,
                     (void**) &pEncoder);

// Retrieve an IWMEncSourcePluginInfoManager pointer.

    hr = pEncoder->get_SourcePluginInfoManager(&pSrcPlugMgr);

// Loop through the source plug-ins. Call the Item method on each
// plug-in to retrieve an IWMEncPluginInfo object. Use the
// SchemeType property to retrieve a string containing the scheme
// type of the plug-in. If the scheme type is "DEVICE" and if the
// plug-in supports resources, call the Item method to retrieve a
// string identifying the resource.
// To capture streams from an attached device, you must choose a
// specific device plug-in.

    hr = pSrcPlugMgr->get_Count(&lPlugCount);
    for (i=0; i<lPlugCount; i++)
    {
        hr = pSrcPlugMgr->Item(i, &pPlugInfo);
        CComBSTR bstrScheme;
        hr = pPlugInfo->get_SchemeType(&bstrScheme);
        if (_wcsicmp(bstrScheme, L"DEVICE")==0)
        {
            hr = pPlugInfo->get_Resources(&bResources);
            if (bResources==VARIANT_TRUE)
            {
                hr = pPlugInfo->get_Count(&lResCount);
                for (j=0; j<lResCount; j++)
                {
                    CComBSTR bstrResource;
                    hr = pPlugInfo->Item(j, &bstrResource);
                }
            }
        }
    }

See Also

  • IWMEncSourcePluginInfoManager Interface


IWMEncSourcePluginInfoManager::Item

The Item method retrieves information about a specific source plug-in object in the collection.

Syntax

HRESULT Item(
  long  lIndex,
  IWMEncPluginInfo**  ppPluginInfo
);

Parameters

var

[in] long containing an index into the source plug-in collection.

ppPluginInfo

[out] Pointer to a pointer to an IWMEncPluginInfo object containing general information.

Return Values

If the method succeeds, it returns S_OK.

Example Code

// Include libraries.

#include <windows.h>
#include <atlbase.h>
#include "wmencode.h"

// Declare variables.

    HRESULT hr;
    IWMEncoder* pEncoder;
    IWMEncSourcePluginInfoManager* pSrcPlugMgr;
    IWMEncPluginInfo* pPlugInfo;

    int i,j;
    long lPlugCount, lResCount;
    VARIANT_BOOL bResources;

// Initialize the COM library and retrieve a pointer
// to an IWMEncoder interface.

    hr = CoInitialize(NULL);
    CoCreateInstance(CLSID_WMEncoder,
                     NULL,
                     CLSCTX_INPROC_SERVER,
                     IID_IWMEncoder,
                     (void**) &pEncoder);

// Retrieve an IWMEncSourcePluginInfoManager pointer.

    hr = pEncoder->get_SourcePluginInfoManager(&pSrcPlugMgr);

// Loop through the source plug-ins. Call the Item method on each
// plug-in to retrieve an IWMEncPluginInfo object. Use the
// SchemeType property to retrieve a string containing the scheme
// type of the plug-in. If the scheme type is "DEVICE" and if the
// plug-in supports resources, call the Item method to retrieve a
// string identifying the resource.
// To capture streams from an attached device, you must choose a
// specific device plug-in.

    hr = pSrcPlugMgr->get_Count(&lPlugCount);
    for (i=0; i<lPlugCount; i++)
    {
        hr = pSrcPlugMgr->Item(i, &pPlugInfo);
        CComBSTR bstrScheme;
        hr = pPlugInfo->get_SchemeType(&bstrScheme);
        if (_wcsicmp(bstrScheme, L"DEVICE")==0)
        {
            hr = pPlugInfo->get_Resources(&bResources);
            if (bResources==VARIANT_TRUE)
            {
                hr = pPlugInfo->get_Count(&lResCount);
                for (j=0; j<lResCount; j++)
                {
                    CComBSTR bstrResource;
                    hr = pPlugInfo->Item(j, &bstrResource);
                }
            }
        }
    }

See Also

  • IWMEncPluginInfo Interface
  • IWMEncSourcePluginInfoManager Interface


IWMEncSourcePluginInfoManager::Refresh

The Refresh method removes the old collection and populates a new collection of source plug-in information structures.

Syntax

HRESULT Refresh();

Parameters

This method takes no parameters.

Return Values

If the method succeeds, it returns S_OK.

Remarks

Use this method to re-create a plug-in registration collection when you either add or remove a plug-in.

See Also

  • IWMEncSourcePluginInfoManager Interface


IWMEncStatistics Interface

The IWMEncStatistics interface provides status information about the encoding session. In addition to the methods inherited from IDispatch, the IWMEncStatistics interface exposes the following methods.

Method | Description
get_EncodingTime | Retrieves the elapsed time of the encoding session.
get_FileArchiveStats | Retrieves an IWMEncFileArchiveStats interface to determine the size of the archive file and the duration of the encoded content stored in the file.
get_IndexerStats | Retrieves an IWMEncIndexerStats interface to determine the number of files being indexed, the name of a file in the queue, and the percentage of indexing completed on the current file.
get_NetConnectionStats | Retrieves a network connection object.
get_StreamOutputCount | Retrieves the number of multiple bit rate output streams generated from a specific input stream.
get_StreamOutputStats | Retrieves the encoding and broadcasting statistics for a specific output stream.
get_WMFOutputStats | Retrieves status information for the encoded output.

See Also

  • [Visual Basic] IWMEncStatistics Object
  • Interfaces (C++)
  • IWMEncFileArchiveStats Interface
  • IWMEncOutputStats Interface
  • IWMEncNetConnectionStats Interface


IWMEncStatistics::get_EncodingTime

The get_EncodingTime method retrieves the elapsed time of the encoding session.

Syntax

HRESULT get_EncodingTime(
  WMENC_longlong*  pqwTime
);

Parameters

pqwTime

[out] Pointer to a QWORD containing the elapsed time.

Return Values

If the method succeeds, it returns S_OK. If it fails, it returns an HRESULT error code.

Return code | Number | Meaning
E_POINTER | 0x80004003 | The pointer to the elapsed time is NULL.

Remarks

The elapsed time, in milliseconds, is measured from the start of the encoding session to the moment at which get_EncodingTime is processed. The WMENC_longlong data type is a typedef from the CURRENCY type. A 64-bit integer is needed to hold the elapsed time, and CURRENCY is the only 64-bit integer type that Automation supports. However, CURRENCY is a fixed-point type that has the decimal point moved four places to the left. Therefore, to display the CURRENCY value as a true integer and retrieve the correct elapsed time, you must multiply the value pointed to by 10,000.

See Also

  • IWMEncStatistics Interface


IWMEncStatistics::get_FileArchiveStats

The get_FileArchiveStats method retrieves an IWMEncFileArchiveStats interface to determine the size of the archive file and the duration of the encoded content stored in the file.

Syntax

HRESULT get_FileArchiveStats(
  IDispatch**  ppFileArchiveStats
);

Parameters

ppFileArchiveStats

[out] Pointer to a pointer to an IWMEncFileArchiveStats interface.

Return Values

If the method succeeds, it returns S_OK. If it fails, it supports the IErrorInfo interface and returns an HRESULT error code.

Return code | Number | Meaning
NS_E_NOSTATSAVAILABLE | 0xC00D1B7D | No statistics are currently available.
NS_E_NOTARCHIVING | 0xC00D1B7E | The encoder engine is not currently archiving.

Example Code

// For an example that explains how to
// create and use an archive file, see the IWMEncFile object.
// The following example shows how to capture archiving statistics
// during the encoding process.

// Include libraries.

#include <windows.h>
#include "wmencode.h"

// Declare variables.

    HRESULT hr;
    IWMEncoder* pEncoder;
    IWMEncStatistics* pStatistics;
    IWMEncFileArchiveStats* pFileArchiveStats;
    IDispatch* pDispFileArchiveStats;
    WMENC_longlong qwDuration, qwSize;

// Initialize the COM library and retrieve a pointer
// to an IWMEncoder interface.

    hr = CoInitialize(NULL);
    CoCreateInstance(CLSID_WMEncoder,
                     NULL,
                     CLSCTX_INPROC_SERVER,
                     IID_IWMEncoder,
                    (void**) &pEncoder);

// Retrieve an IWMEncStatistics interface pointer.

    hr = pEncoder->get_Statistics(&pStatistics);

// Retrieve an IDispatch pointer for the IWMEncOutputStats
// interface.

    hr = pStatistics->get_FileArchiveStats(&pDispFileArchiveStats);

// Call QueryInterface for the IWMEncNetConnectionStats
// interface pointer.

    hr = pDispFileArchiveStats->QueryInterface(
                      IID_IWMEncFileArchiveStats,
                      (void**)&pFileArchiveStats);

// Manually configure the encoder engine or load
// a configuration from a file. For an example, see the
// IWMEncFile object.

// Create a timer to retrieve the statistics
// after you start the encoder engine.

    pFileArchiveStats->get_FileDuration(&qwDuration);
    pFileArchiveStats->get_FileSize(&qwSize);

See Also

  • IWMEncFileArchiveStats Interface
  • IWMEncStatistics Interface


IWMEncStatistics::get_IndexerStats

The get_IndexerStats method retrieves an IWMEncIndexerStats interface to determine the number of files being indexed, the name of a file in the queue, and the percentage of indexing completed on the current file.

Syntax

HRESULT get_IndexerStats(
  IDispatch**  ppIndexerStats
);

Parameters

ppIndexerStats

[out] Pointer to a pointer to an IWMEncIndexerStats interface.

Return Values

If the method succeeds, it returns S_OK. If it fails, it supports the IErrorInfo interface and returns an HRESULT error code.

Return code | Number | Meaning
E_POINTER | 0x80004003 | The indirect pointer to the index statistics is NULL.
NS_E_NOSTATSAVAILABLE | 0xC00D1B7D | No statistics are currently available.

Example Code

// Include libraries.

#include <windows.h>
#include "wmencode.h"
#include <atlbase.h>

// Declare variables.

    HRESULT hr;
    IWMEncoder* pEncoder;
    IWMEncStatistics* pStats;
    IDispatch* pDispIndex;
    IWMEncIndexerStats* pIndexStats;
    long lFileCount, lPercent;
    CComBSTR bstrFileName;

// Initialize the COM library and retrieve a pointer
// to an IWMEncoder interface.

    hr = CoInitialize(NULL);
    CoCreateInstance(CLSID_WMEncoder,
                     NULL,
                     CLSCTX_INPROC_SERVER,
                     IID_IWMEncoder,
                     (void**) &pEncoder);

// Retrieve a pointer to an IWMEncAttributes interface.

    hr = pEncoder->get_Statistics(&pStats);

// Retrieve an IDispatch pointer to IWMEncIndexerStats interface.

    hr = pStats->get_IndexerStats(&pDispIndex);

// Call QueryInterface() to retrieve a pointer to the
// IWMEncIndexerStats interface.

    hr = pDispIndex->QueryInterface(IID_IWMEncIndexerStats,
                                    (void**) &pIndexStats);

// Retrieve information about the indexing process.

    hr = pIndexStats->get_FileCount(&lFileCount);
    hr = pIndexStats->get_FileName(0, &bstrFileName);
    hr = pIndexStats->get_PercentComplete(&lPercent);

See Also

  • IWMEncIndexerStats Interface
  • IWMEncStatistics Interface


IWMEncStatistics::get_NetConnectionStats

The get_NetConnection method retrieves a network connection object.

Syntax

HRESULT get_NetConnectionStats(
  IDispatch**  ppDispNetConnectionStats
);

Parameters

ppDispNetConnectionStats

[out] Pointer to a pointer to the IDispatch interface of the network connection statistucs object.

Return Values

If the method succeeds, it returns S_OK. If it fails, it supports the IErrorInfo interface and returns an HRESULT error code.

Return code | Number | Meaning
NS_E_NOSTATSAVAILABLE | 0xC00D1B7D | No statistics are currently available.

Remarks

Use the IWMEncNetConnectionStats interface to determine the number, protocols and IP addresses of the connected clients.

Example Code

// Include libraries.

#include <windows.h>
#include <atlbase.h>   // Includes CComBSTR.
#include "wmencode.h"

// Declare variables.

    HRESULT hr;
    IWMEncoder* pEncoder;
    IWMEncStatistics* pStatistics;
    IWMEncNetConnectionStats* pNetConnStats;
    IDispatch* pDispNetConnStats;

    long lCount;
    int i;

// Initialize the COM library and retrieve a pointer
// to an IWMEncoder interface.

    hr = CoInitialize(NULL);
    CoCreateInstance(CLSID_WMEncoder,
                     NULL,
                     CLSCTX_INPROC_SERVER,
                     IID_IWMEncoder,
                    (void**) &pEncoder);

// Load a pre-defined configuration from a .wme file

    CComBSTR bstrFileName(L"file_name");
    hr = pEncoder->Load(bstrFileName);

// Start the encoder engine.

    hr = pEncoder->Start();

// Retrieve an IWMEncStatistics interface pointer.

    hr = pEncoder->get_Statistics(&pStatistics);

// Retrieve an IDispatch pointer for the IWMEncNetConnectionStats
// interface.

    hr = pStatistics->get_NetConnectionStats(&pDispNetConnStats);

// Call QueryInterface for the IWMEncNetConnectionStats
// interface pointer.

    hr = pDispNetConnStats->QueryInterface(IID_IWMEncNetConnectionStats,
                                          (void**)&pNetConnStats);

// Retrieve the number of connected clients.

    hr = pNetConnStats->get_ClientCount(&lCount);

// Retrieve the IP address of each client.

    WMENC_BROADCAST_PROTOCOL wmeProtocol;
    for (i=1; i=lCount; i++)
    {
        CComBSTR bstrIPAddr;
        hr = pNetConnStats->get_ClientInfo(i, &wmeProtocol, &bstrIPAddr);
    }

See Also

  • IWMEncNetConnectionStats Interface
  • IWMEncStatistics Interface


IWMEncStatistics::get_StreamOutputCount

The get_StreamOutputCount method retrieves the number of multiple bit rate output streams generated from a specific input stream.

Syntax

HRESULT get_StreamOutputCount(
  WMENC_SOURCE_TYPE  enumType,
  short  iMediaIndex,
  short*  pStreamOutputCount
);

Parameters

enumType

[in] Specifies a member of an WMENC_SOURCE_TYPE enumeration type indicating the type of the specific stream. This must be one of the following values. Only video streams, however, can generate multiple bit rate output streams.

Value | Number | Description
WMENC_AUDIO | 1 | Identifies an audio stream.
WMENC_VIDEO | 2 | Identifies a video stream.
WMENC_SCRIPT | 4 | Identifies a text stream.

iMediaIndex

[in] short containing the source group index number for a specific input stream of the type identified by enumType. Because Windows Media Encoder supports only one audio, one video and one text stream for each source group, iMediaIndex must be zero. The index is zero-based.

pStreamOutputCount

[out] Pointer to a short containing the number of multiple-bit-rate output streams generated from a specific input stream.

Return Values

If the method succeeds, it returns S_OK. If it fails, it supports the IErrorInfo interface and returns an HRESULT error code.

Return code | Number | Meaning
E_POINTER | 0x80004003 | The pointer to the output stream count is NULL.

Remarks

If you specify a source type that does not exist in the source group, the get_StreamOutputCount method returns an error code. It does not return zero.

Example Code

// Include libraries.

#include <windows.h>
#include <atlbase.h>    // Includes CComBSTR.
#include "wmencode.h"

// Declare variables.

    HRESULT hr;
    IWMEncoder* pEncoder;
    IWMEncStatistics* pStatistics;
    IWMEncOutputStats* pOutputStats;
    IDispatch* pDispOutputStats;

    short iStreamCount;
    long lAvgBitrate, lAvgSampleRate;
    long lCurrentBitRate, lCurrentSampleRate;
    long lExpectedBitRate, lExpectedSampleRate;
    WMENC_longlong qwByteCount, qwSampleCount;
    WMENC_longlong qwDroppedByteCount, qwDroppedSampleCount;

// Initialize the COM library and retrieve a pointer
// to an IWMEncoder interface.

    hr = CoInitialize(NULL);
    CoCreateInstance(CLSID_WMEncoder,
                     NULL,
                     CLSCTX_INPROC_SERVER,
                     IID_IWMEncoder,
                    (void**) &pEncoder);

// Retrieve an IWMEncStatistics interface pointer.

    hr = pEncoder->get_Statistics(&pStatistics);

// Retrieve the number of multiple bit rate output streams.

    hr = pStatistics->get_StreamOutputCount(WMENC_VIDEO,
                                            0,
                                            &iStreamCount);

// Retrieve an IDispatch pointer for the IWMEncOutputStats
// interface.

    hr = pStatistics->get_StreamOutputStats(WMENC_VIDEO,
                                            0,
                                            0,
                                            &pDispOutputStats);

// Call QueryInterface for the IWMEncNetConnectionStats
// interface pointer.

    hr = pDispOutputStats->QueryInterface(IID_IWMEncOutputStats,
                                          (void**)&pOutputStats);

// Manually configure the encoder engine or load
// a configuration from a file. For an example, see the
// IWMEncFile object.

// You can create a timer to retrieve the statistics
// after you start the encoder engine.

    hr = pOutputStats->get_AverageBitrate(&lAvgBitrate);
    hr = pOutputStats->get_AverageSampleRate(&lAvgSampleRate);
    hr = pOutputStats->get_ByteCount(&qwByteCount);
    hr = pOutputStats->get_CurrentBitrate(&lCurrentBitRate);
    hr = pOutputStats->get_CurrentSampleRate(&lCurrentSampleRate);
    hr = pOutputStats->get_DroppedByteCount(&qwDroppedByteCount);
    hr = pOutputStats->get_DroppedSampleCount(&qwDroppedSampleCount);
    hr = pOutputStats->get_ExpectedBitrate(&lExpectedBitRate);
    hr = pOutputStats->get_ExpectedSampleRate(&lExpectedSampleRate);
    hr = pOutputStats->get_SampleCount(&qwSampleCount);

See Also

  • IWMEncStatistics Interface


IWMEncStatistics::get_StreamOutputStats

The get_StreamOutputStats method retrieves the encoding and broadcasting statistics for a specific output stream.

Syntax

HRESULT get_StreamOutputStats(
  WMENC_SOURCE_TYPE  enumType,
  short  iMediaIndex,
  short  iStreamIndex,
  IDISPATCH**  ppStats
);

Parameters

enumType

[in] Member of a WMENC_SOURCE_TYPE enumeration type indicating the type of the specific stream. This must be one of the following values.

Value | Number | Description
WMENC_AUDIO | 1 | Identifies an audio stream.
WMENC_VIDEO | 2 | Identifies a video stream.
WMENC_SCRIPT | 4 | Identifies a text stream.

iMediaIndex

[in] short containing the source group index number for a specific input media stream of the type identified by enumType. Because a source group can only contain one audio, one video and one text stream, iMediaIndex must be zero.

iStreamIndex

[in] short containing the index of a specific multiple bit rate output stream for the input stream identified by iMediaIndex. A profile can identify multiple output streams for a specific input stream. Only the bit rate varies among the streams.

ppStats

[out] Pointer to pointer to an IWMEncOutputStats interface containing status information about the output stream.

Return Values

If the method succeeds, it returns S_OK. If it fails, it supports the IErrorInfo interface and returns an HRESULT error code.

Return code | Number | Meaning
E_POINTER | 0x80004003 | The indirect pointer to the output statistics is NULL.
NS_E_NOSTATSAVAILABLE | 0xC00D1B7D | No statistics are currently available.

Remarks

The IWMEncOutputStats interface contains information about the number of media samples received and dropped; the current, average and expected bit rate of the broadcast; and the current, average and expected rates at which media samples are encoded.

Example Code

// Include libraries.

#include <windows.h>
#include <atlbase.h>    // Includes CComBSTR.
#include "wmencode.h"

// Declare variables.

    HRESULT hr;
    IWMEncoder* pEncoder;
    IWMEncStatistics* pStatistics;
    IWMEncOutputStats* pOutputStats;
    IDispatch* pDispOutputStats;

    short iStreamCount;
    long lAvgBitrate, lAvgSampleRate;
    long lCurrentBitRate, lCurrentSampleRate;
    long lExpectedBitRate, lExpectedSampleRate;
    WMENC_longlong qwByteCount, qwSampleCount;
    WMENC_longlong qwDroppedByteCount, qwDroppedSampleCount;

// Initialize the COM library and retrieve a pointer
// to an IWMEncoder interface.

    hr = CoInitialize(NULL);
    CoCreateInstance(CLSID_WMEncoder,
                     NULL,
                     CLSCTX_INPROC_SERVER,
                     IID_IWMEncoder,
                    (void**) &pEncoder);

// Retrieve an IWMEncStatistics interface pointer.

    hr = pEncoder->get_Statistics(&pStatistics);

// Retrieve the number of multiple bit rate output streams.

    hr = pStatistics->get_StreamOutputCount(WMENC_VIDEO,
                                            0,
                                            &iStreamCount);

// Retrieve an IDispatch pointer for the IWMEncOutputStats
// interface.

    hr = pStatistics->get_StreamOutputStats(WMENC_VIDEO,
                                            0,
                                            0,
                                            &pDispOutputStats);

// Call QueryInterface for the IWMEncNetConnectionStats
// interface pointer.

    hr = pDispOutputStats->QueryInterface(IID_IWMEncOutputStats,
                                          (void**)&pOutputStats);

// Manually configure the encoder engine or load
// a configuration from a file. For an example, see the
// IWMEncFile object.

// You can create a timer to retrieve the statistics
// after you start the encoder engine.

    hr = pOutputStats->get_AverageBitrate(&lAvgBitrate);
    hr = pOutputStats->get_AverageSampleRate(&lAvgSampleRate);
    hr = pOutputStats->get_ByteCount(&qwByteCount);
    hr = pOutputStats->get_CurrentBitrate(&lCurrentBitRate);
    hr = pOutputStats->get_CurrentSampleRate(&lCurrentSampleRate);
    hr = pOutputStats->get_DroppedByteCount(&qwDroppedByteCount);
    hr = pOutputStats->get_DroppedSampleCount(&qwDroppedSampleCount);
    hr = pOutputStats->get_ExpectedBitrate(&lExpectedBitRate);
    hr = pOutputStats->get_ExpectedSampleRate(&lExpectedSampleRate);
    hr = pOutputStats->get_SampleCount(&qwSampleCount);

See Also

  • IWMEncOutputStats Interface
  • IWMEncStatistics Interface


IWMEncStatistics::get_WMFOutputStats

The get_WMFOutputStats method retrieves status information for the encoded output.

Syntax

HRESULT get_WMFOutputStats(
  IDispatch**  ppStats
);

Parameters

ppStats

[out] Pointer to a pointer to the IWMEncOutputStats interface.

Return Values

If the method succeeds, it returns S_OK. If it fails, it supports the IErrorInfo interface and returns an HRESULT error code.

Return code | Number | Meaning
E_POINTER | 0x80004003 | The indirect pointer to the output statistics is NULL.

Remarks

The IWMEncOutputStats interface contains information about the number of media samples received and dropped; the current, average and expected bit rate of the broadcast; and the current, average and expected rates at which media samples are encoded.

Example Code

// Include libraries.

#include <windows.h>
#include <atlbase.h>    // Includes CComBSTR.
#include "wmencode.h"

// Declare variables.

    HRESULT hr;
    IWMEncoder* pEncoder;
    IWMEncStatistics* pStatistics;
    IWMEncOutputStats* pOutputStats;
    IDispatch* pDispOutputStats;

    long lAvgBitrate, lAvgSampleRate;
    long lCurrentBitRate, lCurrentSampleRate;
    long lExpectedBitRate, lExpectedSampleRate;
    WMENC_longlong qwByteCount, qwSampleCount;
    WMENC_longlong qwDroppedByteCount, qwDroppedSampleCount;

// Initialize the COM library and retrieve a pointer
// to an IWMEncoder interface.

    hr = CoInitialize(NULL);
    CoCreateInstance(CLSID_WMEncoder,
                     NULL,
                     CLSCTX_INPROC_SERVER,
                     IID_IWMEncoder,
                    (void**) &pEncoder);

// Retrieve an IWMEncStatistics interface pointer.

    hr = pEncoder->get_Statistics(&pStatistics);

// Retrieve an IDispatch pointer for the IWMEncOutputStats
// interface.

    hr = pStatistics->get_WMFOutputStats(&pDispOutputStats);

// Call QueryInterface for the IWMEncNetConnectionStats
// interface pointer.

    hr = pDispOutputStats->QueryInterface(IID_IWMEncOutputStats,
                                          (void**)&pOutputStats);

// Manually configure the encoder engine or load
// a configuration from a file. For an example, see the
// IWMEncFile object.

// You can create a timer to retrieve the statistics
// after you start the encoder engine.

    hr = pOutputStats->get_AverageBitrate(&lAvgBitrate);
    hr = pOutputStats->get_AverageSampleRate(&lAvgSampleRate);
    hr = pOutputStats->get_ByteCount(&qwByteCount);
    hr = pOutputStats->get_CurrentBitrate(&lCurrentBitRate);
    hr = pOutputStats->get_CurrentSampleRate(&lCurrentSampleRate);
    hr = pOutputStats->get_DroppedByteCount(&qwDroppedByteCount);
    hr = pOutputStats->get_DroppedSampleCount(&qwDroppedSampleCount);
    hr = pOutputStats->get_ExpectedBitrate(&lExpectedBitRate);
    hr = pOutputStats->get_ExpectedSampleRate(&lExpectedSampleRate);
    hr = pOutputStats->get_SampleCount(&qwSampleCount);

See Also

  • IWMEncStatistics Interface
  • IWMEncOutputStats Interface


IWMEncTransform Interface

The IWMEncTransform interface specifies and retrieves transform plug-ins. In addition to the methods inherited from IDispatch, the IWMEncTransform interface exposes the following methods.

Method | Description
GetInput | Retrieves the name and scheme of a transform plug-in.
GetTransformPlugin | Retrieves a pointer to a transform plug-in.
SetInput | Specifies a transform plug-in by name and scheme.

See Also

  • [Visual Basic] IWMEncTransform Object


IWMEncTransform::GetInput

The GetInput method retrieves the name and scheme of a transform plug-in.

Syntax

HRESULT GetInput(
  BSTR*  pbstrScheme,
  BSTR*  pbstrInitData,
  BSTR*  pbstrInput
);

Parameters

pbstrScheme

[out] Pointer to a BSTR containing the scheme type.

pbstrInitData

[out] Pointer to a BSTR containing optional initialization data.

pbstrInput

[out] Pointer to a BSTR containing the name of the transform plug-in.

Return Values

If the method succeeds, it returns S_OK. If it fails, it supports the IErrorInfo interface and returns an HRESULT error code.

Return code | Number | Meaning
E_OUTOFMEMORY | 0x8007000E | Memory cannot be allocated.

Example Code

// Include libraries.

#include <windows.h>
#include <atlbase.h>
#include "wmencode.h"

// Declare variables.

    HRESULT hr;
    IWMEncoder* pEncoder;
    IWMEncSourceGroupCollection* pSrcGrpColl;
    IWMEncSourceGroup* pSrcGrp;
    IWMEncSource* pAudSrc;
    IWMEncSource* pVidSrc;
    IWMEncTransformCollection* pTransColl;
    IWMEncTransform* pTransform;

// Initialize the COM library and retrieve a pointer
// to an IWMEncoder interface.

    hr = CoInitialize(NULL);
    CoCreateInstance(CLSID_WMEncoder,
                     NULL,
                     CLSCTX_INPROC_SERVER,
                     IID_IWMEncoder,
                     (void**) &pEncoder);

// Retrieve a pointer to an IWMEncSourceGroupCollection
// interface.

    hr = pEncoder->get_SourceGroupCollection(&pSrcGrpColl);

// Add a source group to the collection.

    hr = pSrcGrpColl->Add(L"SG_1", &pSrcGrp);

// Add a video and audio source to the source group.

    hr = pSrcGrp->AddSource(WMENC_VIDEO, &pVidSrc);
    hr = pSrcGrp->AddSource(WMENC_AUDIO, &pAudSrc);

// Retrieve the transform collection from the source group.

    hr = pSrcGrp->get_GroupTransformCollection(&pTransColl);

// Add an IWMEncTransform object to the collection.

    hr = pTransColl->Add(&pTransform);

// Set the time compression plug-in for the source group.

    hr = pTransform->SetInput(
    L"TCGroupTransformPlugin://TimeCompression1"
    );

// Retrieve the name of the transform plug-in.

    CComBSTR bstrScheme;
    CComBSTR bstrInitData;
    CComBSTR bstrTransName;

    hr = pTransform->GetInput(&bstrScheme,&bstrInitData, &bstrTransName);

See Also

  • IWMEncTransformCollection::get_Count
  • IWMEncTransform::GetTransformPlugin
  • IWMEncTransform Interface
  • IWMEncTransform::SetInput


IWMEncTransform::GetTransformPlugin

The GetTransformPlugin method retrieves a pointer to a transform plug-in.

Syntax

HRESULT GetTransformPlugin(
  IUnknown**  ppUnkPlugin
);

Parameters

ppUnkPlugin

[out] Pointer to the IUnknown pointer of a transform plug-in.

Return Values

If the method succeeds, it returns S_OK. If it fails, it supports the IErrorInfo interface.

Remarks

You can use this method to retrieve the property pages supported by a specific transform plug-in.

Example Code

// Include libraries.

#include <windows.h>
#include <atlbase.h>
#include "wmencode.h"

// Declare variables.

    HRESULT hr;
    IWMEncoder* pEncoder;
    IWMEncSourceGroupCollection* pSrcGrpColl;
    IWMEncSourceGroup* pSrcGrp;
    IWMEncSource *pVidSrc, *pAudSrc;
    IWMEncProfileCollection* pProColl;
    IWMEncProfile* pPro;
    IWMEncTransformCollection* pTransColl;
    IWMEncTransform* pTrans;
    IUnknown* pPlugin = NULL;
    ISpecifyPropertyPages* pPages = NULL;
    CAUUID uuid;
    HWND m_hWnd = NULL;

    long lCount;
    int i;

// Initialize the COM library and retrieve a pointer
// to an IWMEncoder interface.

    hr = CoInitialize(NULL);
    hr = CoCreateInstance(CLSID_WMEncoder,
                          NULL,
                          CLSCTX_INPROC_SERVER,
                          IID_IWMEncoder,
                          (void**) &pEncoder);

// Retrieve a pointer to an IWMEncSourceGroupCollection
// interface.

    hr = pEncoder->get_SourceGroupCollection(&pSrcGrpColl);

// Add an empty source group to the collection.

    hr = pSrcGrpColl->Add(L"SG_1", &pSrcGrp);

// Add video and audio streams to the source group.

    hr = pSrcGrp->AddSource(WMENC_VIDEO, &pVidSrc);
    hr = pSrcGrp->AddSource(WMENC_AUDIO, &pAudSrc);

// Specify the plug-ins to use for capturing streams from the
// video card.

    hr = pVidSrc->SetInput(L"DEVICE://Default_Video_Device");
    hr = pAudSrc->SetInput(L"DEVICE://Default_Audio_Device");

// Loop through the profile collection and retrieve a specific
// profile.

    hr = pEncoder->get_ProfileCollection(&pProColl);
    CComVariant varProfile;
    varProfile.vt = VT_DISPATCH;
    hr = pProColl->get_Count(&lCount);
    for (i=0; i<lCount; i++)
    {
        CComBSTR bstrName(L" ");
        hr = pProColl->Item(i, &pPro);
        hr = pPro->get_Name(&bstrName);
        if (_wcsicmp(bstrName, L"profile_name")==0)
        {
            varProfile.pdispVal = pPro;
            pSrcGrp->put_Profile(varProfile);
            break;
        }
    }

// Retrieve the group transform collection.

    hr = pSrcGrp->get_GroupTransformCollection(&pTransColl);

// Add a transform plug-in to the collection.

    hr = pTransColl->Add(&pTrans);

// Set the time compression plug-in.

    hr = pTrans->SetInput(
             L"TCGroupTransformPlugin://");

// Initialize the encoder engine.

    hr = pEncoder->PrepareToEncode(VARIANT_TRUE);

// Retrieve an IUnknown pointer to the transform plug-in object.

    hr = pTrans->GetTransformPlugin(&pPlugin);

// Call QueryInterface to verify whether the plug-in supports
// property pages. If it does, retrieve a pointer to the
// ISpecifyPropertyPages interface, and fill an array of GUID
// values in which each GUID specifies the CLSID of each property
// page that can be displayed for this object.

    hr = pPlugin->QueryInterface(IID_ISpecifyPropertyPages,
                                (LPVOID*)&pPages);

    hr = pPages->GetPages( &uuid );

// Invoke a dialog box to display.

    hr = OleCreatePropertyFrame
         (
          m_hWnd,              // You must create the parent window.
          200,                 // Horizontal position for the dialog box.
          200,                 // Vertical position for the dialog box.
          L"name",             // String used for the dialog box caption.
          1,                   // Number of pointers passed in pPlugin.
          &pPlugin,            // Pointer to the plug-in.
          uuid.cElems,         // Number of property pages.
          uuid.pElems,         // Array of property page CLSIDs.
          LOCALE_USER_DEFAULT, // Locale ID for the dialog box.
          0,                   // Reserved.
          NULL                 // Reserved.
          );

// Release memory.

    if ( uuid.pElems )
    {
        CoTaskMemFree( uuid.pElems );
    }

See Also

  • IWMEncTransformCollection::get_Count
  • IWMEncTransform::GetInput
  • IWMEncTransform Interface
  • IWMEncTransform::SetInput


IWMEncTransform::SetInput

The SetInput method specifies a transform plug-in by name and scheme.

Syntax

HRESULT SetInput(
  BSTR  bstrInput,
  BSTR  bstrScheme,
  BSTR  bstrInitData
);

Parameters

bstrInput

[in] BSTR containing the full name of a transform plug-in. Specify a plug-in name in the "scheme://resource" format. If you put only the "resource" in bstrInput, and not the full path, Windows Media Encoder examines pbstrScheme to find the scheme type.

bstrScheme

[in] BSTR containing the scheme type. If you supply a value for this parameter, Windows Media Encoder examines bstrInput to form a "scheme://resource" plug-in identifier without parsing the stream. This is useful if the "resource" part of the string contains special characters or symbols that cannot be interpreted as part of a standard URL.

bstrInitData

[in] BSTR containing optional initialization data for the plug-in.

Return Values

If the method succeeds, it returns S_OK. If it fails, it supports the IErrorInfo interface and returns an HRESULT error code.

Return code | Number | Meaning
NS_E_INVALIDCALL_WHILE_ENCODER_RUNNING | 0xC00D0011 | This method cannot be called if the encoder engine is running.

Remarks

You must call the Add method in the IWMEncTransformCollection interface before calling SetInput.

Example Code

// Include libraries.

#include <windows.h>
#include <atlbase.h>
#include "wmencode.h"

// Declare variables.

    HRESULT hr;
    IWMEncoder* pEncoder;
    IWMEncSourceGroupCollection* pSrcGrpColl;
    IWMEncSourceGroup* pSrcGrp;
    IWMEncSource* pAudSrc;
    IWMEncSource* pVidSrc;
    IWMEncTransformCollection* pTransColl;
    IWMEncTransform* pTransform;

// Initialize the COM library and retrieve a pointer
// to an IWMEncoder interface.

    hr = CoInitialize(NULL);
    CoCreateInstance(CLSID_WMEncoder,
                     NULL,
                     CLSCTX_INPROC_SERVER,
                     IID_IWMEncoder,
                     (void**) &pEncoder);

// Retrieve a pointer to an IWMEncSourceGroupCollection
// interface.

    hr = pEncoder->get_SourceGroupCollection(&pSrcGrpColl);

// Add a source group to the collection.

    hr = pSrcGrpColl->Add(L"SG_1", &pSrcGrp);

// Add a video and audio source to the source group.

    hr = pSrcGrp->AddSource(WMENC_VIDEO, &pVidSrc);
    hr = pSrcGrp->AddSource(WMENC_AUDIO, &pAudSrc);

// Retrieve the transform collection from the source group.

    hr = pSrcGrp->get_GroupTransformCollection(&pTransColl);

// Add an IWMEncTransform object to the collection.

    hr = pTransColl->Add(&pTransform);

// Set the time compression plug-in for the source group.

    hr = pTransform->SetInput(
    L"TCGroupTransformPlugin://TimeCompression1"
    );

See Also

  • IWMEncTransformCollection::Add
  • IWMEncTransform::GetInput
  • IWMEncTransform Interface
  • IWMEncTransformCollection Interface


IWMEncTransformCollection Interface

The IWMEncTransformCollection interface manages the collection of transform plug-ins used by Windows Media Encoder. The order of plug-ins in this collection determines the order that the transformations are applied to the media streams. This collection contains only the transform plug-ins that are applied during the current session. The entire collection of transform plug-ins is enumerated by the IWMEncTransformPluginInfoManager interface.

In addition to the methods inherited from IDispatch, the IWMEncTransformCollection interface exposes the following methods.

Method | Description
Add | Adds a transform plug-in to the collection.
get_Count | Retrieves the number of transform plug-ins in the collection.
get_length | Retrieves the number of transform plug-ins in the collection.
Item | Retrieves a specific transform plug-in.
Move | Places one transform plug-in in front of another in the collection.
Remove | Removes a specific plug-in from the collection.
RemoveAll | Removes all plug-ins from the collection.

See Also

  • [Visual Basic] IWMEncTransformCollection Object
  • Interfaces (C++)


IWMEncTransformCollection::Add

The Add method adds a transform plug-in to the collection.

Syntax

HRESULT Add(
  IWMEncTransform**  ppTransform
);

Parameters

ppTransform

[out] Pointer to a pointer to a transform plug-in.

Return Values

If the method succeeds, it returns S_OK. If it fails, it supports the IErrorInfo interface and returns an HRESULT error code.

Return code | Number | Meaning
E_FAIL | 0x80004005 | An unspecified error occurred.
E_OUTOFMEMORY | 0x8007000E | Memory cannot be allocated.
E_POINTER | 0x80004003 | The indirect pointer to a transform plug-in is NULL.

Remarks

Use the Add method to add a transform plug-in to the collection. Use the IWMEncTransform::SetInput method to add a specific plug-in.

Example Code

// Include libraries.

#include <windows.h>
#include <atlbase.h>
#include "wmencode.h"

// Declare variables.

    HRESULT hr;
    IWMEncoder* pEncoder;
    IWMEncSourceGroupCollection* pSrcGrpColl;
    IWMEncSourceGroup* pSrcGrp;
    IWMEncSource* pAudSrc;
    IWMEncSource* pVidSrc;
    IWMEncTransformCollection* pTransColl;
    IWMEncTransform* pTransform;

// Initialize the COM library and retrieve a pointer
// to an IWMEncoder interface.

    hr = CoInitialize(NULL);
    CoCreateInstance(CLSID_WMEncoder,
                     NULL,
                     CLSCTX_INPROC_SERVER,
                     IID_IWMEncoder,
                     (void**) &pEncoder);

// Retrieve a pointer to an IWMEncSourceGroupCollection
// interface.

    hr = pEncoder->get_SourceGroupCollection(&pSrcGrpColl);

// Add a source group to the collection.

    hr = pSrcGrpColl->Add(L"SG_1", &pSrcGrp);

// Add a video and audio source to the source group.

    hr = pSrcGrp->AddSource(WMENC_VIDEO, &pVidSrc);
    hr = pSrcGrp->AddSource(WMENC_AUDIO, &pAudSrc);

// Retrieve the transform collection from the source group.

    hr = pSrcGrp->get_GroupTransformCollection(&pTransColl);

// Add an IWMEncTransform object to the collection.

    hr = pTransColl->Add(&pTransform);

// Set the time compression plug-in for the source group.

    hr = pTransform->SetInput(
    L"TCGroupTransformPlugin://TimeCompression1"
    );

// Retrieve the name of the transform plug-in.

    CComBSTR bstrScheme;
    CComBSTR bstrInitData;
    CComBSTR bstrTransName;

    hr = pTransform->GetInput(&bstrScheme,&bstrInitData, &bstrTransName);

See Also

  • IWMEncTransformCollection Interface
  • IWMEncTransformCollection::Remove
  • IWMEncTransform::SetInput


IWMEncTransformCollection::get_Count

The get_Count method retrieves the number of transform plug-ins in the collection.

Syntax

HRESULT get_Count(
  long*  plCount
);

Parameters

plCount

[out] Pointer to a long containing the number of plug-ins.

Return Values

If the method succeeds, it returns S_OK.

Remarks

The current version of the Windows Media Encoder SDK includes only one transform plug-in. For more information, see the Time Compression Plug-in section of the Programming Guide.

See Also

  • IWMEncTransformCollection::get_length
  • IWMEncTransformCollection Interface
  • Programming Guide
  • Time Compression Plug-in


IWMEncTransformCollection::get_length

The get_length method retrieves the number of transform plug-ins in the collection.

Syntax

HRESULT get_length(
  long*  plCount
);

Parameters

plCount

[out] Pointer to a long containing the number of source groups.

Return Values

If the method succeeds, it returns S_OK.

Remarks

This is the JScript version of the get_Count method. The current version of the Windows Media Encoder SDK includes only one transform plug-in. For more information, see the Time Compression Plug-in section of the Programming Guide.

See Also

  • IWMEncTransformCollection::get_Count
  • IWMEncTransformCollection Interface
  • Programming Guide
  • Time Compression Plug-in


IWMEncTransformCollection::Item

The Item retrieves a specific transform plug-in.

Syntax

HRESULT Item(
  long  lIndex,
  IWMEncTransform**  ppTransform
);

Parameters

lIndex

[in] long containing the index of the plug-in.

ppTransform

[out] Pointer to a pointer to the transform plug-in

Return Values

If the method succeeds, it returns S_OK.

Remarks

The current version of the Windows Media Encoder SDK includes only one transform plug-in. For more information, see the Time Compression Plug-in section of the Programming Guide.

See Also

  • IWMEncTransformCollection Interface
  • Programming Guide
  • Time Compression Plug-in


IWMEncTransformCollection::Move

The Move method places one transform plug-in in front of another in the collection.

Syntax

HRESULT Move(
  long  lMove,
  long  lInFrontOf
);

Parameters

varMove

[in] long containing the numeric index of the plug-in being moved.

varInFrontOf

[in] long containing the numeric index of the plug-in that lMove is placed in front of.

Return Values

If the method succeeds, it returns S_OK. If it fails, it supports the IErrorInfo interface and returns an HRESULT error code.

Return code | Number | Meaning
NS_E_INVALID_INDEX | 0xC00D1B66 | An index identifying the position of a plug-in in the collection is not valid.
NS_E_INVALIDCALL_WHILE_ENCODER_RUNNING | 0xC00D0011 | This method cannot be called if the encoder engine is running.

Remarks

The order of the transform plug-ins in the collection dictates the order that the plug-ins are applied to a stream. However, the current version of the Windows Media Encoder SDK includes only one transform plug-in. For more information, see the Time Compression Plug-in section of the Programming Guide.

See Also

  • IWMEncTransformCollection Interface
  • Programming Guide
  • Time Compression Plug-in


IWMEncTransformCollection::Remove

The Remove method removes a specific plug-in from the collection.

Syntax

HRESULT Remove(
  long  lIndex
);

Parameters

lIndex

[in] long containing the numeric index of the plug-in.

Return Values

If the method succeeds, it returns S_OK. If it fails, it supports the IErrorInfo interface and returns an HRESULT error code.

Return code | Number | Meaning
NS_E_INVALIDCALL_WHILE_ENCODER_RUNNING | 0xC00D0011 | This method cannot be called if the encoder engine is running.

See Also

  • IWMEncTransformCollection::Add
  • IWMEncTransformCollection Interface
  • IWMEncTransformCollection::RemoveAll


IWMEncTransformCollection::RemoveAll

The RemoveAll method removes all plug-ins from the collection.

Syntax

HRESULT RemoveAll();

Parameters

This method takes no parameters.

Return Values

If the method succeeds, it returns S_OK. If it fails, it supports the IErrorInfo interface and returns an HRESULT error code.

Return code | Number | Meaning
NS_E_INVALIDCALL_WHILE_ENCODER_RUNNING | 0xC00D0011 | This method cannot be called if the encoder engine is running.

See Also

  • IWMEncTransformCollection Interface
  • IWMEncTransformCollection::Remove


IWMEncTransformPluginInfoManager Interface

The IWMEncTransformPluginInfoManager interface searches the plug-in registration information to populate a collection of transform IWMEncPluginInfo objects. In addition to the methods inherited from IDispatch, the IWMEncTransformPluginInfoManager interface exposes the following methods.

Method | Description
get_Count | Retrieves the number of registered transform plug-ins.
get_length | Retrieves the number of registered transform plug-ins. This is the JScript version of the get_Count method.
Item | Retrieves registry information about a specific transform plug-in object in the collection.
Refresh | Removes the old collection and populates a new collection of transform plug-in registration structures.

See Also

  • [Visual Basic] IWMEncTransformPluginInfoManager Object
  • Interfaces (C++)
  • IWMEncPluginInfo Interface


IWMEncTransformPluginInfoManager::get_Count

The get_Count method retrieves the number of registered transform plug-ins.

Syntax

HRESULT get_Count(
  long*  plCount
);

Parameters

plCount

[out] Pointer to a long containing the number of plug-ins.

Return Values

If the method succeeds, it returns S_OK.

Example Code

// Include libraries.

#include <windows.h>
#include <atlbase.h>
#include "wmencode.h"

// Declare variables.

    HRESULT hr;
    IWMEncoder* pEncoder;
    IWMEncTransformPluginInfoManager* pTransPlugMgr;
    IWMEncPluginInfo* pPlugInfo;

    int i;
    long lPlugCount;
    VARIANT_BOOL bExclusive;
    VARIANT_BOOL bHidden;
    VARIANT_BOOL bResources;
    VARIANT_BOOL bPropPages;
    CComBSTR bstrScheme;
    CComBSTR bstrCLSID;
    CComBSTR bstrCopyright;
    CComBSTR bstrURL;
    CComBSTR bstrName;

// Initialize the COM library and retrieve a pointer
// to an IWMEncoder interface.

    hr = CoInitialize(NULL);
    hr = CoCreateInstance(CLSID_WMEncoder,
                          NULL,
                          CLSCTX_INPROC_SERVER,
                          IID_IWMEncoder,
                          (void**) &pEncoder);

// Retrieve an IWMEncSourcePluginInfoManager pointer.

    hr = pEncoder->get_TransformPluginInfoManager(&pTransPlugMgr);

// Loop through the source plug-ins. Call the Item method on each
// plug-in to retrieve an IWMEncPluginInfo object. Use the
// IWMEncPluginInfo object to retrieve information about the
// plug-in.

    hr = pTransPlugMgr->get_Count(&lPlugCount);
    for (i=0; i<lPlugCount; i++)
    {
        hr = pTransPlugMgr->Item(i, &pPlugInfo);

        // Retrieve the plug-in scheme type.
        hr = pPlugInfo->get_SchemeType(&bstrScheme);

        // Determine whether the plug-in supports resources.
        hr = pPlugInfo->get_Resources(&bResources);

        // Retrieve the plug-in GUID.
        hr = pPlugInfo->get_CLSID(&bstrCLSID);

        // Retrieve the copyright information.
        hr = pPlugInfo->get_Copyright(&bstrCopyright);

        // Determine whether the plug-in can be used more
        // than once in a source group.
        hr = pPlugInfo->get_Exclusive(&bExclusive);

        // Determine whether the plug-in is hidden from the UI.
        hr = pPlugInfo->get_Hidden(&bHidden);

        // Retrieve the URL, if any, of the Web site
        // containing information about the plug-in.
        hr = pPlugInfo->get_InfoURL(&bstrURL);

        // Retrieve the name of the plug-in.
        hr = pPlugInfo->get_Name(&bstrName);

        // Determine whether the plug-in supports property pages.
        hr = pPlugInfo->get_PropertyPage(&bPropPages);
    }

See Also

  • IWMEncTransformPluginInfoManager Interface


IWMEncTransformPluginInfoManager::get_length

The get_length method retrieves the number of registered transform plug-ins.

Syntax

HRESULT get_length(
  long*  plCount
);

Parameters

plCount

[out] Pointer to a long containing the number of transform plug-ins.

Return Values

If the method succeeds, it returns S_OK.

Remarks

This method is the JScript version of the IWMEncTransformPluginInfoManager::get_Count method. It is provided for JScript developers or developers more accustomed to the JScript syntax.

Example Code

// Include libraries.

#include <windows.h>
#include <atlbase.h>
#include "wmencode.h"

// Declare variables.

    HRESULT hr;
    IWMEncoder* pEncoder;
    IWMEncTransformPluginInfoManager* pTransPlugMgr;
    IWMEncPluginInfo* pPlugInfo;

    int i;
    long lPlugCount;
    VARIANT_BOOL bExclusive;
    VARIANT_BOOL bHidden;
    VARIANT_BOOL bResources;
    VARIANT_BOOL bPropPages;
    CComBSTR bstrScheme;
    CComBSTR bstrCLSID;
    CComBSTR bstrCopyright;
    CComBSTR bstrURL;
    CComBSTR bstrName;

// Initialize the COM library and retrieve a pointer
// to an IWMEncoder interface.

    hr = CoInitialize(NULL);
    hr = CoCreateInstance(CLSID_WMEncoder,
                          NULL,
                          CLSCTX_INPROC_SERVER,
                          IID_IWMEncoder,
                          (void**) &pEncoder);

// Retrieve an IWMEncSourcePluginInfoManager pointer.

    hr = pEncoder->get_TransformPluginInfoManager(&pTransPlugMgr);

// Loop through the source plug-ins. Call the Item method on each
// plug-in to retrieve an IWMEncPluginInfo object. Use the
// IWMEncPluginInfo object to retrieve information about the
// plug-in.

    hr = pTransPlugMgr->get_Count(&lPlugCount);
    for (i=0; i<lPlugCount; i++)
    {
        hr = pTransPlugMgr->Item(i, &pPlugInfo);

        // Retrieve the plug-in scheme type.
        hr = pPlugInfo->get_SchemeType(&bstrScheme);

        // Determine whether the plug-in supports resources.
        hr = pPlugInfo->get_Resources(&bResources);

        // Retrieve the plug-in GUID.
        hr = pPlugInfo->get_CLSID(&bstrCLSID);

        // Retrieve the copyright information.
        hr = pPlugInfo->get_Copyright(&bstrCopyright);

        // Determine whether the plug-in can be used more
        // than once in a source group.
        hr = pPlugInfo->get_Exclusive(&bExclusive);

        // Determine whether the plug-in is hidden from the UI.
        hr = pPlugInfo->get_Hidden(&bHidden);

        // Retrieve the URL, if any, of the Web site
        // containing information about the plug-in.
        hr = pPlugInfo->get_InfoURL(&bstrURL);

        // Retrieve the name of the plug-in.
        hr = pPlugInfo->get_Name(&bstrName);

        // Determine whether the plug-in supports property pages.
        hr = pPlugInfo->get_PropertyPage(&bPropPages);
    }

See Also

  • IWMEncTransformPluginInfoManager::get_Count
  • IWMEncTransformPluginInfoManager Interface


IWMEncTransformPluginInfoManager::Item

The Item method retrieves registry information about a specific transform plug-in object in the collection

Syntax

HRESULT Item(
  long  iIndex,
  IWMEncPluginInfo**  ppPluginInfo
);

Parameters

var

[in] VARIANT containing the numeric index of the plug-in.

ppPluginInfo

[out] Pointer to a pointer to an IWMEncPluginInfo object.

Return Values

If the method succeeds, it returns S_OK.

Example Code

// Include libraries.

#include <windows.h>
#include <atlbase.h>
#include "wmencode.h"

// Declare variables.

    HRESULT hr;
    IWMEncoder* pEncoder;
    IWMEncTransformPluginInfoManager* pTransPlugMgr;
    IWMEncPluginInfo* pPlugInfo;

    int i;
    long lPlugCount;
    VARIANT_BOOL bExclusive;
    VARIANT_BOOL bHidden;
    VARIANT_BOOL bResources;
    VARIANT_BOOL bPropPages;
    CComBSTR bstrScheme;
    CComBSTR bstrCLSID;
    CComBSTR bstrCopyright;
    CComBSTR bstrURL;
    CComBSTR bstrName;

// Initialize the COM library and retrieve a pointer
// to an IWMEncoder interface.

    hr = CoInitialize(NULL);
    hr = CoCreateInstance(CLSID_WMEncoder,
                          NULL,
                          CLSCTX_INPROC_SERVER,
                          IID_IWMEncoder,
                          (void**) &pEncoder);

// Retrieve an IWMEncSourcePluginInfoManager pointer.

    hr = pEncoder->get_TransformPluginInfoManager(&pTransPlugMgr);

// Loop through the source plug-ins. Call the Item method on each
// plug-in to retrieve an IWMEncPluginInfo object. Use the
// IWMEncPluginInfo object to retrieve information about the
// plug-in.

    hr = pTransPlugMgr->get_Count(&lPlugCount);
    for (i=0; i<lPlugCount; i++)
    {
        hr = pTransPlugMgr->Item(i, &pPlugInfo);

        // Retrieve the plug-in scheme type.
        hr = pPlugInfo->get_SchemeType(&bstrScheme);

        // Determine whether the plug-in supports resources.
        hr = pPlugInfo->get_Resources(&bResources);

        // Retrieve the plug-in GUID.
        hr = pPlugInfo->get_CLSID(&bstrCLSID);

        // Retrieve the copyright information.
        hr = pPlugInfo->get_Copyright(&bstrCopyright);

        // Determine whether the plug-in can be used more
        // than once in a source group.
        hr = pPlugInfo->get_Exclusive(&bExclusive);

        // Determine whether the plug-in is hidden from the UI.
        hr = pPlugInfo->get_Hidden(&bHidden);

        // Retrieve the URL, if any, of the Web site
        // containing information about the plug-in.
        hr = pPlugInfo->get_InfoURL(&bstrURL);

        // Retrieve the name of the plug-in.
        hr = pPlugInfo->get_Name(&bstrName);

        // Determine whether the plug-in supports property pages.
        hr = pPlugInfo->get_PropertyPage(&bPropPages);

    }

See Also

  • IWMEncPluginInfo Interface
  • IWMEncTransformPluginInfoManager Interface


IWMEncTransformPluginInfoManager::Refresh

The Refresh method removes the old collection and populates a new collection of transform plug-in registration structures.

Syntax

HRESULT Refresh();

Parameters

This method takes no parameters.

Return Values

If the method succeeds, it returns S_OK.

Remarks

Because you cannot register new plug-ins in the current version of Windows Media Encoder, the Refresh method provides no useful functionality.

See Also

  • IWMEncTransformPluginInfoManager Interface


IWMEncVideoSource Interface

The IWMEncVideoSource interface manages video image cropping to eliminate the bad pixels that often occur at the edges of video streams and imported images. Windows Media Encoder adjusts the cropped image to fill the destination size specified in the associated profile.

In addition to the methods inherited from IWMEncSource, the IWMEncVideoSource interface exposes the following methods.

Method | Description
get_CroppingBottomMargin | Retrieves the number of pixels to be removed from the lower edge of an image.
get_CroppingLeftMargin | Retrieves the number of pixels to be removed from the left edge of an image.
get_CroppingMode | Retrieves a member of an enumeration type indicating the image cropping mode.
get_CroppingRightMargin | Retrieves the number of pixels to be removed from the right edge of an image.
get_CroppingTopMargin | Retrieves the number of pixels to be removed from the top edge of an image.
get_Optimization | Retrieves the type of video optimization performed during the encoding process.
get_PixelFormat | Retrieves the pixel format for the video image.
put_CroppingBottomMargin | Specifies the number of pixels to be removed from the lower edge of an image.
put_CroppingLeftMargin | Specifies the number of pixels to be removed from the left edge of an image.
put_CroppingMode | Specifies a member of an enumeration type indicating the image cropping mode.
put_CroppingRightMargin | Specifies the number of pixels to be removed from the right edge of an image.
put_CroppingTopMargin | Specifies the number of pixels to be removed from the top edge of an image.
put_Optimization | Specifies the type of video optimization performed during the encoding process.
put_PixelFormat | Specifies the pixel format for the video image.

See Also

  • [Visual Basic] IWMEncVideoSource Object
  • Interfaces (C++)
  • IWMEncSource Interface


IWMEncVideoSource::get_CroppingBottomMargin

The get_CroppingBottomMargin method retrieves the number of pixels to be removed from the lower edge of an image.

Syntax

HRESULT get_CroppingBottomMargin(
  long*  plBottom
);

Parameters

plBottom

[out] Pointer to a long containing the number of pixels to be cropped.

Return Values

If the method succeeds, it returns S_OK. If it fails, it supports the IErrorInfo interface and returns an HRESULT error code.

Return code | Number | Meaning
E_POINTER | 0x80004003 | The pointer to the number of pixels to crop is NULL.

Example Code

// Include libraries.

#include <windows.h>
#include "wmencode.h"

// Declare variables.

    HRESULT hr;
    IWMEncoder* pEncoder;
    IWMEncSourceGroupCollection* pSrcGrpColl;
    IWMEncSourceGroup* pSrcGrp;
    IWMEncSource* pAudSrc;
    IWMEncSource* pSrc;
    IWMEncVideoSource* pVidSrc;

// Initialize the COM library and retrieve a pointer
// to an IWMEncoder interface.

    hr = CoInitialize(NULL);
    CoCreateInstance(CLSID_WMEncoder,
                     NULL,
                     CLSCTX_INPROC_SERVER,
                     IID_IWMEncoder,
                     (void**) &pEncoder);

// Retrieve an IWMEncSourceGroupCollection pointer.

    hr = pEncoder->get_SourceGroupCollection(&pSrcGrpColl);

// Add a source group to the collection.

    hr = pSrcGrpColl->Add(L"SG_1", &pSrcGrp);

// Add a video stream to the source group.

    hr = pSrcGrp->AddSource(WMENC_VIDEO, &pSrc);
    hr = pSrcGrp->AddSource(WMENC_AUDIO, &pAudSrc);

// Retrieve an IWMEncVideoSource pointer.

    hr = pSrc->QueryInterface(IID_IWMEncVideoSource, (void**)&pVidSrc);

// Specify the cropping margins.

    hr = pVidSrc->put_CroppingBottomMargin(5);
    hr = pVidSrc->put_CroppingTopMargin(5);
    hr = pVidSrc->put_CroppingLeftMargin(3);
    hr = pVidSrc->put_CroppingRightMargin(3);

// Retrieve the cropping margins.

    hr = pVidSrc->get_CroppingBottomMargin(&lBottom);
    hr = pVidSrc->get_CroppingTopMargin(&lTop);
    hr = pVidSrc->get_CroppingLeftMargin(&lLeft);
    hr = pVidSrc->get_CroppingRightMargin(&lRight);

See Also

  • IWMEncVideoSource Interface
  • IWMEncVideoSource::put_CroppingBottomMargin


IWMEncVideoSource::get_CroppingLeftMargin

The get_CroppingLeftMargin method retrieves the number of pixels to be removed from the left edge of an image.

Syntax

HRESULT get_CroppingLeftMargin(
  long*  plLeft
);

Parameters

plLeft

[out] Pointer to a long containing the number of pixels to be cropped.

Return Values

If the method succeeds, it returns S_OK. If it fails, it supports the IErrorInfo interface and returns an HRESULT error code.

Return code | Number | Meaning
E_POINTER | 0x80004003 | The pointer to the number of pixels to crop is NULL.

Example Code

// Include libraries.

#include <windows.h>
#include "wmencode.h"

// Declare variables.

    HRESULT hr;
    IWMEncoder* pEncoder;
    IWMEncSourceGroupCollection* pSrcGrpColl;
    IWMEncSourceGroup* pSrcGrp;
    IWMEncSource* pAudSrc;
    IWMEncSource* pSrc;
    IWMEncVideoSource* pVidSrc;

// Initialize the COM library and retrieve a pointer
// to an IWMEncoder interface.

    hr = CoInitialize(NULL);
    CoCreateInstance(CLSID_WMEncoder,
                     NULL,
                     CLSCTX_INPROC_SERVER,
                     IID_IWMEncoder,
                     (void**) &pEncoder);

// Retrieve an IWMEncSourceGroupCollection pointer.

    hr = pEncoder->get_SourceGroupCollection(&pSrcGrpColl);

// Add a source group to the collection.

    hr = pSrcGrpColl->Add(L"SG_1", &pSrcGrp);

// Add a video stream to the source group.

    hr = pSrcGrp->AddSource(WMENC_VIDEO, &pSrc);
    hr = pSrcGrp->AddSource(WMENC_AUDIO, &pAudSrc);

// Retrieve an IWMEncVideoSource pointer.

    hr = pSrc->QueryInterface(IID_IWMEncVideoSource, (void**)&pVidSrc);

// Specify the cropping margins.

    hr = pVidSrc->put_CroppingBottomMargin(5);
    hr = pVidSrc->put_CroppingTopMargin(5);
    hr = pVidSrc->put_CroppingLeftMargin(3);
    hr = pVidSrc->put_CroppingRightMargin(3);

// Retrieve the cropping margins.

    hr = pVidSrc->get_CroppingBottomMargin(&lBottom);
    hr = pVidSrc->get_CroppingTopMargin(&lTop);
    hr = pVidSrc->get_CroppingLeftMargin(&lLeft);
    hr = pVidSrc->get_CroppingRightMargin(&lRight);

See Also

  • IWMEncVideoSource Interface
  • IWMEncVideoSource::put_CroppingLeftMargin


IWMEncVideoSource::get_CroppingMode

The get_CroppingMode method retrieves a member of an enumeration type that specifies the image cropping mode.

Syntax

HRESULT get_CroppingMode(
  WMENC_CROPPING_MODE*  penumCroppingMode
);

Parameters

penumCroppingMode

[out] Member of a WMENC_CROPPING_MODE enumeration type specifying the cropping mode. This must be the following value.

Value | Number | Description
WMENC_CROPPING_ABSOLUTE | 0 | The amount of an image to crop must be specified as an absolute number of pixels.

Return Values

If the method succeeds, it returns S_OK. If it fails, it supports the IErrorInfo interface and returns an HRESULT error code.

Return code | Number | Meaning
E_POINTER | 0x80004003 | The pointer to the cropping mode is NULL.

Remarks

Use the IWMEncVideoSource::put_CroppingMode method to specify the cropping mode.

See Also

  • IWMEncVideoSource Interface
  • IWMEncVideoSource::put_CroppingMode


IWMEncVideoSource::get_CroppingRightMargin

The get_CroppingRightMargin method retrieves the number of pixels to be removed from the right edge of an image.

Syntax

HRESULT get_CroppingRightMargin(
  long*  plRight
);

Parameters

plRight

[out] Pointer to a long containing the number of pixels to be cropped.

Return Values

If the method succeeds, it returns S_OK. If it fails, it supports the IErrorInfo interface and returns an HRESULT error code.

Return code | Number | Meaning
E_POINTER | 0x80004003 | The pointer to the number of pixels to crop is NULL.

Example Code

// Include libraries.

#include <windows.h>
#include "wmencode.h"

// Declare variables.

    HRESULT hr;
    IWMEncoder* pEncoder;
    IWMEncSourceGroupCollection* pSrcGrpColl;
    IWMEncSourceGroup* pSrcGrp;
    IWMEncSource* pAudSrc;
    IWMEncSource* pSrc;
    IWMEncVideoSource* pVidSrc;

// Initialize the COM library and retrieve a pointer
// to an IWMEncoder interface.

    hr = CoInitialize(NULL);
    CoCreateInstance(CLSID_WMEncoder,
                     NULL,
                     CLSCTX_INPROC_SERVER,
                     IID_IWMEncoder,
                     (void**) &pEncoder);

// Retrieve an IWMEncSourceGroupCollection pointer.

    hr = pEncoder->get_SourceGroupCollection(&pSrcGrpColl);

// Add a source group to the collection.

    hr = pSrcGrpColl->Add(L"SG_1", &pSrcGrp);

// Add a video stream to the source group.

    hr = pSrcGrp->AddSource(WMENC_VIDEO, &pSrc);
    hr = pSrcGrp->AddSource(WMENC_AUDIO, &pAudSrc);

// Retrieve an IWMEncVideoSource pointer.

    hr = pSrc->QueryInterface(IID_IWMEncVideoSource, (void**)&pVidSrc);

// Specify the cropping margins.

    hr = pVidSrc->put_CroppingBottomMargin(5);
    hr = pVidSrc->put_CroppingTopMargin(5);
    hr = pVidSrc->put_CroppingLeftMargin(3);
    hr = pVidSrc->put_CroppingRightMargin(3);

// Retrieve the cropping margins.

    hr = pVidSrc->get_CroppingBottomMargin(&lBottom);
    hr = pVidSrc->get_CroppingTopMargin(&lTop);
    hr = pVidSrc->get_CroppingLeftMargin(&lLeft);
    hr = pVidSrc->get_CroppingRightMargin(&lRight);

See Also

  • IWMEncVideoSource Interface
  • IWMEncVideoSource::put_CroppingRightMargin


IWMEncVideoSource::get_CroppingTopMargin

The get_CroppingTopMargin method retrieves the number of pixels to be removed from the top edge of an image.

Syntax

HRESULT get_CroppingTopMargin(
  long*  plTop
);

Parameters

plTop

[out] Pointer to a long containing the number of pixels to be cropped.

Return Values

If the method succeeds, it returns S_OK. If it fails, it supports the IErrorInfo interface and returns an HRESULT error code.

Return code | Number | Meaning
E_POINTER | 0x80004003 | The pointer to the number of pixels to crop is NULL.

Example Code

// Include libraries.

#include <windows.h>
#include "wmencode.h"

// Declare variables.

    HRESULT hr;
    IWMEncoder* pEncoder;
    IWMEncSourceGroupCollection* pSrcGrpColl;
    IWMEncSourceGroup* pSrcGrp;
    IWMEncSource* pAudSrc;
    IWMEncSource* pSrc;
    IWMEncVideoSource* pVidSrc;

// Initialize the COM library and retrieve a pointer
// to an IWMEncoder interface.

    hr = CoInitialize(NULL);
    CoCreateInstance(CLSID_WMEncoder,
                     NULL,
                     CLSCTX_INPROC_SERVER,
                     IID_IWMEncoder,
                     (void**) &pEncoder);

// Retrieve an IWMEncSourceGroupCollection pointer.

    hr = pEncoder->get_SourceGroupCollection(&pSrcGrpColl);

// Add a source group to the collection.

    hr = pSrcGrpColl->Add(L"SG_1", &pSrcGrp);

// Add a video stream to the source group.

    hr = pSrcGrp->AddSource(WMENC_VIDEO, &pSrc);
    hr = pSrcGrp->AddSource(WMENC_AUDIO, &pAudSrc);

// Retrieve an IWMEncVideoSource pointer.

    hr = pSrc->QueryInterface(IID_IWMEncVideoSource, (void**)&pVidSrc);

// Specify the cropping margins.

    hr = pVidSrc->put_CroppingBottomMargin(5);
    hr = pVidSrc->put_CroppingTopMargin(5);
    hr = pVidSrc->put_CroppingLeftMargin(3);
    hr = pVidSrc->put_CroppingRightMargin(3);

// Retrieve the cropping margins.

    hr = pVidSrc->get_CroppingBottomMargin(&lBottom);
    hr = pVidSrc->get_CroppingTopMargin(&lTop);
    hr = pVidSrc->get_CroppingLeftMargin(&lLeft);
    hr = pVidSrc->get_CroppingRightMargin(&lRight);

See Also

  • IWMEncVideoSource Interface
  • IWMEncVideoSource::put_CroppingTopMargin


IWMEncVideoSource::get_Optimization

The get_Optimization method retrieves the type of video optimization performed during the encoding process.

Syntax

HRESULT get_Optimization(
  WMENC_VIDEO_OPTIMIZATION*  penumOptimization
);

Parameters

penumOptimization

[out] Pointer to a member of a WMENC_VIDEO_OPTIMIZATION enumeration type that indicates the encoding optimization. This must be one of the following values.

Value | Number | Meaning
WMENC_VIDEO_STANDARD | 1 | Applies the standard compression algorithm during the encoding process.
WMENC_VIDEO_DEINTERLACE | 2 | Separates the interlaced video source to restore the original frames.
WMENC_VIDEO_INVERSETELECINE | 3 | Removes redundant video data from the video source.

Return Values

If the method succeeds, it returns S_OK. If it fails, it supports the IErrorInfo interface and returns an HRESULT error code.

Return code | Number | Meaning
E_POINTER | 0x80004003 | The pointer to the optimization value is NULL.

Remarks

Television signals are interlaced by combining two frames into one image. Windows Media Encoder can separate the frames to restore the original content. When film is translated to a digital format, frames can be added by using the telecine process to increase the frame rate. Windows Media Encoder can eliminate the redundant frames. In both cases, Windows Media Encoder uses optimization to produce higher-quality output. However, you must choose the correct optimization for the content being encoded.

See Also

  • IWMEncVideoSource Interface
  • IWMEncVideoSource::put_Optimization


IWMEncVideoSource::get_PixelFormat

The get_PixelFormat method retrieves the pixel format for the video image.

Syntax

HRESULT get_PixelFormat(
  WMENC_PIXELFORMAT_VIDEO*  penumPixelFormat
);

Parameters

penumPixelFormat

[out] Pointer to a member of a WMENC_PIXELFORMAT_VIDEO enumeration type that identifies the pixel format. This must be one of the following values.

Value | Number | Meaning
WMENC_PIXELFORMAT_AUTO | 0x00000001 | Windows Media Encoder selects the current format of the video image. This is the default value.
WMENC_PIXELFORMAT_IYUV | 0x56555949 | The IYUV format.
WMENC_PIXELFORMAT_I420 | 0x30323449 | The I420 format.
WMENC_PIXELFORMAT_YV12 | 0x32315659 | The YV12 format.
WMENC_PIXELFORMAT_YUY2 | 0x32595559 | The YUY2 format.
WMENC_PIXELFORMAT_UYVY | 0x59565955 | The UYVY format.
WMENC_PIXELFORMAT_YVYU | 0x55595659 | The YVYU format.
WMENC_PIXELFORMAT_YVU9 | 0x39555659 | The YVU9 format.
WMENC_PIXELFORMAT_RGB24 | 0xE436EB7D | The RGB24 format.
WMENC_PIXELFORMAT_RGB32 | 0xE436EB7E | The RGB32 format.
WMENC_PIXELFORMAT_RGB555 | 0xE436EB7C | The RGB555 format.
WMENC_PIXELFORMAT_RGB565 | 0xE436EB7B | The RGB565 format.
WMENC_PIXELFORMAT_RGB8 | 0xE436EB7A | The RGB8 format.
WMENC_PIXELFORMAT_RGB4 | 0xE436EB79 | The RGB4 format.
WMENC_PIXELFORMAT_RGB1 | 0xE436EB78 | The RGB1 format.

Return Values

If the method succeeds, it returns S_OK. If it fails, it supports the IErrorInfo interface and returns an HRESULT error code.

Return code | Number | Meaning
E_POINTER | 0x80004003 | The pointer to the pixel format is NULL.

Remarks

The formats are listed in the order of decreasing preference for use in Windows Media Encoder.

See Also

  • IWMEncVideoSource Interface
  • IWMEncVideoSource::put_PixelFormat


IWMEncVideoSource::put_CroppingBottomMargin

The put_CroppingBottomMargin method specifies the number of pixels to be removed from the lower edge of an image.

Syntax

HRESULT put_CroppingBottomMargin(
  long  lBottom
);

Parameters

lBottom

[in] long containing the number of pixels to be cropped.

Return Values

If the method succeeds, it returns S_OK. If it fails, it supports the IErrorInfo interface and returns an HRESULT error code.

Return code | Number | Meaning
NS_E_INVALIDCALL_WHILE_ENCODER_RUNNING | 0xC00D0011 | This method cannot be called if the encoder engine is running.

Example Code

// Include libraries.

#include <windows.h>
#include "wmencode.h"

// Declare variables.

    HRESULT hr;
    IWMEncoder* pEncoder;
    IWMEncSourceGroupCollection* pSrcGrpColl;
    IWMEncSourceGroup* pSrcGrp;
    IWMEncSource* pAudSrc;
    IWMEncSource* pSrc;
    IWMEncVideoSource* pVidSrc;

// Initialize the COM library and retrieve a pointer
// to an IWMEncoder interface.

    hr = CoInitialize(NULL);
    CoCreateInstance(CLSID_WMEncoder,
                     NULL,
                     CLSCTX_INPROC_SERVER,
                     IID_IWMEncoder,
                     (void**) &pEncoder);

// Retrieve an IWMEncSourceGroupCollection pointer.

    hr = pEncoder->get_SourceGroupCollection(&pSrcGrpColl);

// Add a source group to the collection.

    hr = pSrcGrpColl->Add(L"SG_1", &pSrcGrp);

// Add a video stream to the source group.

    hr = pSrcGrp->AddSource(WMENC_VIDEO, &pSrc);
    hr = pSrcGrp->AddSource(WMENC_AUDIO, &pAudSrc);

// Retrieve an IWMEncVideoSource pointer.

    hr = pSrc->QueryInterface(IID_IWMEncVideoSource, (void**)&pVidSrc);

// Specify the cropping margins.

    hr = pVidSrc->put_CroppingBottomMargin(5);
    hr = pVidSrc->put_CroppingTopMargin(5);
    hr = pVidSrc->put_CroppingLeftMargin(3);
    hr = pVidSrc->put_CroppingRightMargin(3);

// Retrieve the cropping margins.

    hr = pVidSrc->get_CroppingBottomMargin(&lBottom);
    hr = pVidSrc->get_CroppingTopMargin(&lTop);
    hr = pVidSrc->get_CroppingLeftMargin(&lLeft);
    hr = pVidSrc->get_CroppingRightMargin(&lRight);

See Also

  • IWMEncVideoSource::get_CroppingBottomMargin
  • IWMEncVideoSource Interface


IWMEncVideoSource::put_CroppingLeftMargin

The put_CroppingLeftMargin method specifies the number of pixels to be removed from the left edge of an image.

Syntax

HRESULT put_CroppingLeftMargin(
  long  lLeft
);

Parameters

lLeft

[in] long containing the number of pixels to be cropped.

Return Values

If the method succeeds, it returns S_OK. If it fails, it supports the IErrorInfo interface and returns an HRESULT error code.

Return code | Number | Meaning
NS_E_INVALIDCALL_WHILE_ENCODER_RUNNING | 0xC00D0011 | This method cannot be called if the encoder engine is running.

Example Code

// Include libraries.

#include <windows.h>
#include "wmencode.h"

// Declare variables.

    HRESULT hr;
    IWMEncoder* pEncoder;
    IWMEncSourceGroupCollection* pSrcGrpColl;
    IWMEncSourceGroup* pSrcGrp;
    IWMEncSource* pAudSrc;
    IWMEncSource* pSrc;
    IWMEncVideoSource* pVidSrc;

// Initialize the COM library and retrieve a pointer
// to an IWMEncoder interface.

    hr = CoInitialize(NULL);
    CoCreateInstance(CLSID_WMEncoder,
                     NULL,
                     CLSCTX_INPROC_SERVER,
                     IID_IWMEncoder,
                     (void**) &pEncoder);

// Retrieve an IWMEncSourceGroupCollection pointer.

    hr = pEncoder->get_SourceGroupCollection(&pSrcGrpColl);

// Add a source group to the collection.

    hr = pSrcGrpColl->Add(L"SG_1", &pSrcGrp);

// Add a video stream to the source group.

    hr = pSrcGrp->AddSource(WMENC_VIDEO, &pSrc);
    hr = pSrcGrp->AddSource(WMENC_AUDIO, &pAudSrc);

// Retrieve an IWMEncVideoSource pointer.

    hr = pSrc->QueryInterface(IID_IWMEncVideoSource, (void**)&pVidSrc);

// Specify the cropping margins.

    hr = pVidSrc->put_CroppingBottomMargin(5);
    hr = pVidSrc->put_CroppingTopMargin(5);
    hr = pVidSrc->put_CroppingLeftMargin(3);
    hr = pVidSrc->put_CroppingRightMargin(3);

// Retrieve the cropping margins.

    hr = pVidSrc->get_CroppingBottomMargin(&lBottom);
    hr = pVidSrc->get_CroppingTopMargin(&lTop);
    hr = pVidSrc->get_CroppingLeftMargin(&lLeft);
    hr = pVidSrc->get_CroppingRightMargin(&lRight);

See Also

  • IWMEncVideoSource::get_CroppingLeftMargin
  • IWMEncVideoSource Interface


IWMEncVideoSource::put_CroppingMode

The put_CroppingMode method specifies a member of an enumeration type that indicates the image cropping mode.

Syntax

HRESULT put_CroppingMode(
  WMENC_CROPPING_MODE  enumCroppingMode
);

Parameters

enumCroppingMode

[in] Member of a WMENC_CROPPING_MODE enumeration type specifying the cropping mode. This must be the following value.

Value | Description
WMENC_CROPPING_ABSOLUTE | The amount of an image to crop must be specified as an absolute number of pixels.

Return Values

If the method succeeds, it returns S_OK. If it fails, it supports the IErrorInfo interface and returns an HRESULT error code.

Return code | Number | Meaning
NS_E_INVALIDCALL_WHILE_ENCODER_RUNNING | 0xC00D0011 | This method cannot be called if the encoder engine is running.

Remarks

Use the IWMEncVideoSource::get_CroppingMode method to retrieve the cropping mode.

See Also

  • IWMEncVideoSource::get_CroppingMode
  • IWMEncVideoSource Interface


IWMEncVideoSource::put_CroppingRightMargin

The put_CroppingRightMargin method specifies the number of pixels to be removed from the right edge of an image.

Syntax

HRESULT put_CroppingRightMargin(
  long  lRight
);

Parameters

lRight

[in] long containing the number of pixels to be cropped.

Return Values

If the method succeeds, it returns S_OK. If it fails, it supports the IErrorInfo interface and returns an HRESULT error code.

Return code | Number | Meaning
NS_E_INVALIDCALL_WHILE_ENCODER_RUNNING | 0xC00D0011 | This method cannot be called if the encoder engine is running.

Example Code

// Include libraries.

#include <windows.h>
#include "wmencode.h"

// Declare variables.

    HRESULT hr;
    IWMEncoder* pEncoder;
    IWMEncSourceGroupCollection* pSrcGrpColl;
    IWMEncSourceGroup* pSrcGrp;
    IWMEncSource* pAudSrc;
    IWMEncSource* pSrc;
    IWMEncVideoSource* pVidSrc;

// Initialize the COM library and retrieve a pointer
// to an IWMEncoder interface.

    hr = CoInitialize(NULL);
    CoCreateInstance(CLSID_WMEncoder,
                     NULL,
                     CLSCTX_INPROC_SERVER,
                     IID_IWMEncoder,
                     (void**) &pEncoder);

// Retrieve an IWMEncSourceGroupCollection pointer.

    hr = pEncoder->get_SourceGroupCollection(&pSrcGrpColl);

// Add a source group to the collection.

    hr = pSrcGrpColl->Add(L"SG_1", &pSrcGrp);

// Add a video stream to the source group.

    hr = pSrcGrp->AddSource(WMENC_VIDEO, &pSrc);
    hr = pSrcGrp->AddSource(WMENC_AUDIO, &pAudSrc);

// Retrieve an IWMEncVideoSource pointer.

    hr = pSrc->QueryInterface(IID_IWMEncVideoSource, (void**)&pVidSrc);

// Specify the cropping margins.

    hr = pVidSrc->put_CroppingBottomMargin(5);
    hr = pVidSrc->put_CroppingTopMargin(5);
    hr = pVidSrc->put_CroppingLeftMargin(3);
    hr = pVidSrc->put_CroppingRightMargin(3);

// Retrieve the cropping margins.

    hr = pVidSrc->get_CroppingBottomMargin(&lBottom);
    hr = pVidSrc->get_CroppingTopMargin(&lTop);
    hr = pVidSrc->get_CroppingLeftMargin(&lLeft);
    hr = pVidSrc->get_CroppingRightMargin(&lRight);

See Also

  • IWMEncVideoSource::get_CroppingRightMargin
  • IWMEncVideoSource Interface


IWMEncVideoSource::put_CroppingTopMargin

The put_CroppingTopMargin method specifies the number of pixels to be removed from the top edge of an image.

Syntax

HRESULT put_CroppingTopMargin(
  long  lTop
);

Parameters

lTop

[in] long containing the number of pixels to be cropped.

Return Values

If the method succeeds, it returns S_OK. If it fails, it supports the IErrorInfo interface and returns an HRESULT error code.

Return code | Number | Meaning
NS_E_INVALIDCALL_WHILE_ENCODER_RUNNING | 0xC00D0011 | This method cannot be called if the encoder engine is running.

Example Code

// Include libraries.

#include <windows.h>
#include "wmencode.h"

// Declare variables.

    HRESULT hr;
    IWMEncoder* pEncoder;
    IWMEncSourceGroupCollection* pSrcGrpColl;
    IWMEncSourceGroup* pSrcGrp;
    IWMEncSource* pAudSrc;
    IWMEncSource* pSrc;
    IWMEncVideoSource* pVidSrc;

// Initialize the COM library and retrieve a pointer
// to an IWMEncoder interface.

    hr = CoInitialize(NULL);
    CoCreateInstance(CLSID_WMEncoder,
                     NULL,
                     CLSCTX_INPROC_SERVER,
                     IID_IWMEncoder,
                     (void**) &pEncoder);

// Retrieve an IWMEncSourceGroupCollection pointer.

    hr = pEncoder->get_SourceGroupCollection(&pSrcGrpColl);

// Add a source group to the collection.

    hr = pSrcGrpColl->Add(L"SG_1", &pSrcGrp);

// Add a video stream to the source group.

    hr = pSrcGrp->AddSource(WMENC_VIDEO, &pSrc);
    hr = pSrcGrp->AddSource(WMENC_AUDIO, &pAudSrc);

// Retrieve an IWMEncVideoSource pointer.

    hr = pSrc->QueryInterface(IID_IWMEncVideoSource, (void**)&pVidSrc);

// Specify the cropping margins.

    hr = pVidSrc->put_CroppingBottomMargin(5);
    hr = pVidSrc->put_CroppingTopMargin(5);
    hr = pVidSrc->put_CroppingLeftMargin(3);
    hr = pVidSrc->put_CroppingRightMargin(3);

// Retrieve the cropping margins.

    hr = pVidSrc->get_CroppingBottomMargin(&lBottom);
    hr = pVidSrc->get_CroppingTopMargin(&lTop);
    hr = pVidSrc->get_CroppingLeftMargin(&lLeft);
    hr = pVidSrc->get_CroppingRightMargin(&lRight);

See Also

  • IWMEncVideoSource::get_CroppingTopMargin
  • IWMEncVideoSource Interface


IWMEncVideoSource::put_Optimization

The put_Optimization method specifies the type of video optimization performed during the encoding process.

Syntax

HRESULT put_Optimization(
  WMENC_VIDEO_OPTIMIZATION  enumOptimization
);

Parameters

enumOptimization

[out] Member of a WMENC_VIDEO_OPTIMIZATION enumeration type that indicates the encoding optimization. This must be one of the following values.

Value | Number | Meaning
WMENC_VIDEO_STANDARD | 1 | Applies the standard compression algorithm during the encoding process.
WMENC_VIDEO_DEINTERLACE | 2 | Separates the interlaced video source to restore the original frames.
WMENC_VIDEO_INVERSETELECINE | 3 | Removes redundant video data from the video source.

Return Values

If the method succeeds, it returns S_OK. If it fails, it supports the IErrorInfo interface and returns an HRESULT error code.

Return code | Number | Meaning
E_INVALIDARG | 0x80070057 | The video optimization specified is not valid.
NS_E_INVALIDCALL_WHILE_ENCODER_RUNNING | 0xC00D0011 | This method cannot be called if the encoder engine is running.

Remarks

Television signals are interlaced by combining two frames into one image. Windows Media Encoder can separate the frames to restore the original content. When film is translated to a digital format, frames can be added by using the telecine process to increase the frame rate. Windows Media Encoder can eliminate the redundant frames. In both cases, Windows Media Encoder uses optimization to produce higher-quality output. However, you must choose the correct optimization for the content being encoded.

See Also

  • IWMEncVideoSource::get_Optimization
  • IWMEncVideoSource Interface


IWMEncVideoSource::put_PixelFormat

The put_PixelFormat method specifies the pixel format for the video image.

Syntax

HRESULT put_PixelFormat(
  WMENC_PIXELFORMAT_VIDEO  enumPixelFormat
);

Parameters

enumPixelFormat

[out] Member of a WMENC_PIXELFORMAT_VIDEO enumeration type that identifies the pixel format. This must be one of the following values.

Value | Number | Meaning
WMENC_PIXELFORMAT_AUTO | 0x00000001 | Windows Media Encoder selects the current format of the video image. This is the default value.
WMENC_PIXELFORMAT_IYUV | 0x56555949 | The IYUV format.
WMENC_PIXELFORMAT_I420 | 0x30323449 | The I420 format.
WMENC_PIXELFORMAT_YV12 | 0x32315659 | The YV12 format.
WMENC_PIXELFORMAT_YUY2 | 0x32595559 | The YUY2 format.
WMENC_PIXELFORMAT_UYVY | 0x59565955 | The UYVY format.
WMENC_PIXELFORMAT_YVYU | 0x55595659 | The YVYU format.
WMENC_PIXELFORMAT_YVU9 | 0x39555659 | The YVU9 format.
WMENC_PIXELFORMAT_RGB24 | 0xE436EB7D | The RGB24 format.
WMENC_PIXELFORMAT_RGB32 | 0xE436EB7E | The RGB32 format.
WMENC_PIXELFORMAT_RGB555 | 0xE436EB7C | The RGB555 format.
WMENC_PIXELFORMAT_RGB565 | 0xE436EB7B | The RGB565 format.
WMENC_PIXELFORMAT_RGB8 | 0xE436EB7A | The RGB8 format.
WMENC_PIXELFORMAT_RGB4 | 0xE436EB79 | The RGB4 format.
WMENC_PIXELFORMAT_RGB1 | 0xE436EB78 | The RGB1 format.

Return Values

If the method succeeds, it returns S_OK. If it fails, it supports the IErrorInfo interface and returns an HRESULT error code.

Return code | Number | Meaning
E_INVALIDARG | 0x80070057 | The pixel format specified is not valid.
NS_E_INVALIDCALL_WHILE_ENCODER_RUNNING | 0xC00D0011 | This method cannot be called if the encoder engine is running.

Remarks

The formats are listed in the order of decreasing preference for use in Windows Media Encoder.

See Also

  • IWMEncVideoSource::get_PixelFormat
  • IWMEncVideoSource Interface


Objects (Visual Basic)

The Windows Media Encoder SDK provides the following interfaces to configure and operate Windows Media Encoder and capture multimedia streams from files or devices.

Interfaces | Description
_IWMEncoderEvents Object | Receives Windows Media Encoder event notifications.
IWMEncAttributes Object | Manages a collection of name-value pairs created by the content author to provide extra information about the encoding session.
IWMEncBroadcast Object | Manages the port number used for broadcasting encoded content.
IWMEncDataViewCollection Object | Manages a collection of objects used to display a stream. The most common examples are preview and postview objects.
IWMEncDisplayInfo Object | Manages information about the content of being encoded. This includes the name of the author, the copyright date, the title and rating of the content, and descriptive text.
IWMEncFile Object | Manages the name of the file used for archiving encoded content.
IWMEncFileArchiveStats Object | Retrieves the size, in bytes, of the archive file and the duration, in milliseconds, of the encoded content stored in the file.
IWMEncIndexerStats Object | Monitors the indexing process for a Windows Media file.
IWMEncNetConnectionStats Object | Retrieves information about the number and nature of the clients connected to Windows Media Encoder.
IWMEncOutputStats Object | Retrieves status information about the encoding session.
IWMEncPluginInfo Object | Retrieves information about plug-ins.
IWMEncPostViewCollection Object | Manages a collection of objects that can be used to display streams after compression and decompression.
IWMEncProfile Object | Retrieves descriptive information about the profile associated with the active source group.
IWMEncProfileCollection Object | Enumerates the profiles that are available to an encoding session.
IWMEncProfileManager Object | Creates an instance of the Profile Manager to edit and create profiles.
IWMEncSource Object | Defines the source of a multimedia stream.
IWMEncSourceGroup Object | Manages a source group of source streams.
IWMEncSourceGroupCollection Object | Manages the collection of source groups that are available during an encoding session.
IWMEncSourcePluginInfoManager Object | Enumerates the available source plug-ins.
IWMEncStatistics Object | Retrieves status information about the encoding session.
IWMEncTransform Object | Specifies and retrieves transform plug-ins.
IWMEncTransformCollection Object | Manages the collection of transform plug-ins used during the current encoding session.
IWMEncTransformPluginInfoManager Object | Enumerates the available transform plug-ins.
IWMEncVideoSource Object | Crops the edges of a video image, and specifies the pixel format and video optimization.
WMEncoder Object | Operates the Windows Media Encoder engine.
WMEncoderApp Object | Displays the primary user interface built into Windows Media Encoder.

See Also

  • [Visual C++] Interfaces (C++)
  • Programming Reference


_IWMEncoderEvents Object

The _IWMEncoderEvents object is a callback object to which Windows Media Encoder sends event notifications. Use this object to respond to run-time errors, configuration changes, and state changes.

Note Do not perform blocking actions when the encoder engine is firing events. You will not be able to receive the events in a timely manner. For example, do not create a modal dialog box when events are being fired.

The _IWMEncoderEvents object exposes the following methods.

Method | Description
OnArchiveStateChange | Receives an event notice indicating a change in the archiving state.
OnClientConnect | Receives an event notice indicating that a client has connected to Windows Media Encoder.
OnClientDisconnect | Receives an event notice indicating that a client has disconnected from Windows Media Encoder
OnConfigChanged | Receives an event notice indicating a change in the Windows Media Encoder configuration.
OnError | Receives Windows Media Encoder run-time error event notices.
OnIndexerStateChange | Receives an event notice indicating whether the creation of an index for a Windows Media file has been started or stopped.
OnSourceStateChange | Receives an event notice indicating whether a specific input stream has started or stopped sending data to the encoder engine.
OnStateChange | Receives an event notice indicating whether Windows Media Encoder has been started or stopped.

See Also

  • [Visual C++] _IWMEncoderEvents Interface
  • Objects (Visual Basic)


_IWMEncoderEvents.OnArchiveStateChange

The OnArchiveStateChange method receives an event notice indicating a change in the archiving state.

Syntax

_IWMEncoderEvents.OnArchiveStateChange(
  enumArchive As WMENC_ARCHIVE_TYPE,
  enumState As WMENC_ARCHIVE_STATE
)

Parameters

enumArchive

[in] Member of a WMENC_ARCHIVE_TYPE enumeration type sent by Windows Media Encoder to specify where the archived content is being saved. This parameter must take the following value.

Value | Number | Meaning
WMENC_ARCHIVE_LOCAL | 1 | Save encoded content to a local file.

enumState

[in] member of a WMENC_ARCHIVE_STATE enumeration type sent by Windows Media Encoder to specify the archiving state. This parameter must take one of the following values.

Value | Number | Meaning
WMENC_ARCHIVE_RUNNING | 1 | The archiving operation is running.
WMENC_ARCHIVE_PAUSED | 2 | The archiving operation has been paused.
WMENC_ARCHIVE_STOPPED | 3 | The archiving operation has been stopped.

Return Values

This method does not return a value to the encoder engine.

Remarks

Use OnArchiveStateChange to respond to notifications of changes in the state of the archiving process. For example, use this callback to determine when to enable or disable UI command buttons that depend upon whether archiving has been started or stopped.

Example Code

Private Sub Encoder_OnArchiveStateChange(
ByVal enumArchive As WMEncoderLib.WMENC_ARCHIVE_TYPE,
ByVal enumState As WMEncoderLib.WMENC_ARCHIVE_STATE)

    Select Case enumArchive
        Case WMENC_ARCHIVE_LOCAL
        Select Case enumState
            Case WMENC_ARCHIVE_RUNNING
                ' Process the case.
            Case WMENC_ARCHIVE_PAUSED
                ' Process the case.
            Case WMENC_ARCHIVE_STOPPED
                ' Process the case.
       End Select
    End Select

End Sub

See Also

  • _IWMEncoderEvents Object
  • IWMEncFileArchiveStats Object
  • WMEncoder Object
  • WMENC_ARCHIVE_STATE
  • WMENC_ARCHIVE_TYPE


_IWMEncoderEvents.OnClientConnect

The OnClientConnect method receives an event notice indicating that a client has connected to Windows Media Encoder.

Syntax

_IWMEncoderEvents.OnClientConnect(
  protocol As WMENC_BROADCAST_PROTOCOL,
  bstrIPAddr As BSTR
)

Parameters

protocol

[in] Member of a WMENC_BROADCAST_PROTOCOL enumeration type containing the broadcast protocol. This must be the following value.

Value | Number | Description
WMENC_PROTOCOL_HTTP | 1 | The client has connected using the HTTP protocol.

bstrIPAddr

[in] BSTR containing the IP address of the client.

Return Values

This method does not return a value to the encoder engine.

Example Code

Private Sub Encoder_OnClientConnect(
ByVal protocol As WMEncoderLib.WMENC_BROADCAST_PROTOCOL,
ByVal bstrIPAddr As String)

    Select Case WMENC_PROTOCOL_HTTP
        If bstrIPAddr = "xxx.xxx.xxx.xxx" Then
           ' Handle a specific IP address.
        End If

End Sub

See Also

  • _IWMEncoderEvents Object
  • IWMEncNetConnectionStats Object
  • WMENC_BROADCAST_PROTOCOL


_IWMEncoderEvents.OnClientDisconnect

The OnClientDisconnect method receives an event notice indicating that a client has disconnected from Windows Media Encoder.

Syntax

_IWMEncoderEvents.OnClientDisconnect(
  protocol As WMENC_BROADCAST_PROTOCOL,
  bstrIPAddr As BSTR
)

Parameters

protocol

[in] Member of a WMENC_BROADCAST_PROTOCOL enumeration type containing the broadcast protocol. This must be the following value.

Value | Number | Description
WMENC_PROTOCOL_HTTP | 1 | The client has connected using the HTTP protocol.

bstrIPAddr

[in] BSTR containing the IP address of the client.

Return Values

This method does not return a value to the encoder engine.

Example Code

Private Sub Encoder_OnClientDisconnect(
ByVal protocol As WMEncoderLib.WMENC_BROADCAST_PROTOCOL,
ByVal bstrIPAddr As String)

    Select Case WMENC_PROTOCOL_HTTP
        If bstrIPAddr = "xxx.xxx.xxx.xxx" Then
            ' Handle a specific IP address.
        End If

End Sub

See Also

  • _IWMEncoderEvents Object
  • IWMEncNetConnectionStats Object


_IWMEncoderEvents.OnConfigChange

The OnConfigChange method receives an event notice indicating a change in the Windows Media Encoder configuration.

Syntax

_IWMEncoderEvents.OnConfigChange(
  lDISPID As Long,
  bstrSrcGrp As BSTR
)

Parameters

lDISPID

[in] LONG sent by Windows Media Encoder, containing the DISPID of the property that changed.

bstrSrcGrp

[in]..BSTR sent by Windows Media Encoder, containing the name of the source group in which the change occurred.

Return Values

This method returns no value to the encoder engine.

Remarks

This event is fired for any property in the Windows Media Encoder type library.

Example Code

Private Sub Encoder_OnConfigChange(
ByVal lDISPID As Long,
ByVal bstrSrcGrp As String)

    If lDISPID = DISPID_FILE_LOCALFILENAME Then
        ' The end user has specified a new name for the archive file.
        ' Process the new name.
    End If
    If lDISPID = DISPID_BROADCAST_PORTNUMBER Then
        ' The end user has specified a new broadcast port number.
        ' Process for the new port number.
    End If
End Sub

See Also

  • _IWMEncoderEvents Object


_IWMEncoderEvents.OnError

The OnError method receives Windows Media Encoder run-time error event notices.

Syntax

_IWMEncoderEvents.OnError(
  hResult As Long,
)

Parameters

hResult

[in] LONG sent by the encoder, containing the error code. This can be one of the following values.

Value | Number | Description
NS_E_BAD_MARKIN | 0xC00D1B58 | The starting time must be greater than zero and less than the ending time.
NS_E_BAD_MARKOUT | 0xC00D1B59 | The ending time must be greater than the starting time and less than the file duration.
NS_E_VIDEODEVICE_BUSY | 0xC00D1B64 | The video capture device is in use and cannot be opened.
NS_E_VIDEODRIVER_UNSTABLE | 0xC00D1B68 | The video capture driver returned an unrecoverable error.
NS_E_VIDCAPSTARTFAILED | 0xC00D1B69 | The video capture device did not start.
NS_E_VIDCAPCREATEWINDOW | 0xC00D1B6D | The video capture window was not created.
NS_E_INVALIDCALL_WHILE_ARCHIVAL_RUNNING | 0xC00D1B74 | The specified operation is not allowed when the file is being archived.
NS_E_ARCHIVE_FILENAME_NOTSET | 0xC00D1B79 | The archive file name is not properly specified.
NS_E_INVALIDCALL_WHILE_ENCODER_STOPPED | 0xC00D1B7F | The specified operation is not allowed when the encoder engine is not running.
NS_E_INVALID_INPUTFPS | 0xC00D1B81 | Inverse telecine cannot be specified when the frame rate does not equal 30 frames per second.
NS_E_NO_DATAVIEW_SUPPORT | 0xC00D1B82 | Internal problems are preventing the preview or postview.
NS_E_CODEC_UNAVAILABLE | 0xC00D1B83 | One or more required codecs cannot be found.
NS_E_UNEXPECTED_DISPLAY_SETTINGS | 0xC00D1B88 | The display size or color setting has changed since the encoding session was defined.

Return Values

This method does not return a value to the encoder engine.

Remarks

Use the OnError method to respond to run-time error event notices. The ErrorState method in the WMEncoder object provides another way to retrieve errors while the encoder is running. If you are comparing hResult to a hexadecimal error code, eliminate the leading "Ox" from the hex value.

Example Code

Private Sub Encoder_OnError(ByVal hResult As Long)

    If Hex(hResult) = "C00D1B66" Then
        ' Process the error.
        ' OxC00D1B66 = NS_E_INVALIDCALL_WHILE_ENCODER_RUNNING
    End If

End Sub

See Also

  • _IWMEncoderEvents Object
  • WMEncoder.ErrorState
  • WMEncoder Object


_IWMEncoderEvents.OnIndexerStateChange

The OnIndexerStateChange method receives an event notice indicating whether the indexing process for a Windows Media file has been started or stopped.

Syntax

_IWMEncoderEvents.OnIndexerStateChange(
  enumIndexerState As WMENC_INDEXER_STATE,
  bstrFile As BSTR
)

Parameters

enumIndexerState

[in] Member of a WMENC_INDEXER_STATE enumeration type sent by Windows Media Encoder to specify the state of the indexing process. This must be one of the following values

Value | Number | Description
WMENC_INDEXER_RUNNING | 1 | The indexing process has been started.
WMENC_INDEXER_STOPPED | 2 | The indexing process has been stopped.

bstrFile

[in] BSTR sent by Windows Media Encoder, containing the name of the file being indexed.

Return Values

This method does not return a value to the encoder engine.

Remarks

A file index enables operations, such as fast fowarding, that must seek to specific time offsets in a file. For each file, an event is sent when the indexing process starts, and another event is sent when the process stops. The indexing process is performed in the background on a lower priority thread.

Example Code

Private Sub Encoder_OnIndexerStateChange(
ByVal enumIndexerState As WMEncoderLib.WMENC_INDEXER_STATE,
ByVal bstrFile As String)

    Select Case enumIndexerState
        Case WMENC_INDEXER_RUNNING
            ' Process the case.
        Case WMENC_INDEXER_STOPPED
            ' Process the case.
    End Select

End Sub

See Also

  • _IWMEncoderEvents Object


_IWMEncoderEvents.OnSourceStateChange

The OnSourceStateChange method receives an event notice indicating whether the encoding of a specific source stream has started or stopped.

Syntax

_IWMEncoderEvents.OnSourceStateChange(
  enumState As WMENC_SOURCE_STATE,
  enumType As WMENC_SOURCE_TYPE,
  iIndex As Short,
  bstrSourceGroup As BSTR
)

Parameters

enumState

[in] Member of a WMENC_SOURCE_STATE enumeration type indicating whether input stream capture has been started or stopped. This must be one of the following values.

Value | Number | Description
WMENC_SOURCE_START | 1 | The input stream has started.
WMENC_SOURCE_STOP | 2 | The input stream has stopped.
WMENC_SOURCE_PREPARE | 3 | A source plug-in has been added.
WMENC_SOURCE_UNPREPARE | 4 | A source plug-in has been removed.

enumType

[in] Member of a WMENC_SOURCE_TYPE enumeration type indicating the media type of the input stream. This must be one of the following values.

Value | Number | Description
WMENC_AUDIO | 1 | Identifies an audio stream.
WMENC_VIDEO | 2 | Identifies a video stream.
WMENC_SCRIPT | 4 | Identifies a script stream.

iIndex

[in] short identifying which audio, video or text stream is being captured. Because there can only be one stream of each type, iIndex must be zero.

bstrSourceGroup

[in] BSTR containing the name of the source group of which the source stream is a member.

Return Values

This method does not return a value to the encoder engine.

Remarks

Use OnSourceStateChange to determine when a source stream has finished transmitting data to the encoder engine. When all streams have finished, you can begin encoding another source group. This enables you to broadcast playlists from Windows Media Encoder.

Example Code

Private Sub Encoder_OnSourceStateChange(
ByVal enumState As WMEncoderLib.WMENC_SOURCE_STATE,
ByVal enumType As WMEncoderLib.WMENC_SOURCE_TYPE,
ByVal iIndex As Integer,
ByVal bstrSourceGroup As String)

    Select Case enumState
        Case WMENC_SOURCE_START
            Select Case enumType
                Case WMENC_AUDIO
                    ' Process the case.
                Case WMENC_VIDEO
                    ' Process the case.
                Case WMENC_SCRIPT
                    ' Process the case.
            End Select
        Case WMENC_SOURCE_STOP
            Select Case enumType
                Case WMENC_AUDIO
                    ' Process the case.
                Case WMENC_VIDEO
                    ' Process the case.
                Case WMENC_SCRIPT
                    ' Process the case.
            End Select
        Case WMENC_SOURCE_PREPARE
            ' Process the case.
        Case WMENC_SOURCE_UNPREPARE
            ' Process the case.
    End Select

End Sub

See Also

  • _IWMEncoderEvents Object


_IWMEncoderEvents.OnStateChange

The OnStateChange method receives an event notice indicating whether Windows Media Encoder has been started or stopped.

Syntax

_IWMEncoderEvents.OnStateChange(
  enumState  As WMENC_ENCODER_STATE
)

Parameters

enumState

[in] Member of a WMENC_ENCODER_STATE enumeration type sent by Windows Media Encoder to specify the operating state. This parameter must be one of the following values.

Value | Number | Meaning
WMENC_ENCODER_STARTING | 1 | Windows Media Encoder is starting.
WMENC_ENCODER_RUNNING | 2 | Windows Media Encoder is running.
WMENC_ENCODER_STOPPING | 4 | Windows Media Encoder is stopping.
WMENC_ENCODER_STOPPED | 5 | Windows Media Encoder has been stopped.

Return Values

This method does not return a value to the encoder engine.

Remarks

Use the OnStateChange method to respond to Windows Media Encoder state event notices. For example, use this callback to determine when to enable or disable UI command buttons that depend upon whether the encoder is running or stopped.

Example Code

Private Sub Encoder_OnStateChange(ByVal enumState As WMEncoderLib.WMENC_ENCODER_STATE)

    Select Case enumState
        Case WMENC_ENCODER_STARTING
            ' Process the case.
        Case WMENC_ENCODER_RUNNING
            ' Process the case.
        Case WMENC_ENCODER_STOPPING
            ' Process the case.
        Case WMENC_ENCODER_STOPPED
            ' Process the case.

    End Select
End Sub

See Also

  • _IWMEncoderEvents Object


IWMEncAttributes Object

The IWMEncAttributes object manages a collection of user-defined attributes. These are combinations of name-value pairs that provide extra, author-defined information about an encoding session. For example, you can indicate the creation date for a stream by assigning the string "Date" to the attribute name and a string containing the formatted date to the attribute value. You can also use this interface to categorize content.

The IWMEncAttributes object exposes the following properties and methods.

Property | Description
Count | Retrieves the number of name-value pairs in the collection of user-defined attributes.

Property | Description
Add | Adds a new name-value pair to the collection of user-defined attributes.
Item | Retrieves a specific name-value pair from the collection of user-defined attributes.
Remove | Removes a specific name-value pair from the collection of user-defined attributes.
RemoveAll | Removes all attributes from the collection.

See Also

  • [Visual C++] IWMEncAttributes Interface
  • Objects (Visual Basic)


IWMEncAttributes.Count

The Count property retrieves the number of name-value pairs in the collection of user-defined attributes.

Syntax

Long = IWMEncAttributes.Count

Parameters

This property takes no parameters.

Return Values

This property returns a LONG containing the number of attributes in the collection.

Remarks

Call Count before iterating through the collection, and use the returned value as an upper loop boundary.

Example Code

' Create a WMEncoder object.
Dim Encoder As WMENcoder
Set Encoder = New WMEncoder

' Retrieve an IWMEncAttributes object.
Dim Attr As IWMEncAttributes
Set Attr = Encoder.Attributes
Dim i As Integer
Dim strName As String
Dim strValue As String

' Add three custom attributes to the collection.
Attr.Add "Date created: ", "02/15/2000"
Attr.Add "Time created: ", "13:30:15"
Attr.Add "File content: ", "multimedia data"

' View the attributes in the collection.
For i = 0 To Attr.Count - 1
  strValue = Attr.Item(i, strName)
Next

' Remove an attribute by name.
Attr.Remove ("File content: ")

' Remove an attribute by index.
Attr.Remove (0)

' Remove any remaining attributes.
Attr.RemoveAll

See Also

  • IWMEncAttributes.Add
  • IWMEncAttributes.Item
  • IWMEncAttributes Object
  • IWMEncAttributes.Remove
  • IWMEncAttributes.RemoveAll


IWMEncAttributes.Add

The Add method adds a new name-value pair to the collection of user-defined attributes.

Syntax

IWMEncAttributes.Add bstrName, varValue

Parameters

bstrName

[in] BSTR containing the attribute name.

varValue

[in] VARIANT containing the attribute value.

Return Values

If this method fails, it returns an error number.

Number | Meaning
0x80070057 | The string containing the name cannot be empty.
0x80004003 | The address of the variable containing the name is NULL.
0xC00D1B65 | You cannot call this method if the encoder engine is running.

Remarks

The IWMEncAttributes.Remove method removes a single name-value pair from the collection, and IWMEncAttributes.RemoveAll clears all attributes from the collection.

Example Code

' Create a WMEncoder object.
Dim Encoder As WMENcoder
Set Encoder = New WMEncoder

' Retrieve an IWMEncAttributes object.
Dim Attr As IWMEncAttributes
Set Attr = Encoder.Attributes
Dim i As Integer
Dim strName As String
Dim strValue As Variant

' Add three custom attributes to the collection.
Attr.Add "Date created: ", "02/15/2000"
Attr.Add "Time created: ", "13:30:15"
Attr.Add "File content: ", "multimedia data"

' View the attributes in the collection.
For i = 0 To Attr.Count - 1
  strValue = Attr.Item(i, strName)
Next

' Remove an attribute by name.
Attr.Remove ("File content: ")

' Remove an attribute by index.
Attr.Remove (0)

' Remove any remaining attributes.
Attr.RemoveAll

See Also

  • IWMEncAttributes.Count
  • IWMEncAttributes.Item
  • IWMEncAttributes Object
  • IWMEncAttributes.Remove
  • IWMEncAttributes.RemoveAll


IWMEncAttributes.Item

The Item method retrieves a specific name-value pair from the collection of user-defined attributes.

Syntax

VARIANT = IWMEncAttributes.Item ( iIndex, bstrName )

Parameters

iIndex

[in] LONG containing the index number of the attribute in the collection.

bstrName

[out] BSTR containing the attribute name.

Return Values

If this method succeeds, it returns a VARIANT containing the attribute value. If it fails, it returns an error number.

Number | Meaning
0xC00D0011 | The input parameter does not match a valid index in the attributes collection.

Remarks

You can iterate through the collection and use this method to find the index for a specific attribute. Call IWMEncAttributes.Count first to determine the upper limit of the number of items you must iterate through.

Example Code

' Create a WMEncoder object.
Dim Encoder As WMENcoder
Set Encoder = New WMEncoder

' Retrieve an IWMEncAttributes object.
Dim Attr As IWMEncAttributes
Set Attr = Encoder.Attributes
Dim i As Integer
Dim strName As String
Dim strValue As String

' Add three custom attributes to the collection.
Attr.Add "Date created: ", "02/15/2000"
Attr.Add "Time created: ", "13:30:15"
Attr.Add "File content: ", "multimedia data"

' View the attributes in the collection.
For i = 0 To Attr.Count - 1
  strValue = Attr.Item(i, strName)
Next

' Remove an attribute by name.
Attr.Remove ("File content: ")

' Remove an attribute by index.
Attr.Remove (0)

' Remove any remaining attributes.
Attr.RemoveAll

See Also

  • IWMEncAttributes.Add
  • IWMEncAttributes.Count
  • IWMEncAttributes Object
  • IWMEncAttributes.Remove
  • IWMEncAttributes.RemoveAll


IWMEncAttributes.Remove

The Remove method removes a specific name-value pair from the collection.

Syntax

IWMEncAttributes.Remove var

Parameters

var

[in] VARIANT containing either the name or index of the attribute to be removed.

Return Values

If this method fails, it returns an error number.

Number | Meaning
0xC00D0011 | The input parameter does not match a valid index in the attributes collection.
0xC00D1B66 | You cannot call this method if the encoder engine is running.

Remarks

The attribute to be removed can be specified either by a string name or by an index into the attribute collection. Use the IWMEncAttributes.Add method to add an attribute to the collection. Use the IWMEncAttributes.RemoveAll method to delete all attributes from the collection.

Example Code

' Create a WMEncoder object.
Dim Encoder As WMENcoder
Set Encoder = New WMEncoder

' Retrieve an IWMEncAttributes object.
Dim Attr As IWMEncAttributes
Set Attr = Encoder.Attributes
Dim i As Integer
Dim strName As String
Dim strValue As String

' Add three custom attributes to the collection.
Attr.Add "Date created: ", "02/15/2000"
Attr.Add "Time created: ", "13:30:15"
Attr.Add "File content: ", "multimedia data"

' View the attributes in the collection.
For i = 0 To Attr.Count - 1
  strValue = Attr.Item(i, strName)
Next

' Remove an attribute by name.
Attr.Remove ("File content: ")

' Remove an attribute by index.
Attr.Remove (0)

' Remove any remaining attributes.
Attr.RemoveAll

See Also

  • IWMEncAttributes.Add
  • IWMEncAttributes.Count
  • IWMEncAttributes.Item
  • IWMEncAttributes Object
  • IWMEncAttributes.RemoveAll


IWMEncAttributes.RemoveAll

The RemoveAll method removes all attributes from the collection of user-defined attributes.

Syntax

IWMEncAttributes.RemoveAll

Parameters

This method takes no parameters.

Return Values

If this method fails, it returns an error number.

Number | Meaning
0xC00D1B66 | You cannot call this method if the encoder engine is running.

Remarks

Use the IWMEncAttributes.Remove method to remove a single attribute from the collection. Use the IWMEncAttributes.Add method to add an attribute to the collection.

Example Code

' Create a WMEncoder object.
Dim Encoder As WMENcoder
Set Encoder = New WMEncoder

' Retrieve an IWMEncAttributes object.
Dim Attr As IWMEncAttributes
Set Attr = Encoder.Attributes
Dim i As Integer
Dim strName As String
Dim strValue As String

' Add three custom attributes to the collection.
Attr.Add "Date created: ", "02/15/2000"
Attr.Add "Time created: ", "13:30:15"
Attr.Add "File content: ", "multimedia data"

' View the attributes in the collection.
For i = 0 To Attr.Count - 1
  strValue = Attr.Item(i, strName)
Next

' Remove an attribute by name.
Attr.Remove ("File content: ")

' Remove an attribute by index.
Attr.Remove (0)

' Remove any remaining attributes.
Attr.RemoveAll

See Also

  • IWMEncAttributes.Add
  • IWMEncAttributes.Count
  • IWMEncAttributes Object
  • IWMEncAttributes.Item
  • IWMEncAttributes.Remove


IWMEncBroadcast Object

The IWMEncBroadcast object manages the port number and protocol used for broadcasting encoded content. The IWMEncBroadcast object exposes the following property.

Property | Description
PortNumber | Specifies and retrieves the port number used for broadcasting encoded content.

See Also

  • [Visual C++] IWMEncBroadcast Interface
  • Objects (Visual Basic)


IWMEncBroadcast.PortNumber

The PortNumber property specifies and retrieves the port number used for broadcasting encoded content.

Syntax

Long = IWMEncBroadcast.PortNumber(enumProtocol)
IWMEncBroadcast.PortNumber(enumProtocol) = Long

Parameters

enumProtocol

[in] Specifies the protocol for transmitting encoded content. Currently, this must be the following value.

Value | Number | Meaning
WMENC_PROTOCOL_HTTP | 1 | The transmission uses the HTTP protocol.

Return Values

When getting the value, this property returns a LONG containing the port number. If this property fails, it returns an error number.

Number | Description
0x80070057 | The protocol is not valid.
0xC00D1B66 | You cannot set this property if the encoder engine is running.

Remarks

Only the HTTP protocol can be used.

Example Code

' Create a WMEncoder object.
Dim Encoder As WMEncoder
Set Encoder = New WMEncoder

' Create an IWMEncBroadcast object.
Dim Brdcst As IWMEncBroadcast
Set Brdcst = Encoder.Broadcast

' Retrieve the port number. The port number defaults to zero.
Dim PortNum As Integer
PortNum = Brdcst.PortNumber(WMENC_PROTOCOL_HTTP)

' Set the port number.
Brdcst.PortNumber(WMENC_PROTOCOL_HTTP) = 2356

See Also

  • IWMEncBroadcast Object


IWMEncDataViewCollection Object

The IWMEncDataViewCollection object contains a collection of data view objects used by Windows Media Encoder to display multimedia content. The most common examples are preview and postview objects. A preview object displays a specific multimedia stream before it is compressed. A postview object displays the same stream after compression and decompression. Postviews, therefore, more closely resemble the image rendered in Windows Media Player on a client computer.

A single data view object is generally associated with only one source stream in one source group but can be shared by multiple sources. For example, you can render both a live presentation and a bitmap intermission slide in the same video window by sharing a data view object between the two sources.

You can add multiple data view objects to a single source. For instance, one object might simply render a video or audio stream, and another object might use periods of inactivity in the encoded stream to send an e-mail message.

All of the data view objects associated with a stream are grouped together in a collection. Multiple collections exist if multiple streams are associated with data view objects. A data view collection is acquired from the IWMEncSource object.

Note If you are a Visual Basic programmer, you can use this object to retrieve information about the collection of IWMEncDataView objects. However, IWMEncDataView does not support Automation. Therefore, you must use C++ to display preview and postview objects. For more information, see the Previewing and Postviewing section in the Programming Guide.

The IWMEncDataViewCollection object exposes the following properties and methods.

Property | Description
Count | Retrieves the number of IWMEncDataView objects in the collection.
length | Retrieves the number of IWMEncDataView objects in the collection.

Method | Description
Add | Adds an IWMEncDataView object to the collection.
Item | Retrieves a specific IWMEncDataView object from the collection.
Remove | Removes a specific IWMEncDataView object from the collection.
RemoveAll | Removes all IWMEncDataView objects from the collection.

See Also

  • [Visual C++] IWMEncDataView Interface
  • [Visual C++] IWMEncDataViewCollection Interface
  • IWMEncSource Object
  • Objects (Visual Basic)
  • Previewing and Postviewing
  • Programming Guide


IWMEncDataViewCollection.Count

The Count property retrieves the number of IWMEncDataView objects in the collection.

Syntax

Long = IWMEncDataViewCollection.Count

Parameters

This property takes no parameters.

Return Values

When getting the value, this property returns a Long containing the number of objects.

Remarks

This property is read-only.

See Also

  • [Visual C++] IWMEncDataView Interface
  • IWMEncDataViewCollection Object


IWMEncDataViewCollection.length

The length property retrieves the number of IWMEncDataView objects in the collection.

Syntax

Long = IWMEncDataViewCollection.length

Parameters

This property takes no parameters.

Return Values

When getting the value, this property returns a Long containing the number of objects.

Remarks

This property is read-only. This is the JScript version of the Count method. It is included for developers more comfortable with JScript syntax

See Also

  • [Visual C++] IWMEncDataView Interface
  • IWMEncDataViewCollection Object


IWMEncDataViewCollection.Add

The Add method adds an IWMEncDataView object to the collection.

Syntax

IWMEncDataViewCollection.Add DataView, lStreamCookie

Parameters

pDataView

[in] Data view object.

plStreamCookie

[in, out] LONG containing the ID of the stream associated with the data view.

Return Values

If this method fails, it returns an error number.

Number | Description
0x80004005 | An error occurred.
0x80070057 | A parameter is not valid.
0x8007000E | Memory cannot be allocated.
0xC00D1B66 | This method cannot be called if the encoder engine is running.

Remarks

Because IWMEncDataView objects do not support Automation, you cannot use Visual Basic to add IWMEncDataView objects to the collection.

See Also

  • [Visual C++] IWMEncDataView Interface
  • [Visual C++] IWMEncDataViewCollection::Add
  • IWMEncDataViewCollection Object


IWMEncDataViewCollection.Item

The Item method retrieves a specific IWMEncDataView object from the collection.

Syntax

Long = IWMEncDataViewCollection.Item( Index, DataView )

Parameters

Index

[in] LONG containing the index of the object in the collection.

DataView

[out] IUnknown pointer to the preview or postview object.

Return Values

This method returns a LONG containing the ID of the stream associated with the preview or postview object. If this method fails, it returns an error number.

Number | Description
0xC00D0011 | Either the index is less than zero or greater than the number of objects in the data view collection.

Remarks

Because IWMEncDataView objects do not support Automation, you cannot use the IUnknown pointer returned in the second parameter of this method.

See Also

  • [Visual C++] IWMEncDataView Interface
  • [Visual C++] IWMEncDataViewCollection::Item
  • IWMEncDataViewCollection Object


IWMEncDataViewCollection.Remove

The Remove method removes a specific IWMEncDataView object from the collection.

Syntax

IWMEncDataViewCollection.Remove lStreamIndex

Parameters

lStreamIndex

[in] LONG containing the index of the stream.

Return Values

If this method fails, it returns an error number.

Number | Description
0xC00D1B66 | The index of the data view object to remove is invalid.
0xC00D0011 | This method cannot be called if the encoder engine is running.

See Also

  • [Visual C++] IWMEncDataView Interface
  • IWMEncDataViewCollection.Add
  • IWMEncDataViewCollection Object
  • IWMEncDataViewCollection.RemoveAll


IWMEncDataViewCollection.RemoveAll

The RemoveAll method removes all IWMEncDataView objects from the collection.

Syntax

IWMEncDataViewCollection.RemoveAll

Parameters

This method takes no parameters.

Return Values

If this method fails, it returns an error number.

Number | Description
0xC00D0011 | This method cannot be called if the encoder engine is running.

See Also

  • [Visual C++] IWMEncDataView Interface
  • IWMEncDataViewCollection Object
  • IWMEncDataViewCollection.Remove


IWMEncDisplayInfo Object

The IWMEncDisplayInfo object records and retrieves string information about the content being encoded. Typically, this includes the name of the author, the copyright date, the title and rating of the content and any extra description added by the content author. The IWMEncDisplayInfo object exposes the following properties and methods.

Property | Description
Author | Specifies and retrieves the name of the content author.
Copyright | Specifies and retrieves the copyright information for the content being encoded.
Description | Specifies and retrieves a general description of the multimedia content being encoded.
Rating | Specifies and retrieves the rating information for the content being encoded.
Title | Specifies and retrieves the title of the media being encoded.

See Also

  • [Visual C++] IWMEncDisplayInfo Interface
  • Objects (Visual Basic)


IWMEncDisplayInfo.Author

The Author property specifies and retrieves the name of the content author.

Syntax

IWMEncDisplayInfo.Author = BSTR
BSTR = IWMEncDisplayInfo.Author

Parameters

This property takes no parameters.

Return Values

When getting the value, this property returns a BSTR containing the name of the author. If this property fails, it returns an error number.

Number | Meaning
0xC00D0011 | This property cannot be set if the encoder engine is running.

Example Code

' Create a WMEncoder object.
Dim Encoder As WMEncoder
Set Encoder = New WMEncoder

' Retrieve an IWMEncDisplayInfo object.
Dim DispInfo As IWMEncDisplayInfo
Set DispInfo = Encoder.DisplayInfo

' Declare string variables.
Dim strAuthor As String
Dim strCopyright As String
Dim strDescription As String
Dim strRating As String
Dim strTitle As String

' Set the IWMEncDisplayInfo properties
DispInfo.Author = "Content author's name."
DispInfo.Copyright = "Copyright 2000. All rights reserved."
DispInfo.Description = "Description of the encoded content."
DispInfo.Rating = "Not applicable."
DispInfo.Title = "Title of the encoded content."

' Retrieve the IWMEncDisplayInfo properties.
strAuthor = DispInfo.Author
strCopyright = DispInfo.Copyright
strDescription = DispInfo.Description
strRating = DispInfo.Rating
strTitle = DispInfo.Title

See Also

  • IWMEncDisplayInfo.Copyright
  • IWMEncDisplayInfo.Description
  • IWMEncDisplayInfo Object
  • IWMEncDisplayInfo.Rating
  • IWMEncDisplayInfo.Title


IWMEncDisplayInfo.Copyright

The Copyright property specifies and retrieves the copyright information for the content being encoded.

Syntax

IWMEncDisplayInfo.Copyright = BSTR
BSTR = IWMEncDisplayInfo.Copyright

Parameters

This property takes no parameters.

Return Values

When getting the value, this property returns a BSTR containing the copyright information. If this property fails, it returns an error number.

Number | Meaning
0xC00D0011 | This property cannot be set if the encoder engine is running.

Example Code

' Create a WMEncoder object.
Dim Encoder As WMEncoder
Set Encoder = New WMEncoder

' Retrieve an IWMEncDisplayInfo object.
Dim DispInfo As IWMEncDisplayInfo
Set DispInfo = Encoder.DisplayInfo

' Declare string variables.
Dim strAuthor As String
Dim strCopyright As String
Dim strDescription As String
Dim strRating As String
Dim strTitle As String

' Set the IWMEncDisplayInfo properties
DispInfo.Author = "Content author's name."
DispInfo.Copyright = "Copyright 2000. All rights reserved."
DispInfo.Description = "Description of the encoded content."
DispInfo.Rating = "Not applicable."
DispInfo.Title = "Title of the encoded content."

' Retrieve the IWMEncDisplayInfo properties.
strAuthor = DispInfo.Author
strCopyright = DispInfo.Copyright
strDescription = DispInfo.Description
strRating = DispInfo.Rating
strTitle = DispInfo.Title

See Also

  • IWMEncDisplayInfo.Author
  • IWMEncDisplayInfo.Description
  • IWMEncDisplayInfo Object
  • IWMEncDisplayInfo.Rating
  • IWMEncDisplayInfo.Title


IWMEncDisplayInfo.Description

The Description property specifies and retrieves a general description of the multimedia content being encoded.

Syntax

IWMEncDisplayInfo.Description = BSTR
BSTR = IWMEncDisplayInfo.Description

Parameters

This property takes no parameters.

Return Values

When getting the value, this property returns a BSTR containing the description. If this property fails, it returns an error number.

Number | Meaning
0xC00D0011 | This property cannot be set if the encoder engine is running.

Example Code

' Create a WMEncoder object.
Dim Encoder As WMEncoder
Set Encoder = New WMEncoder

' Retrieve an IWMEncDisplayInfo object.
Dim DispInfo As IWMEncDisplayInfo
Set DispInfo = Encoder.DisplayInfo

' Declare string variables.
Dim strAuthor As String
Dim strCopyright As String
Dim strDescription As String
Dim strRating As String
Dim strTitle As String

' Set the IWMEncDisplayInfo properties
DispInfo.Author = "Content author's name."
DispInfo.Copyright = "Copyright 2000. All rights reserved."
DispInfo.Description = "Description of the encoded content."
DispInfo.Rating = "Not applicable."
DispInfo.Title = "Title of the encoded content."

' Retrieve the IWMEncDisplayInfo properties.
strAuthor = DispInfo.Author
strCopyright = DispInfo.Copyright
strDescription = DispInfo.Description
strRating = DispInfo.Rating
strTitle = DispInfo.Title

See Also

  • IWMEncDisplayInfo.Author
  • IWMEncDisplayInfo.Copyright
  • IWMEncDisplayInfo Object
  • IWMEncDisplayInfo.Rating
  • IWMEncDisplayInfo.Title


IWMEncDisplayInfo.Rating

The Rating property specifies and retrieves the rating information for the content being encoded.

Syntax

IWMEncDisplayInfo.Rating = BSTR
BSTR = IWMEncDisplayInfo.Rating

Parameters

This property takes no parameters.

Return Values

When getting the value, this property returns a BSTR containing the rating information. If this property fails, it returns an error number.

Number | Meaning
0xC00D0011 | This property cannot be set if the encoder engine is running.

Remarks

The rating information specifies the audience for which the content is suitable.

Example Code

' Create a WMEncoder object.
Dim Encoder As WMEncoder
Set Encoder = New WMEncoder

' Retrieve an IWMEncDisplayInfo object.
Dim DispInfo As IWMEncDisplayInfo
Set DispInfo = Encoder.DisplayInfo

' Declare string variables.
Dim strAuthor As String
Dim strCopyright As String
Dim strDescription As String
Dim strRating As String
Dim strTitle As String

' Set the IWMEncDisplayInfo properties
DispInfo.Author = "Content author's name."
DispInfo.Copyright = "Copyright 2000. All rights reserved."
DispInfo.Description = "Description of the encoded content."
DispInfo.Rating = "Not applicable."
DispInfo.Title = "Title of the encoded content."

' Retrieve the IWMEncDisplayInfo properties.
strAuthor = DispInfo.Author
strCopyright = DispInfo.Copyright
strDescription = DispInfo.Description
strRating = DispInfo.Rating
strTitle = DispInfo.Title

See Also

  • IWMEncDisplayInfo.Author
  • IWMEncDisplayInfo.Copyright
  • IWMEncDisplayInfo.Description
  • IWMEncDisplayInfo Object
  • IWMEncDisplayInfo.Title


IWMEncDisplayInfo.Title

The Title property specifies and retrieves the title of the content being encoded.

Syntax

IWMEncDisplayInfo.Title = BSTR
BSTR = IWMEncDisplayInfo.Title

Parameters

This property takes no parameters.

Return Values

When getting the value, this property returns a BSTR containing the title. If this property fails, it returns an error number.

Number | Meaning
0xC00D0011 | This property cannot be set if the encoder engine is running.

Example Code

' Create a WMEncoder object.
Dim Encoder As WMEncoder
Set Encoder = New WMEncoder

' Retrieve an IWMEncDisplayInfo object.
Dim DispInfo As IWMEncDisplayInfo
Set DispInfo = Encoder.DisplayInfo

' Declare string variables.
Dim strAuthor As String
Dim strCopyright As String
Dim strDescription As String
Dim strRating As String
Dim strTitle As String

' Set the IWMEncDisplayInfo properties
DispInfo.Author = "Content author's name."
DispInfo.Copyright = "Copyright 2000. All rights reserved."
DispInfo.Description = "Description of the encoded content."
DispInfo.Rating = "Not applicable."
DispInfo.Title = "Title of the encoded content."

' Retrieve the IWMEncDisplayInfo properties.
strAuthor = DispInfo.Author
strCopyright = DispInfo.Copyright
strDescription = DispInfo.Description
strRating = DispInfo.Rating
strTitle = DispInfo.Title

See Also

  • IWMEncDisplayInfo.Author
  • IWMEncDisplayInfo.Copyright
  • IWMEncDisplayInfo.Description
  • IWMEncDisplayInfo Object
  • IWMEncDisplayInfo.Rating


IWMEncFile Object

The IWMEncFile object manages the name of the file used for archiving encoded content. The IWMEncFile object exposes the following property.

Property | Description
LocalFileName | Specifies and retrieves the full pathname of the file.

See Also

  • [Visual C++] IWMEncFile Interface
  • Objects (Visual Basic)


IWMEncFile.LocalFileName

The LocalFileName property specifies and retrieves the full path of the file used for archiving encoded content.

Syntax

IWMEncFile.LocalFileName = BSTR
BSTR = IWMEncFile.LocalFileName

Parameters

This property takes no parameters.

Return Values

When getting the value, this property returns a BSTR containing the name of the local file. If this property fails, it returns an error number.

Number | Meaning
0xC00D0011 | This property cannot be set if the encoder engine is running.

Remarks

The file being used for archiving encoded content must reside on either the computer that is broadcasting the content or the local network to which that computer is connected. If you want to disable the archiving process, you can either specify an empty string for the file name, or set WMEncoder.EnableAutoArchive to VARIANT_FALSE and not use the WMEncoder.Archive method to manually begin archiving.

Example Code

' Create a WMEncoder object. To handle the events raised by the
' WMEncoder object, use the WithEvents keyword.
Dim WithEvents Encoder As WMEncoder
Set Encoder = New WMEncoder

' Declare objects and variables.
Dim SrcGrpColl As IWMEncSourceGroupCollection
Dim SrcGrp As IWMEncSourceGroup
Dim AudSrc As IWMEncSource
Dim VidSrc As IWMEncVideoSource
Dim ProColl As IWMEncProfileCollection
Dim Pro As IWMEncProfile
Dim File As IWMEncFile
Dim i As Integer

' Create an IWMEncSourceGroupCollection object.
Set SrcGrpColl = Encoder.SourceGroupCollection

' Create an IWMEncSourceGroup object.
Set SrcGrp = SrcGrpColl.Add("SG_1")

' Create a video and an audio source object.
Set AudSrc = SrcGrp.AddSource(WMENC_AUDIO)
Set VidSrc = SrcGrp.AddSource(WMENC_VIDEO)

' Create an IWMEncFile object.
Set File = Encoder.File

' Specify the .avi source file.
AudSrc.SetInput "C:\test.avi"
VidSrc.SetInput "C:\test.avi"

' Specify the output Windows Media file.
File.LocalFileName = "C:\test.wmv"

' Loop through the collection of system profiles to set
' a specific profile into the source group object.
Set ProColl = Encoder.ProfileCollection
For i = 0 To ProColl.Count - 1
    Set Pro = ProColl.Item(i)
    If Pro.Name = "name of a system profile" Then
        SrcGrp.Profile = ProColl.Item(i)
        Exit For
    End If
Next

' Tell the encoder to start archiving when the encoder
' engine starts running.
Encoder.EnableAutoArchive = True

' Initialize the encoder engine.
Encoder.PrepareToEncode True

' Start the encoder engine.
Encoder.Start

' To determine when the archiving process has stopped,
' create an event procudure to handle the OnArchiveStateChange
' event. The encoder engine stops when it reaches the end
' of the .avi file.
Private Sub Encoder_OnArchiveStateChange(ByVal enumArchive As WMEncoderLib.WMENC_ARCHIVE_TYPE, ByVal enumState As WMEncoderLib.WMENC_ARCHIVE_STATE)
    Select Case enumArchive
        Case WMENC_ARCHIVE_LOCAL
        Select Case enumState
            Case WMENC_ARCHIVE_STOPPED
                MsgBox "Encoder Stopped "
       End Select
    End Select
End Sub

See Also

  • _IWMEncoderEvents.OnArchiveStateChange
  • IWMEncFile Object
  • IWMEncProfile Object
  • IWMEncProfileCollection Object
  • IWMEncSource Object
  • IWMEncSourceGroup Object
  • IWMEncSourceGroupCollection Object
  • WMEncoder.Archive
  • WMEncoder.EnableAutoArchive


IWMEncFileArchiveStats Object

The IWMEncFileArchiveStats object retrieves the size, in bytes, of the archive file and the duration, in milliseconds, of the encoded content stored in the file.The IWMEncFileArchiveStats object exposes the following properties.

Property | Description
FileDuration | Retrieves the duration, in milliseconds, of the encoded content stored in an archive file.
FileSize | Retrieves the size, in bytes, of the archive file.

See Also

  • [Visual C++] IWMEncFileArchiveStats Interface
  • Objects (Visual Basic)


IWMEncFileArchiveStats.FileDuration

The FileDuration property retrieves the duration, in milliseconds, of the encoded content stored in an archive file.

Syntax

WMENC_LONGLONG = IWMEncFileArchiveStats.FileDuration

Parameters

This property takes no parameters.

Return Values

When getting the value, this property returns a QWORD containing the output file duration.

Remarks

The WMENC_LONGLONG data type is a typedef from the CURRENCY type. A 64-bit integer is needed to hold the duration, and CURRENCY is the only 64-bit integer type that Automation supports. However, CURRENCY is a fixed-point type that has the decimal point moved four places to the left. Therefore, to display the CURRENCY value as a true integer and retrieve the correct file duration, you must multiply the return value by 10,000.

File duration information does not persist after the encoding process has stopped. You can create a timer object to retrieve the archiving statistics.

Example Code

' See the IWMEncFile object for an example that explains how to
' create and use an archive file.
' The following example shows how to capture archiving statistics
' during the encoding process.

' Declare objects and variables.

Dim Statistics As IWMEncStatistics
Dim FileStats As IWMEncFileArchiveStats
Dim Duration As WMENC_LONGLONG
Dim Size As WMENC_LONGLONG

' Create a IWMEncStatistics object and retrieve
' the IWMEncFileArchiveStats object from it.
Set Statistics = Encoder.Statistics
Set FileStats = Statistics.FileArchiveStats

' Find the duration and size of the archive file.
Duration = FileStats.FileDuration * 10000
Size = FileStats.FileSize * 10000

See Also

  • IWMEncFile Object
  • IWMEncFileArchiveStats Object


IWMEncFileArchiveStats.FileSize

The FileSize property retrieves the size, in bytes, of the archive file.

Syntax

WMENC_LONGLONG = IWMEncFileArchiveStats.FileSize

Parameters

This property takes no parameters.

Return Values

When getting the value, this property returns a QWORD containing the output file size.

Remarks

The WMENC_LONGLONG data type is a typdef from the CURRENCY type. A 64-bit integer is needed to hold the size of the archive file, and CURRENCY is the only 64-bit integer type Automation contains. However, CURRENCY is a fixed-point type that has the decimal point moved four places to the left. Therefore, to display the CURRENCY value as a true integer and retrieve the correct file size, you must multiply the return value by 10,000.

File size information does not persist after the encoding process has stopped. You can create a timer object to retrieve the archiving statistics.

Example Code

' See the IWMEncFile object for an example that explains how to
' create and use an archive file.
' The following example shows how to capture archiving statistics
' during the encoding process.

' Declare objects and variables.

Dim Statistics As IWMEncStatistics
Dim FileStats As IWMEncFileArchiveStats
Dim Duration As WMENC_LONGLONG
Dim Size As WMENC_LONGLONG

' Create a IWMEncStatistics object and retrieve
' the IWMEncFileArchiveStats object from it.
Set Statistics = Encoder.Statistics
Set FileStats = Statistics.FileArchiveStats

' Find the duration and size of the archive file.
Duration = FileStats.FileDuration * 10000
Size = FileStats.FileSize * 10000

See Also

  • IWMEncFile Object
  • IWMEncFileArchiveStats Object


IWMEncIndexerStats Object

The IWMEncIndexerStats object monitors the indexing process for a Windows Media file. A file index enables operations, such as fast forwarding, that must seek to specific time offsets in the file. If you specify an archive file, Windows Media Encoder automatically starts the indexing process on a separate thread in the background of the encoder engine immediately after the archiving process stops. The indexing process stops at the end of the file.The IWMEncIndexerStats object exposes the following properties.

Property | Description
FileCount | Retrieves the number of files remaining in the indexing queue, including the file currently being indexed.
FileName | Retrieves the name of a specific file in the indexing queue.
PercentComplete | Retrieves the percentage of indexing completed for the file currently being indexed.

See Also

  • [Visual C++] IWMEncIndexerStats Interface
  • Objects (Visual Basic)


IWMEncIndexerStats.FileCount

The FileCount property retrieves the number of files remaining in the indexing queue, including the file currently being indexed.

Syntax

Long = IWMEncIndexerStats.FileCount

Parameters

This property takes no parameters.

Return Values

When getting the value, this property returns a LONG containing the number of files.

Example Code

' Create a WMEncoder object.
Dim Encoder As WMEncoder
Set Encoder = New WMEncoder

' Declare objects and variables.
Dim Statistics As IWMEncStatistics
Dim IndexStats As IWMEncIndexerStats
Dim lFileCount As Long
Dim sFileName As String
Dim lPercent As Long

' Retrieve an IWMEncStatistics object, and use it to
' retrieve an IWMEncIndexerStats object.
Set Statistics = Encoder.Statistics
Set IndexStats = Statistics.IndexerStats

' Retrieve the number of files remaining in the queue.
lFileCount = IndexStats.FileCount

' Retrieve the name of a specific file in the queue.
sFileName = IndexStats.FileName(0)

' Retrieve the percentage of indexing completed on the
' current file.
lPercent = IndexStats.PercentComplete

See Also

  • IWMEncIndexerStats Object
  • IWMEncStatistics Object
  • WMEncoder Object


IWMEncIndexerStats.FileName

The FileName property retrieves the name of a specific file in the indexing queue.

Syntax

BSTR = IWMEncIndexerStats.FileName ( lIndex )

Parameters

lIndex

[in] LONG containing the index into the queue. The index is zero-based.

Return Values

When getting the value, this property returns a BSTR containing the file name.

Example Code

' Create a WMEncoder object.
Dim Encoder As WMEncoder
Set Encoder = New WMEncoder

' Declare objects and variables.
Dim Statistics As IWMEncStatistics
Dim IndexStats As IWMEncIndexerStats
Dim lFileCount As Long
Dim sFileName As String
Dim lPercent As Long

' Retrieve an IWMEncStatistics object, and use it to
' retrieve an IWMEncIndexerStats object.
Set Statistics = Encoder.Statistics
Set IndexStats = Statistics.IndexerStats

' Retrieve the number of files remaining in the queue.
lFileCount = IndexStats.FileCount

' Retrieve the name of a specific file in the queue.
sFileName = IndexStats.FileName(0)

' Retrieve the percentage of indexing completed on the
' current file.
lPercent = IndexStats.PercentComplete

See Also

  • IWMEncIndexerStats Object
  • IWMEncStatistics Object
  • WMEncoder Object


IWMEncIndexerStats.PercentComplete

The PercentComplete property retrieves the percentage of indexing completed for the file currently being indexed.

Syntax

Long = IWMEncIndexerStats.PercentComplete

Parameters

This property takes no parameters.

Return Values

When getting the value, this property returns a LONG containing the percentage of indexing completed.

Example Code

' Create a WMEncoder object.
Dim Encoder As WMEncoder
Set Encoder = New WMEncoder

' Declare objects and variables.
Dim Statistics As IWMEncStatistics
Dim IndexStats As IWMEncIndexerStats
Dim lFileCount As Long
Dim sFileName As String
Dim lPercent As Long

' Retrieve an IWMEncStatistics object, and use it to
' retrieve an IWMEncIndexerStats object.
Set Statistics = Encoder.Statistics
Set IndexStats = Statistics.IndexerStats

' Retrieve the number of files remaining in the queue.
lFileCount = IndexStats.FileCount

' Retrieve the name of a specific file in the queue.
sFileName = IndexStats.FileName(0)

' Retrieve the percentage of indexing completed on the
' current file.
lPercent = IndexStats.PercentComplete

See Also

  • IWMEncIndexerStats Object
  • IWMEncStatistics Object
  • WMEncoder Object


IWMEncNetConnectionStats Object

The IWMEncNetConnectionStats object identifies the number of clients connected to the computer that is hosting Windows Media Encoder, and the protocol and IP address of a specific client. The IWMEncNetConnectionStats object exposes the following properties.

Property | Description
ClientCount | Retrieves the number of clients connected to Windows Media Encoder.
ClientInfo | Retrieves the protocol and IP address of a specific client.

See Also

  • [Visual C++] IWMEncNetConnectionStats Interface
  • Objects (Visual Basic)


IWMEncNetConnectionStats.ClientCount

The ClientCount property retrieves the number of clients connected to Windows Media Encoder.

Syntax

Long = IWMEncNetConnection.ClientCount

Parameters

This property takes no parameters.

Return Values

When getting the value, this property returns a LONG containing the number of connected clients.

Remarks

Windows Media Encoder can unicast and multicast from a Windows Media server, and up to fifty clients can connect directly to the computer hosting Windows Media Encoder.

Example Code

' Declare objects and variables.
Dim Statistics As IWMEncStatistics
Dim NetClient As IWMEncNetConnectionStats
Dim lClients As Long
Dim sAddr As String
Dim i As Integer

' Retrieve an IWMEncStatistics object and an IWMEncNetConnections
' object.
Set Statistics = Encoder.Statistics
Set NetClient = Statistics.NetConnectionStats

' Retrieve the number of clients connected.
lClients = NetClient.ClientCount

' Retrieve the IP address of each client.
For i = 1 To lClients
    sAddr = NetClient.ClientInfo(i, WMENC_PROTOCOL_HTTP)
Next

See Also

  • IWMEncNetConnectionStats Object
  • IWMEncStatistics Object
  • WMEncoder Object


IWMEncNetConnectionStats.ClientInfo

The ClientInfo property retrieves the protocol and IP address of a specific client.

Syntax

BSTR = IWMEncNetConnection.ClientInfo ( lIndex, Protocol )

Parameters

lIndex

[in] LONG containing the index identifying the client.

Protocol

[out] Member of a WMENC_BROADCAST_PROTOCOL enumeration type indicating the type of protocol through which the client is connected. This must be the following value.

Value | Number | Description
WMENC_PROTOCOL_HTTP | 1 | The transmission uses the HTTP protocol.

Return Values

When getting the value, this property returns a BSTR containing the IP address of the client.

Remarks

You can use this method to monitor client connections. For instance, you can determine how many clients are connected from a specific range of IP addresses.

Example Code

' Declare objects and variables.
Dim Statistics As IWMEncStatistics
Dim NetClient As IWMEncNetConnectionStats
Dim lClients As Long
Dim sAddr As String
Dim i As Integer

' Retrieve an IWMEncStatistics object and an IWMEncNetConnections
' object.
Set Statistics = Encoder.Statistics
Set NetClient = Statistics.NetConnectionStats

' Retrieve the number of clients connected to the encoder engine.
lClients = NetClient.ClientCount

' Retrieve the IP address of each client.
For i = 1 To lClients
    sAddr = NetClient.ClientInfo(i, WMENC_PROTOCOL_HTTP)
Next

See Also

  • IWMEncNetConnectionStats Object
  • IWMEncStatistics Object
  • WMEncoder Object


IWMEncOutputStats Object

The IWMEncOutputStats object retrieves status information about the encoding session.The IWMEncOutputStats object exposes the following properties.

Property | Description
AverageBitrate | Retrieves the average number of bits encoded per second since the encoder engine was started.
AverageSampleRate | Retrieves the average number of media samples encoded per second since the encoder engine was started.
ByteCount | Retrieves the number of bytes encoded since the encoder engine was started.
CurrentBitrate | Retrieves the number of bits being encoded per second at the moment this method is called.
CurrentSampleRate | Retrieves the number of samples being encoded per second at the moment this method is called.
DroppedByteCount | Retrieves the number of bytes dropped since the encoder engine started.
DroppedSampleCount | Retrieves the number of media samples not encoded since the encoder engine was started.
ExpectedBitrate | Retrieves the encoding bit-rate expected throughout the encoding session.
ExpectedSampleRate | Retrieves the encoding sample rate expected throughout the encoding session.
SampleCount | Retrieves the number of samples encoded since the encoder engine was started.

See Also

  • [Visual C++] IWMEncOutputStats Interface


IWMEncOutputStats.AverageBitrate

The AverageBitrate property retrieves the average number of bits encoded per second since the encoder engine was started.

Syntax

Long = IWMEncOutputStats.AverageBitrate

Parameters

This property takes no parameters.

Return Values

When getting the value, this property returns a Long containing the average bit-rate.

Remarks

This property is read-only.

Example Code

' Create a WMEncoder Object.
Dim Encoder As WMEncoder
Set Encoder = New WMEncoder

' Retrieve an IWMEncStatistics object
Dim Statistics As IWMEncStatistics
Set Statistics = Encoder.Statistics

' Configure the encoder engine
' For configuration code see the IWMEncSource object

' Retrieve an IWMEncOutputStats object from the
' IWMEncStatistics object
Dim OutputStats As IWMEncOutputStats
Set OutputStats = Statistics.StreamOutputStats(WMENC_AUDIO, 0, 0)

' You can create a timer control to retrieve the statistics
' (as follows) after you start the encoder engine.
Dim lAvgBitrate As Long
Dim lAvgSampleRate As Long
Dim lByteCount As WMENC_LONGLONG
Dim lCurrentBitRate As Long
Dim lCurrentSampleRate As Long
Dim lDroppedByteCount As WMENC_LONGLONG
Dim lDroppedSampleCount As WMENC_LONGLONG
Dim lExpectedBitRate As Long
Dim lExpectedSampleRate As Long
Dim lSampleCount As WMENC_LONGLONG

lAvgBitrate = OutputStats.AverageBitrate
lAvgSampleRate = OutputStats.AverageSampleRate
lByteCount = OutputStats.ByteCount
lCurrentBitRate = OutputStats.CurrentBitrate
lCurrentSampleRate = OutputStats.CurrentSampleRate
lDroppedByteCount = OutputStats.DroppedByteCount
lDroppedSampleCount = OutputStats.DroppedSampleCount
lExpectedBitRate = OutputStats.ExpectedBitrate
lExpectedSampleRate = OutputStats.ExpectedSampleRate
lSampleCount = OutputStats.SampleCount

See Also

  • IWMEncOutputStats Object


IWMEncOutputStats.AverageSampleRate

The AverageSampleRate property retrieves the average number of media samples encoded per second since the encoder engine was started.

Syntax

Long = IWMEncOutputStats.AverageSampleRate

Parameters

This property takes no parameters.

Return Values

When getting the value, this property returns a Long containing the average sample rate.

Remarks

This property is read-only.

Example Code

' Create a WMEncoder Object.
Dim Encoder As WMEncoder
Set Encoder = New WMEncoder

' Retrieve an IWMEncStatistics object
Dim Statistics As IWMEncStatistics
Set Statistics = Encoder.Statistics

' You must manually configure the encoder engine or load
' a configuration from a file. For an example, see the
' IWMEncFile object.

' Retrieve an IWMEncOutputStats object from the
' IWMEncStatistics object
Dim OutputStats As IWMEncOutputStats
Set OutputStats = Statistics.StreamOutputStats(WMENC_AUDIO, 0, 0)

' You can create a timer control to retrieve the statistics
' (as follows) after you start the encoder engine.
Dim lAvgBitrate As Long
Dim lAvgSampleRate As Long
Dim lByteCount As WMENC_LONGLONG
Dim lCurrentBitRate As Long
Dim lCurrentSampleRate As Long
Dim lDroppedByteCount As WMENC_LONGLONG
Dim lDroppedSampleCount As WMENC_LONGLONG
Dim lExpectedBitRate As Long
Dim lExpectedSampleRate As Long
Dim lSampleCount As WMENC_LONGLONG

lAvgBitrate = OutputStats.AverageBitrate
lAvgSampleRate = OutputStats.AverageSampleRate
lByteCount = OutputStats.ByteCount
lCurrentBitRate = OutputStats.CurrentBitrate
lCurrentSampleRate = OutputStats.CurrentSampleRate
lDroppedByteCount = OutputStats.DroppedByteCount
lDroppedSampleCount = OutputStats.DroppedSampleCount
lExpectedBitRate = OutputStats.ExpectedBitrate
lExpectedSampleRate = OutputStats.ExpectedSampleRate
lSampleCount = OutputStats.SampleCount

See Also

  • IWMEncOutputStats Object


IWMEncOutputStats.ByteCount

The ByteCount property retrieves the number of bytes encoded since the encoder engine was started.

Syntax

WMENC_LONGLONG = IWMEncOutputStats.ByteCount

Parameters

This property takes no parameters.

Return Values

When getting the value, this property returns a QWORD containing the byte count.

Remarks

This property is read-only. The WMENC_LONGLONG data type is a typedef from the CURRENCY type. A 64-bit integer is needed to hold the byte count, and CURRENCY is the only 64-bit integer type that Automation supports. However, CURRENCY is a fixed-point type that has the decimal point moved four places to the left. Therefore, to display the CURRENCY value as a true integer and retrieve the correct byte count, you must multiply the return value by 10,000.

Example Code

' Create a WMEncoder Object.
Dim Encoder As WMEncoder
Set Encoder = New WMEncoder

' Retrieve an IWMEncStatistics object
Dim Statistics As IWMEncStatistics
Set Statistics = Encoder.Statistics

' You must manually configure the encoder engine or load
' a configuration from a file. For an example, see the
' IWMEncFile object.

' Retrieve an IWMEncOutputStats object from the
' IWMEncStatistics object
Dim OutputStats As IWMEncOutputStats
Set OutputStats = Statistics.StreamOutputStats(WMENC_AUDIO, 0, 0)

' You can create a timer control to retrieve the statistics
' (as follows) after you start the encoder engine.
Dim lAvgBitrate As Long
Dim lAvgSampleRate As Long
Dim lByteCount As WMENC_LONGLONG
Dim lCurrentBitRate As Long
Dim lCurrentSampleRate As Long
Dim lDroppedByteCount As WMENC_LONGLONG
Dim lDroppedSampleCount As WMENC_LONGLONG
Dim lExpectedBitRate As Long
Dim lExpectedSampleRate As Long
Dim lSampleCount As WMENC_LONGLONG

lAvgBitrate = OutputStats.AverageBitrate
lAvgSampleRate = OutputStats.AverageSampleRate
lByteCount = OutputStats.ByteCount
lCurrentBitRate = OutputStats.CurrentBitrate
lCurrentSampleRate = OutputStats.CurrentSampleRate
lDroppedByteCount = OutputStats.DroppedByteCount
lDroppedSampleCount = OutputStats.DroppedSampleCount
lExpectedBitRate = OutputStats.ExpectedBitrate
lExpectedSampleRate = OutputStats.ExpectedSampleRate
lSampleCount = OutputStats.SampleCount

See Also

  • IWMEncOutputStats Object


IWMEncOutputStats.CurrentBitrate

The CurrentBitrate property retrieves the number of bits being encoded per second at the moment this method is called.

Syntax

Long = IWMEncOutputStats.CurrentBitrate

Parameters

This property takes no parameters.

Return Values

When getting the value, this property returns a Long containing the current bit-rate.

Remarks

This property is read-only.

Example Code

' Create a WMEncoder Object.
Dim Encoder As WMEncoder
Set Encoder = New WMEncoder

' Retrieve an IWMEncStatistics object
Dim Statistics As IWMEncStatistics
Set Statistics = Encoder.Statistics

' You must manually configure the encoder engine or load
' a configuration from a file. For an example, see the
' IWMEncFile object.

' Retrieve an IWMEncOutputStats object from the
' IWMEncStatistics object
Dim OutputStats As IWMEncOutputStats
Set OutputStats = Statistics.StreamOutputStats(WMENC_AUDIO, 0, 0)

' You can create a timer control to retrieve the statistics
' (as follows) after you start the encoder engine.
Dim lAvgBitrate As Long
Dim lAvgSampleRate As Long
Dim lByteCount As WMENC_LONGLONG
Dim lCurrentBitRate As Long
Dim lCurrentSampleRate As Long
Dim lDroppedByteCount As WMENC_LONGLONG
Dim lDroppedSampleCount As WMENC_LONGLONG
Dim lExpectedBitRate As Long
Dim lExpectedSampleRate As Long
Dim lSampleCount As WMENC_LONGLONG

lAvgBitrate = OutputStats.AverageBitrate
lAvgSampleRate = OutputStats.AverageSampleRate
lByteCount = OutputStats.ByteCount
lCurrentBitRate = OutputStats.CurrentBitrate
lCurrentSampleRate = OutputStats.CurrentSampleRate
lDroppedByteCount = OutputStats.DroppedByteCount
lDroppedSampleCount = OutputStats.DroppedSampleCount
lExpectedBitRate = OutputStats.ExpectedBitrate
lExpectedSampleRate = OutputStats.ExpectedSampleRate
lSampleCount = OutputStats.SampleCount

See Also

  • IWMEncOutputStats Object


IWMEncOutputStats.CurrentSampleRate

The CurrentSampleRate property retrieves the number of samples being encoded per second at the moment this method is called.

Syntax

Long = IWMEncOutputStats.CurrentSampleRate

Parameters

This property takes no parameters.

Return Values

When getting the value, this property returns a Long containing the current sample rate.

Remarks

This property is read-only.

Example Code

' Create a WMEncoder Object.
Dim Encoder As WMEncoder
Set Encoder = New WMEncoder

' Retrieve an IWMEncStatistics object
Dim Statistics As IWMEncStatistics
Set Statistics = Encoder.Statistics

' You must manually configure the encoder engine or load
' a configuration from a file. For an example, see the
' IWMEncFile object.

' Retrieve an IWMEncOutputStats object from the
' IWMEncStatistics object
Dim OutputStats As IWMEncOutputStats
Set OutputStats = Statistics.StreamOutputStats(WMENC_AUDIO, 0, 0)

' You can create a timer control to retrieve the statistics
' (as follows) after you start the encoder engine.
Dim lAvgBitrate As Long
Dim lAvgSampleRate As Long
Dim lByteCount As WMENC_LONGLONG
Dim lCurrentBitRate As Long
Dim lCurrentSampleRate As Long
Dim lDroppedByteCount As WMENC_LONGLONG
Dim lDroppedSampleCount As WMENC_LONGLONG
Dim lExpectedBitRate As Long
Dim lExpectedSampleRate As Long
Dim lSampleCount As WMENC_LONGLONG

lAvgBitrate = OutputStats.AverageBitrate
lAvgSampleRate = OutputStats.AverageSampleRate
lByteCount = OutputStats.ByteCount
lCurrentBitRate = OutputStats.CurrentBitrate
lCurrentSampleRate = OutputStats.CurrentSampleRate
lDroppedByteCount = OutputStats.DroppedByteCount
lDroppedSampleCount = OutputStats.DroppedSampleCount
lExpectedBitRate = OutputStats.ExpectedBitrate
lExpectedSampleRate = OutputStats.ExpectedSampleRate
lSampleCount = OutputStats.SampleCount

See Also

  • IWMEncOutputStats Object


IWMEncOutputStats.DroppedByteCount

The DroppedByteCount property retrieves the number of bytes dropped since the encoder engine was started.

Syntax

WMENC_LONGLONG = IWMEncOutputStats.DroppedByteCount

Parameters

This property takes no parameters.

Return Values

When getting the value, this property returns a QWORD containing the dropped byte count.

Remarks

This property is read-only. The WMENC_LONGLONG data type is a typedef from the CURRENCY type. A 64-bit integer is needed to hold the count, and CURRENCY is the only 64-bit integer type that Automation supports. However, CURRENCY is a fixed-point type that has the decimal point moved four places to the left. Therefore, to display the CURRENCY value as a true integer and retrieve the correct count, you must multiply the return value by 10,000.

Example Code

' Create a WMEncoder Object.
Dim Encoder As WMEncoder
Set Encoder = New WMEncoder

' Retrieve an IWMEncStatistics object
Dim Statistics As IWMEncStatistics
Set Statistics = Encoder.Statistics

' You must manually configure the encoder engine or load
' a configuration from a file. For an example, see the
' IWMEncFile object.

' Retrieve an IWMEncOutputStats object from the
' IWMEncStatistics object
Dim OutputStats As IWMEncOutputStats
Set OutputStats = Statistics.StreamOutputStats(WMENC_AUDIO, 0, 0)

' You can create a timer control to retrieve the statistics
' (as follows) after you start the encoder engine.
Dim lAvgBitrate As Long
Dim lAvgSampleRate As Long
Dim lByteCount As WMENC_LONGLONG
Dim lCurrentBitRate As Long
Dim lCurrentSampleRate As Long
Dim lDroppedByteCount As WMENC_LONGLONG
Dim lDroppedSampleCount As WMENC_LONGLONG
Dim lExpectedBitRate As Long
Dim lExpectedSampleRate As Long
Dim lSampleCount As WMENC_LONGLONG

lAvgBitrate = OutputStats.AverageBitrate
lAvgSampleRate = OutputStats.AverageSampleRate
lByteCount = OutputStats.ByteCount
lCurrentBitRate = OutputStats.CurrentBitrate
lCurrentSampleRate = OutputStats.CurrentSampleRate
lDroppedByteCount = OutputStats.DroppedByteCount
lDroppedSampleCount = OutputStats.DroppedSampleCount
lExpectedBitRate = OutputStats.ExpectedBitrate
lExpectedSampleRate = OutputStats.ExpectedSampleRate
lSampleCount = OutputStats.SampleCount

See Also

  • IWMEncOutputStats Object


IWMEncOutputStats.DroppedSampleCount

The DroppedSampleCount property retrieves the number of media samples dropped since the encoder engine was started.

Syntax

WMENC_LONGLONG = IWMEncOutputStats.DroppedSampleCount

Parameters

This property takes no parameters.

Return Values

When getting the value, this property returns a QWORD containing the number of samples dropped.

Remarks

This property is read-only. The WMENC_LONGLONG data type is a typedef from the CURRENCY type. A 64-bit integer is needed to hold the count, and CURRENCY is the only 64-bit integer type that Automation supports. However, CURRENCY is a fixed-point type that has the decimal point moved four places to the left. Therefore, to display the CURRENCY value as a true integer and retrieve the correct count, you must multiply the return value by 10,000.

Example Code

' Create a WMEncoder Object.
Dim Encoder As WMEncoder
Set Encoder = New WMEncoder

' Retrieve an IWMEncStatistics object
Dim Statistics As IWMEncStatistics
Set Statistics = Encoder.Statistics

' You must manually configure the encoder engine or load
' a configuration from a file. For an example, see the
' IWMEncFile object.

' Retrieve an IWMEncOutputStats object from the
' IWMEncStatistics object
Dim OutputStats As IWMEncOutputStats
Set OutputStats = Statistics.StreamOutputStats(WMENC_AUDIO, 0, 0)

' You can create a timer control to retrieve the statistics
' (as follows) after you start the encoder engine.
Dim lAvgBitrate As Long
Dim lAvgSampleRate As Long
Dim lByteCount As WMENC_LONGLONG
Dim lCurrentBitRate As Long
Dim lCurrentSampleRate As Long
Dim lDroppedByteCount As WMENC_LONGLONG
Dim lDroppedSampleCount As WMENC_LONGLONG
Dim lExpectedBitRate As Long
Dim lExpectedSampleRate As Long
Dim lSampleCount As WMENC_LONGLONG

lAvgBitrate = OutputStats.AverageBitrate
lAvgSampleRate = OutputStats.AverageSampleRate
lByteCount = OutputStats.ByteCount
lCurrentBitRate = OutputStats.CurrentBitrate
lCurrentSampleRate = OutputStats.CurrentSampleRate
lDroppedByteCount = OutputStats.DroppedByteCount
lDroppedSampleCount = OutputStats.DroppedSampleCount
lExpectedBitRate = OutputStats.ExpectedBitrate
lExpectedSampleRate = OutputStats.ExpectedSampleRate
lSampleCount = OutputStats.SampleCount

See Also

  • IWMEncOutputStats Object


IWMEncOutputStats.ExpectedBitrate

The ExpectedBitrate property retrieves the encoding bit-rate expected throughout the encoding session.

Syntax

Long = IWMEncOutputStats.ExpectedBitrate

Parameters

This property takes no parameters.

Return Values

When getting the value, this property returns a Long containing the expected bit-rate.

Remarks

This property is read-only.

Example Code

' Create a WMEncoder Object.
Dim Encoder As WMEncoder
Set Encoder = New WMEncoder

' Retrieve an IWMEncStatistics object
Dim Statistics As IWMEncStatistics
Set Statistics = Encoder.Statistics

' You must manually configure the encoder engine or load
' a configuration from a file. For an example, see the
' IWMEncFile object.

' Retrieve an IWMEncOutputStats object from the
' IWMEncStatistics object
Dim OutputStats As IWMEncOutputStats
Set OutputStats = Statistics.StreamOutputStats(WMENC_AUDIO, 0, 0)

' You can create a timer control to retrieve the statistics
' (as follows) after you start the encoder engine.
Dim lAvgBitrate As Long
Dim lAvgSampleRate As Long
Dim lByteCount As WMENC_LONGLONG
Dim lCurrentBitRate As Long
Dim lCurrentSampleRate As Long
Dim lDroppedByteCount As WMENC_LONGLONG
Dim lDroppedSampleCount As WMENC_LONGLONG
Dim lExpectedBitRate As Long
Dim lExpectedSampleRate As Long
Dim lSampleCount As WMENC_LONGLONG

lAvgBitrate = OutputStats.AverageBitrate
lAvgSampleRate = OutputStats.AverageSampleRate
lByteCount = OutputStats.ByteCount
lCurrentBitRate = OutputStats.CurrentBitrate
lCurrentSampleRate = OutputStats.CurrentSampleRate
lDroppedByteCount = OutputStats.DroppedByteCount
lDroppedSampleCount = OutputStats.DroppedSampleCount
lExpectedBitRate = OutputStats.ExpectedBitrate
lExpectedSampleRate = OutputStats.ExpectedSampleRate
lSampleCount = OutputStats.SampleCount

See Also

  • IWMEncOutputStats Object


IWMEncOutputStats.ExpectedSampleRate

The ExpectedSampleRate property retrieves the encoding sample rate expected throughout the encoding session.

Syntax

Long = IWMEncOutputStats.ExpectedSampleRate

Parameters

This property takes no parameters.

Return Values

When getting the value, this property returns a Long containing the expected sample rate.

Remarks

This property is read-only.

Example Code

' Create a WMEncoder Object.
Dim Encoder As WMEncoder
Set Encoder = New WMEncoder

' Retrieve an IWMEncStatistics object
Dim Statistics As IWMEncStatistics
Set Statistics = Encoder.Statistics

' You must manually configure the encoder engine or load
' a configuration from a file. For an example, see the
' IWMEncFile object.

' Retrieve an IWMEncOutputStats object from the
' IWMEncStatistics object
Dim OutputStats As IWMEncOutputStats
Set OutputStats = Statistics.StreamOutputStats(WMENC_AUDIO, 0, 0)

' You can create a timer control to retrieve the statistics
' (as follows) after you start the encoder engine.
Dim lAvgBitrate As Long
Dim lAvgSampleRate As Long
Dim lByteCount As WMENC_LONGLONG
Dim lCurrentBitRate As Long
Dim lCurrentSampleRate As Long
Dim lDroppedByteCount As WMENC_LONGLONG
Dim lDroppedSampleCount As WMENC_LONGLONG
Dim lExpectedBitRate As Long
Dim lExpectedSampleRate As Long
Dim lSampleCount As WMENC_LONGLONG

lAvgBitrate = OutputStats.AverageBitrate
lAvgSampleRate = OutputStats.AverageSampleRate
lByteCount = OutputStats.ByteCount
lCurrentBitRate = OutputStats.CurrentBitrate
lCurrentSampleRate = OutputStats.CurrentSampleRate
lDroppedByteCount = OutputStats.DroppedByteCount
lDroppedSampleCount = OutputStats.DroppedSampleCount
lExpectedBitRate = OutputStats.ExpectedBitrate
lExpectedSampleRate = OutputStats.ExpectedSampleRate
lSampleCount = OutputStats.SampleCount

See Also

  • IWMEncOutputStats Object


IWMEncOutputStats.SampleCount

The SampleCount property retrieves the number of samples encoded since the encoder engine was started.

Syntax

WMENC_LONGLONG = IWMEncOutputStats.SampleCount

Parameters

This property takes no parameters.

Return Values

When getting the value, this property returns a QWORD containing the number of encoded samples.

Remarks

This property is read-only. The WMENC_LONGLONG data type is a typedef from the CURRENCY type. A 64-bit integer is needed to hold the sample count, and CURRENCY is the only 64-bit integer type that Automation supports. However, CURRENCY is a fixed-point type that has the decimal point moved four places to the left. Therefore, to display the CURRENCY value as a true integer and retrieve the correct sample count, you must multiply the return value by 10,000.

Example Code

' Create a WMEncoder Object.
Dim Encoder As WMEncoder
Set Encoder = New WMEncoder

' Retrieve an IWMEncStatistics object
Dim Statistics As IWMEncStatistics
Set Statistics = Encoder.Statistics

' You must manually configure the encoder engine or load
' a configuration from a file. For an example, see the
' IWMEncFile object.

' Retrieve an IWMEncOutputStats object from the
' IWMEncStatistics object
Dim OutputStats As IWMEncOutputStats
Set OutputStats = Statistics.StreamOutputStats(WMENC_AUDIO, 0, 0)

' You can create a timer control to retrieve the statistics
' (as follows) after you start the encoder engine.
Dim lAvgBitrate As Long
Dim lAvgSampleRate As Long
Dim lByteCount As WMENC_LONGLONG
Dim lCurrentBitRate As Long
Dim lCurrentSampleRate As Long
Dim lDroppedByteCount As WMENC_LONGLONG
Dim lDroppedSampleCount As WMENC_LONGLONG
Dim lExpectedBitRate As Long
Dim lExpectedSampleRate As Long
Dim lSampleCount As WMENC_LONGLONG

lAvgBitrate = OutputStats.AverageBitrate
lAvgSampleRate = OutputStats.AverageSampleRate
lByteCount = OutputStats.ByteCount
lCurrentBitRate = OutputStats.CurrentBitrate
lCurrentSampleRate = OutputStats.CurrentSampleRate
lDroppedByteCount = OutputStats.DroppedByteCount
lDroppedSampleCount = OutputStats.DroppedSampleCount
lExpectedBitRate = OutputStats.ExpectedBitrate
lExpectedSampleRate = OutputStats.ExpectedSampleRate
lSampleCount = OutputStats.SampleCount

See Also

  • IWMEncOutputStats Object


IWMEncPluginInfo Object

The IWMEncPluginInfo object retrieves plug-in registry information. The IWMEncPluginInfo object exposes the following properties and methods.

Property | Description
CLSID | Retrieves the globally unique identifier (GUID) of the plug-in.
Copyright | Retrieves the copyright information assigned to the plug-in by the author.
Count | Retrieves the number of registered plug-ins.
Exclusive | Retrieves a Boolean value indicating whether the plug-in can be used more than once in an encoding session.
Hidden | Retrieves a Boolean value indicating whether the plug-in is hidden from the UI.
InfoURL | Retrieves an optional URL that directs the user to a Web site presenting information about the plug-in.
MediaType | Retrieves the media types supported by the plug-in.
Name | Retrieves the name of the plug-in.
PluginType | Retrieves the plug-in type.
PropertyPage | Retrieves a Boolean value indicating whether the plug-in supports property pages.
Resources | Retrieves a Boolean value indicating whether the plug-in supports resources.
SchemeType | Retrieves the scheme type of the plug-in.
TransformFlags | Retrieves flags indicating whether a transform plug-in is applied to a single stream or to a source group of streams or both

Method | Description
Item | Retrieves the resource corresponding to an index entry in the resource array.

See Also

  • [Visual C++] IWMEncPluginInfo Interface
  • Objects (Visual Basic)


IWMEncPluginInfo.CLSID

The CLSID property retrieves the GUID of the plug-in.

Syntax

BSTR = IWMEncPluginInfo.CLSID

Parameters

This property takes no parameters.

Return Values

When getting the value, this property returns a BSTR containing the GUID of the plug-in.

Remarks

Plug-ins for the encoder must be COM objects. The GUID, or CLSID, is the 128 bit identifier of this object. The CLSID is used by Windows Media Encoder to create an instance of the plug-in object.

Example Code

' Declare objects.
Dim Encoder As WMEncoder
Dim PluginIndex As Integer
Dim ResourceIndex As Integer
Dim Scheme As String
Dim Resource As String
Dim SrcPlugMgr As IWMEncSourcePluginInfoManager
Dim PlugInfo As IWMEncPluginInfo

' Create a WMEncoder object and retrieve an
' IWMEncSourcePluginInfoManager object from it.
Set Encoder = New WMEncoder
Set SrcPlugMgr = Encoder.SourcePluginInfoManager

' Loop through the source plug-ins. Call the Item method on each
' plug-in to retrieve an IWMEncPluginInfo object. Use the
' SchemeType property to retrieve a string containing the scheme
' type of the plug-in. If the scheme type is "DEVICE" and if the
' plug-in supports resources, call the Item method to retrieve a
' string identifying the resource. If the resource indicates that
' the plug-in captures streams from the default video device,
' retrieve registry information about the plug-in.

' To capture streams from an attached device, you must choose a
' specific device plug-in.

Dim sCLSID As String
Dim sCopyright As String
Dim bExclusive As Boolean
Dim bHidden As Boolean
Dim pPropPage As Boolean
Dim sURL As String
Dim enumMediaType As WMENC_SOURCE_TYPE
Dim enumPluginType As WMENC_PLUGIN_TYPE
Dim sName As String

For PluginIndex = 0 To SrcPlugMgr.Count - 1
    Set PlugInfo = SrcPlugMgr.Item(PluginIndex)
    Scheme = PlugInfo.SchemeType
    If Scheme = "DEVICE" Then
        If PlugInfo.Resources = True Then
            For ResourceIndex = 0 To PlugInfo.Count - 1
                Resource = PlugInfo.Item(ResourceIndex)
                If Resource = "Default_Video_Device" Then '

                    ' Retrieve the plug-in GUID.
                    sCLSID = PlugInfo.CLSID

                    ' Retrieve the copyright information.
                    sCopyright = PlugInfo.Copyright

                    ' Determine whether the plug-in can be used
                    ' more than once in a source group.
                    bExclusive = PlugInfo.Exclusive

                    ' Determine whether the plug-in is hidden
                    ' from the UI.
                    bHidden = PlugInfo.Hidden

                    ' Retrieve the URL, if any, of the Web site
                    ' containing information about the plug-in.
                    sURL = PlugInfo.InfoURL

                    ' Retrieve the media types supported by the
                    ' plug-in. This is a bitwise OR of the
                    ' WMENC_SOURCE_TYPE enumeration type.
                    enumMediaType = PlugInfo.MediaType

                    ' Retrieve the name of the plug-in.
                    sName = PlugInfo.Name

                    ' Determine whether the plug-in is a source or
                    ' transform type.
                    enumPluginType = PlugInfo.PluginType

                    ' Determine whether the plug-in supports
                    ' property pages.
                    bPropPage = PlugInfo.PropertyPage
                End If
            Next
        End If
    End If
Next

' Continue configuring the encoder engine.

See Also

  • IWMEncPluginInfo Object


IWMEncPluginInfo.Copyright

The Copyright property retrieves the copyright information assigned to the plug-in by the author.

Syntax

BSTR = IWMEncPluginInfo.Copyright

Parameters

This property takes no parameters.

Return Values

When getting the value, this property returns a BSTR containing the copyright information.

Remarks

The copyright can contain information similar to “Copyright 1999 Company Name. All rights reserved.” The copyright structure member is optional.

Example Code

' Declare objects.
Dim Encoder As WMEncoder
Dim PluginIndex As Integer
Dim ResourceIndex As Integer
Dim Scheme As String
Dim Resource As String
Dim SrcPlugMgr As IWMEncSourcePluginInfoManager
Dim PlugInfo As IWMEncPluginInfo

' Create a WMEncoder object and retrieve an
' IWMEncSourcePluginInfoManager object from it.
Set Encoder = New WMEncoder
Set SrcPlugMgr = Encoder.SourcePluginInfoManager

' Loop through the source plug-ins. Call the Item method on each
' plug-in to retrieve an IWMEncPluginInfo object. Use the
' SchemeType property to retrieve a string containing the scheme
' type of the plug-in. If the scheme type is "DEVICE" and if the
' plug-in supports resources, call the Item method to retrieve a
' string identifying the resource. If the resource indicates that
' the plug-in captures streams from the default video device,
' retrieve registry information about the plug-in.

' To capture streams from an attached device, you must choose a
' specific device plug-in.

Dim sCLSID As String
Dim sCopyright As String
Dim bExclusive As Boolean
Dim bHidden As Boolean
Dim pPropPage As Boolean
Dim sURL As String
Dim enumMediaType As WMENC_SOURCE_TYPE
Dim enumPluginType As WMENC_PLUGIN_TYPE
Dim sName As String

For PluginIndex = 0 To SrcPlugMgr.Count - 1
    Set PlugInfo = SrcPlugMgr.Item(PluginIndex)
    Scheme = PlugInfo.SchemeType
    If Scheme = "DEVICE" Then
        If PlugInfo.Resources = True Then
            For ResourceIndex = 0 To PlugInfo.Count - 1
                Resource = PlugInfo.Item(ResourceIndex)
                If Resource = "Default_Video_Device" Then '

                    ' Retrieve the plug-in GUID.
                    sCLSID = PlugInfo.CLSID

                    ' Retrieve the copyright information.
                    sCopyright = PlugInfo.Copyright

                    ' Determine whether the plug-in can be used
                    ' more than once in a source group.
                    bExclusive = PlugInfo.Exclusive

                    ' Determine whether the plug-in is hidden
                    ' from the UI.
                    bHidden = PlugInfo.Hidden

                    ' Retrieve the URL, if any, of the Web site
                    ' containing information about the plug-in.
                    sURL = PlugInfo.InfoURL

                    ' Retrieve the media types supported by the
                    ' plug-in. This is a bitwise OR of the
                    ' WMENC_SOURCE_TYPE enumeration type.
                    enumMediaType = PlugInfo.MediaType

                    ' Retrieve the name of the plug-in.
                    sName = PlugInfo.Name

                    ' Determine whether the plug-in is a source or
                    ' transform type.
                    enumPluginType = PlugInfo.PluginType

                    ' Determine whether the plug-in supports
                    ' property pages.
                    bPropPage = PlugInfo.PropertyPage
                End If
            Next
        End If
    End If
Next

' Continue configuring the encoder engine.

See Also

  • IWMEncPluginInfo Object


IWMEncPluginInfo.Count

The Count property retrieves the number of resources in the plug-in.

Syntax

Long = IWMEncPluginInfo.Count

Parameters

This property takes no parameters.

Return Values

When getting the value, this property returns a LONG containing the number of resources.

Remarks

If your system has two or more audio capture cards, each card is identified by a resource.

Example Code

' Declare objects.
Dim Encoder As WMEncoder
Dim PluginIndex As Integer
Dim ResourceIndex As Integer
Dim Scheme As String
Dim Resource As String
Dim SrcPlugMgr As IWMEncSourcePluginInfoManager
Dim PlugInfo As IWMEncPluginInfo

' Create a WMEncoder object and retrieve an
' IWMEncSourcePluginInfoManager object from it.
Set Encoder = New WMEncoder
Set SrcPlugMgr = Encoder.SourcePluginInfoManager

' Loop through the source plug-ins. Call the Item method on each
' plug-in to retrieve an IWMEncPluginInfo object. Use the
' SchemeType property to retrieve a string containing the scheme
' type of the plug-in. If the scheme type is "DEVICE" and if the
' plug-in supports resources, call the Item method to retrieve a
' string identifying the resource. If the resource indicates that
' the plug-in captures streams from the default video device,
' retrieve registry information about the plug-in.

' To capture streams from an attached device, you must choose a
' specific device plug-in.

Dim sCLSID As String
Dim sCopyright As String
Dim bExclusive As Boolean
Dim bHidden As Boolean
Dim pPropPage As Boolean
Dim sURL As String
Dim enumMediaType As WMENC_SOURCE_TYPE
Dim enumPluginType As WMENC_PLUGIN_TYPE
Dim sName As String

For PluginIndex = 0 To SrcPlugMgr.Count - 1
    Set PlugInfo = SrcPlugMgr.Item(PluginIndex)
    Scheme = PlugInfo.SchemeType
    If Scheme = "DEVICE" Then
        If PlugInfo.Resources = True Then
            For ResourceIndex = 0 To PlugInfo.Count - 1
                Resource = PlugInfo.Item(ResourceIndex)
                If Resource = "Default_Video_Device" Then '

                    ' Retrieve the plug-in GUID.
                    sCLSID = PlugInfo.CLSID

                    ' Retrieve the copyright information.
                    sCopyright = PlugInfo.Copyright

                    ' Determine whether the plug-in can be used
                    ' more than once in a source group.
                    bExclusive = PlugInfo.Exclusive

                    ' Determine whether the plug-in is hidden
                    ' from the UI.
                    bHidden = PlugInfo.Hidden

                    ' Retrieve the URL, if any, of the Web site
                    ' containing information about the plug-in.
                    sURL = PlugInfo.InfoURL

                    ' Retrieve the media types supported by the
                    ' plug-in. This is a bitwise OR of the
                    ' WMENC_SOURCE_TYPE enumeration type.
                    enumMediaType = PlugInfo.MediaType

                    ' Retrieve the name of the plug-in.
                    sName = PlugInfo.Name

                    ' Determine whether the plug-in is a source or
                    ' transform type.
                    enumPluginType = PlugInfo.PluginType

                    ' Determine whether the plug-in supports
                    ' property pages.
                    bPropPage = PlugInfo.PropertyPage
                End If
            Next
        End If
    End If
Next

' Continue configuring the encoder engine.

See Also

  • IWMEncPluginInfo Object


IWMEncPluginInfo.Exclusive

The Exclusive property retrieves a Boolean indicating whether the plug-in can be used more than once in an encoding session.

Syntax

VARIANT_BOOL = IWMEncPluginInfo.Exclusive

Parameters

This property takes no parameters.

Return Values

When getting the value, this property returns a VARIANT_BOOL.

Remarks

This property is read-only. For some physical devices it may be necessary for Exclusive to return TRUE. By default, it returns FALSE.

Example Code

' Declare objects.
Dim Encoder As WMEncoder
Dim PluginIndex As Integer
Dim ResourceIndex As Integer
Dim Scheme As String
Dim Resource As String
Dim SrcPlugMgr As IWMEncSourcePluginInfoManager
Dim PlugInfo As IWMEncPluginInfo

' Create a WMEncoder object and retrieve an
' IWMEncSourcePluginInfoManager object from it.
Set Encoder = New WMEncoder
Set SrcPlugMgr = Encoder.SourcePluginInfoManager

' Loop through the source plug-ins. Call the Item method on each
' plug-in to retrieve an IWMEncPluginInfo object. Use the
' SchemeType property to retrieve a string containing the scheme
' type of the plug-in. If the scheme type is "DEVICE" and if the
' plug-in supports resources, call the Item method to retrieve a
' string identifying the resource. If the resource indicates that
' the plug-in captures streams from the default video device,
' retrieve registry information about the plug-in.

' To capture streams from an attached device, you must choose a
' specific device plug-in.

Dim sCLSID As String
Dim sCopyright As String
Dim bExclusive As Boolean
Dim bHidden As Boolean
Dim pPropPage As Boolean
Dim sURL As String
Dim enumMediaType As WMENC_SOURCE_TYPE
Dim enumPluginType As WMENC_PLUGIN_TYPE
Dim sName As String

For PluginIndex = 0 To SrcPlugMgr.Count - 1
    Set PlugInfo = SrcPlugMgr.Item(PluginIndex)
    Scheme = PlugInfo.SchemeType
    If Scheme = "DEVICE" Then
        If PlugInfo.Resources = True Then
            For ResourceIndex = 0 To PlugInfo.Count - 1
                Resource = PlugInfo.Item(ResourceIndex)
                If Resource = "Default_Video_Device" Then '

                    ' Retrieve the plug-in GUID.
                    sCLSID = PlugInfo.CLSID

                    ' Retrieve the copyright information.
                    sCopyright = PlugInfo.Copyright

                    ' Determine whether the plug-in can be used
                    ' more than once in a source group.
                    bExclusive = PlugInfo.Exclusive

                    ' Determine whether the plug-in is hidden
                    ' from the UI.
                    bHidden = PlugInfo.Hidden

                    ' Retrieve the URL, if any, of the Web site
                    ' containing information about the plug-in.
                    sURL = PlugInfo.InfoURL

                    ' Retrieve the media types supported by the
                    ' plug-in. This is a bitwise OR of the
                    ' WMENC_SOURCE_TYPE enumeration type.
                    enumMediaType = PlugInfo.MediaType

                    ' Retrieve the name of the plug-in.
                    sName = PlugInfo.Name

                    ' Determine whether the plug-in is a source or
                    ' transform type.
                    enumPluginType = PlugInfo.PluginType

                    ' Determine whether the plug-in supports
                    ' property pages.
                    bPropPage = PlugInfo.PropertyPage
                End If
            Next
        End If
    End If
Next

' Continue configuring the encoder engine.

See Also

  • IWMEncPluginInfo Object


IWMEncPluginInfo.Hidden

The Hidden property retrieves a Boolean value indicating whether the plug-in is hidden from the UI.

Syntax

VARIANT_BOOL = IWMEncPluginInfo.Hidden

Parameters

This property takes no parameters.

Return Values

When getting the value, this property returns a VARIANT_BOOL indicating whether the plug-in is visible in the UI.

Remarks

Use Hidden to hide the plug-in from the user interface if, for instance, you only intend to use the plug-in programmatically. By default, the returned value is FALSE.

Example Code

' Declare objects.
Dim Encoder As WMEncoder
Dim PluginIndex As Integer
Dim ResourceIndex As Integer
Dim Scheme As String
Dim Resource As String
Dim SrcPlugMgr As IWMEncSourcePluginInfoManager
Dim PlugInfo As IWMEncPluginInfo

' Create a WMEncoder object and retrieve an
' IWMEncSourcePluginInfoManager object from it.
Set Encoder = New WMEncoder
Set SrcPlugMgr = Encoder.SourcePluginInfoManager

' Loop through the source plug-ins. Call the Item method on each
' plug-in to retrieve an IWMEncPluginInfo object. Use the
' SchemeType property to retrieve a string containing the scheme
' type of the plug-in. If the scheme type is "DEVICE" and if the
' plug-in supports resources, call the Item method to retrieve a
' string identifying the resource. If the resource indicates that
' the plug-in captures streams from the default video device,
' retrieve registry information about the plug-in.

' To capture streams from an attached device, you must choose a
' specific device plug-in.

Dim sCLSID As String
Dim sCopyright As String
Dim bExclusive As Boolean
Dim bHidden As Boolean
Dim pPropPage As Boolean
Dim sURL As String
Dim enumMediaType As WMENC_SOURCE_TYPE
Dim enumPluginType As WMENC_PLUGIN_TYPE
Dim sName As String

For PluginIndex = 0 To SrcPlugMgr.Count - 1
    Set PlugInfo = SrcPlugMgr.Item(PluginIndex)
    Scheme = PlugInfo.SchemeType
    If Scheme = "DEVICE" Then
        If PlugInfo.Resources = True Then
            For ResourceIndex = 0 To PlugInfo.Count - 1
                Resource = PlugInfo.Item(ResourceIndex)
                If Resource = "Default_Video_Device" Then '

                    ' Retrieve the plug-in GUID.
                    sCLSID = PlugInfo.CLSID

                    ' Retrieve the copyright information.
                    sCopyright = PlugInfo.Copyright

                    ' Determine whether the plug-in can be used
                    ' more than once in a source group.
                    bExclusive = PlugInfo.Exclusive

                    ' Determine whether the plug-in is hidden
                    ' from the UI.
                    bHidden = PlugInfo.Hidden

                    ' Retrieve the URL, if any, of the Web site
                    ' containing information about the plug-in.
                    sURL = PlugInfo.InfoURL

                    ' Retrieve the media types supported by the
                    ' plug-in. This is a bitwise OR of the
                    ' WMENC_SOURCE_TYPE enumeration type.
                    enumMediaType = PlugInfo.MediaType

                    ' Retrieve the name of the plug-in.
                    sName = PlugInfo.Name

                    ' Determine whether the plug-in is a source or
                    ' transform type.
                    enumPluginType = PlugInfo.PluginType

                    ' Determine whether the plug-in supports
                    ' property pages.
                    bPropPage = PlugInfo.PropertyPage
                End If
            Next
        End If
    End If
Next

' Continue configuring the encoder engine.

See Also

  • IWMEncPluginInfo Object


IWMEncPluginInfo.InfoURL

The InfoURL property retrieves an optional URL that directs the user to a web site presenting information about the plug-in.

Syntax

BSTR = IWMEncPluginInfo.InfoURL

Parameters

This property takes no parameters.

Return Values

When getting the value, this property returns a BSTR containing the URL.

Remarks

This property is read-only. An information URL is optional.

Example Code

' Declare objects.
Dim Encoder As WMEncoder
Dim PluginIndex As Integer
Dim ResourceIndex As Integer
Dim Scheme As String
Dim Resource As String
Dim SrcPlugMgr As IWMEncSourcePluginInfoManager
Dim PlugInfo As IWMEncPluginInfo

' Create a WMEncoder object and retrieve an
' IWMEncSourcePluginInfoManager object from it.
Set Encoder = New WMEncoder
Set SrcPlugMgr = Encoder.SourcePluginInfoManager

' Loop through the source plug-ins. Call the Item method on each
' plug-in to retrieve an IWMEncPluginInfo object. Use the
' SchemeType property to retrieve a string containing the scheme
' type of the plug-in. If the scheme type is "DEVICE" and if the
' plug-in supports resources, call the Item method to retrieve a
' string identifying the resource. If the resource indicates that
' the plug-in captures streams from the default video device,
' retrieve registry information about the plug-in.

' To capture streams from an attached device, you must choose a
' specific device plug-in.

Dim sCLSID As String
Dim sCopyright As String
Dim bExclusive As Boolean
Dim bHidden As Boolean
Dim pPropPage As Boolean
Dim sURL As String
Dim enumMediaType As WMENC_SOURCE_TYPE
Dim enumPluginType As WMENC_PLUGIN_TYPE
Dim sName As String

For PluginIndex = 0 To SrcPlugMgr.Count - 1
    Set PlugInfo = SrcPlugMgr.Item(PluginIndex)
    Scheme = PlugInfo.SchemeType
    If Scheme = "DEVICE" Then
        If PlugInfo.Resources = True Then
            For ResourceIndex = 0 To PlugInfo.Count - 1
                Resource = PlugInfo.Item(ResourceIndex)
                If Resource = "Default_Video_Device" Then '

                    ' Retrieve the plug-in GUID.
                    sCLSID = PlugInfo.CLSID

                    ' Retrieve the copyright information.
                    sCopyright = PlugInfo.Copyright

                    ' Determine whether the plug-in can be used
                    ' more than once in a source group.
                    bExclusive = PlugInfo.Exclusive

                    ' Determine whether the plug-in is hidden
                    ' from the UI.
                    bHidden = PlugInfo.Hidden

                    ' Retrieve the URL, if any, of the Web site
                    ' containing information about the plug-in.
                    sURL = PlugInfo.InfoURL

                    ' Retrieve the media types supported by the
                    ' plug-in. This is a bitwise OR of the
                    ' WMENC_SOURCE_TYPE enumeration type.
                    enumMediaType = PlugInfo.MediaType

                    ' Retrieve the name of the plug-in.
                    sName = PlugInfo.Name

                    ' Determine whether the plug-in is a source or
                    ' transform type.
                    enumPluginType = PlugInfo.PluginType

                    ' Determine whether the plug-in supports
                    ' property pages.
                    bPropPage = PlugInfo.PropertyPage
                End If
            Next
        End If
    End If
Next

' Continue configuring the encoder engine.

See Also

  • IWMEncPluginInfo Object


IWMEncPluginInfo.MediaType

The MediaType property retrieves the media types supported by the plug-in.

Syntax

WMENC_SOURCE_TYPE = IWMEncPluginInfo.MediaType

Parameters

This property takes no parameters.

Return Values

When getting the value, this property returns a member of a WMENC_SOURCE_TYPE enumeration type identifying the supported media. This must be a bitwise OR of the following values.

Return code | Number | Meaning
WMENC_AUDIO | 1 | The plug_in supports audio streams.
WMENC_VIDEO | 2 | The plug_in supports video streams.
WMENC_SCRIPT | 4 | The plug_in supports text streams.

Remarks

This property is read-only.

Example Code

' Declare objects.
Dim Encoder As WMEncoder
Dim PluginIndex As Integer
Dim ResourceIndex As Integer
Dim Scheme As String
Dim Resource As String
Dim SrcPlugMgr As IWMEncSourcePluginInfoManager
Dim PlugInfo As IWMEncPluginInfo

' Create a WMEncoder object and retrieve an
' IWMEncSourcePluginInfoManager object from it.
Set Encoder = New WMEncoder
Set SrcPlugMgr = Encoder.SourcePluginInfoManager

' Loop through the source plug-ins. Call the Item method on each
' plug-in to retrieve an IWMEncPluginInfo object. Use the
' SchemeType property to retrieve a string containing the scheme
' type of the plug-in. If the scheme type is "DEVICE" and if the
' plug-in supports resources, call the Item method to retrieve a
' string identifying the resource. If the resource indicates that
' the plug-in captures streams from the default video device,
' retrieve registry information about the plug-in.

' To capture streams from an attached device, you must choose a
' specific device plug-in.

Dim sCLSID As String
Dim sCopyright As String
Dim bExclusive As Boolean
Dim bHidden As Boolean
Dim pPropPage As Boolean
Dim sURL As String
Dim enumMediaType As WMENC_SOURCE_TYPE
Dim enumPluginType As WMENC_PLUGIN_TYPE
Dim sName As String

For PluginIndex = 0 To SrcPlugMgr.Count - 1
    Set PlugInfo = SrcPlugMgr.Item(PluginIndex)
    Scheme = PlugInfo.SchemeType
    If Scheme = "DEVICE" Then
        If PlugInfo.Resources = True Then
            For ResourceIndex = 0 To PlugInfo.Count - 1
                Resource = PlugInfo.Item(ResourceIndex)
                If Resource = "Default_Video_Device" Then '

                    ' Retrieve the plug-in GUID.
                    sCLSID = PlugInfo.CLSID

                    ' Retrieve the copyright information.
                    sCopyright = PlugInfo.Copyright

                    ' Determine whether the plug-in can be used
                    ' more than once in a source group.
                    bExclusive = PlugInfo.Exclusive

                    ' Determine whether the plug-in is hidden
                    ' from the UI.
                    bHidden = PlugInfo.Hidden

                    ' Retrieve the URL, if any, of the Web site
                    ' containing information about the plug-in.
                    sURL = PlugInfo.InfoURL

                    ' Retrieve the media types supported by the
                    ' plug-in. This is a bitwise OR of the
                    ' WMENC_SOURCE_TYPE enumeration type.
                    enumMediaType = PlugInfo.MediaType

                    ' Retrieve the name of the plug-in.
                    sName = PlugInfo.Name

                    ' Determine whether the plug-in is a source or
                    ' transform type.
                    enumPluginType = PlugInfo.PluginType

                    ' Determine whether the plug-in supports
                    ' property pages.
                    bPropPage = PlugInfo.PropertyPage
                End If
            Next
        End If
    End If
Next

' Continue configuring the encoder engine.

See Also

  • IWMEncPluginInfo Object


IWMEncPluginInfo.Name

The Name property retrieves the name of the plug-in.

Syntax

BSTR = IWMEncPluginInfo.Name

Parameters

This property takes no parameters.

Return Values

When getting the value, this property returns a BSTR containing the name.

Remarks

This property is read-only. This method returns the resources associated with the plug-in.

Example Code

' Declare objects.
Dim Encoder As WMEncoder
Dim PluginIndex As Integer
Dim ResourceIndex As Integer
Dim Scheme As String
Dim Resource As String
Dim SrcPlugMgr As IWMEncSourcePluginInfoManager
Dim PlugInfo As IWMEncPluginInfo

' Create a WMEncoder object and retrieve an
' IWMEncSourcePluginInfoManager object from it.
Set Encoder = New WMEncoder
Set SrcPlugMgr = Encoder.SourcePluginInfoManager

' Loop through the source plug-ins. Call the Item method on each
' plug-in to retrieve an IWMEncPluginInfo object. Use the
' SchemeType property to retrieve a string containing the scheme
' type of the plug-in. If the scheme type is "DEVICE" and if the
' plug-in supports resources, call the Item method to retrieve a
' string identifying the resource. If the resource indicates that
' the plug-in captures streams from the default video device,
' retrieve registry information about the plug-in.

' To capture streams from an attached device, you must choose a
' specific device plug-in.

Dim sCLSID As String
Dim sCopyright As String
Dim bExclusive As Boolean
Dim bHidden As Boolean
Dim pPropPage As Boolean
Dim sURL As String
Dim enumMediaType As WMENC_SOURCE_TYPE
Dim enumPluginType As WMENC_PLUGIN_TYPE
Dim sName As String

For PluginIndex = 0 To SrcPlugMgr.Count - 1
    Set PlugInfo = SrcPlugMgr.Item(PluginIndex)
    Scheme = PlugInfo.SchemeType
    If Scheme = "DEVICE" Then
        If PlugInfo.Resources = True Then
            For ResourceIndex = 0 To PlugInfo.Count - 1
                Resource = PlugInfo.Item(ResourceIndex)
                If Resource = "Default_Video_Device" Then '

                    ' Retrieve the plug-in GUID.
                    sCLSID = PlugInfo.CLSID

                    ' Retrieve the copyright information.
                    sCopyright = PlugInfo.Copyright

                    ' Determine whether the plug-in can be used
                    ' more than once in a source group.
                    bExclusive = PlugInfo.Exclusive

                    ' Determine whether the plug-in is hidden
                    ' from the UI.
                    bHidden = PlugInfo.Hidden

                    ' Retrieve the URL, if any, of the Web site
                    ' containing information about the plug-in.
                    sURL = PlugInfo.InfoURL

                    ' Retrieve the media types supported by the
                    ' plug-in. This is a bitwise OR of the
                    ' WMENC_SOURCE_TYPE enumeration type.
                    enumMediaType = PlugInfo.MediaType

                    ' Retrieve the name of the plug-in.
                    sName = PlugInfo.Name

                    ' Determine whether the plug-in is a source or
                    ' transform type.
                    enumPluginType = PlugInfo.PluginType

                    ' Determine whether the plug-in supports
                    ' property pages.
                    bPropPage = PlugInfo.PropertyPage
                End If
            Next
        End If
    End If
Next

' Continue configuring the encoder engine.

See Also

  • IWMEncPluginInfo Object


IWMEncPluginInfo.PluginType

The PluginType property retrieves the plug-in type.

Syntax

WMENC_PLUGIN_TYPE = IWMEncPluginInfo.PluginType

Parameters

This property takes no parameters.

Return Values

When getting the value, this property returns a member of a WMENC_PLUGIN_TYPE enumeration type indicating the type of the plug-in. This must be one of the following values.

Return code | Number | Meaning
WMENC_PLUGIN_SOURCE | 1 | The plug-in is a source type that captures multimedia content.
WMENC_PLUGIN_TRANSFORM | 2 | The plug-in is a transform type that modifies multimedia streams.

Remarks

This property is read-only.

Example Code

' Declare objects.
Dim Encoder As WMEncoder
Dim PluginIndex As Integer
Dim ResourceIndex As Integer
Dim Scheme As String
Dim Resource As String
Dim SrcPlugMgr As IWMEncSourcePluginInfoManager
Dim PlugInfo As IWMEncPluginInfo

' Create a WMEncoder object and retrieve an
' IWMEncSourcePluginInfoManager object from it.
Set Encoder = New WMEncoder
Set SrcPlugMgr = Encoder.SourcePluginInfoManager

' Loop through the source plug-ins. Call the Item method on each
' plug-in to retrieve an IWMEncPluginInfo object. Use the
' SchemeType property to retrieve a string containing the scheme
' type of the plug-in. If the scheme type is "DEVICE" and if the
' plug-in supports resources, call the Item method to retrieve a
' string identifying the resource. If the resource indicates that
' the plug-in captures streams from the default video device,
' retrieve registry information about the plug-in.

' To capture streams from an attached device, you must choose a
' specific device plug-in.

Dim sCLSID As String
Dim sCopyright As String
Dim bExclusive As Boolean
Dim bHidden As Boolean
Dim pPropPage As Boolean
Dim sURL As String
Dim enumMediaType As WMENC_SOURCE_TYPE
Dim enumPluginType As WMENC_PLUGIN_TYPE
Dim sName As String

For PluginIndex = 0 To SrcPlugMgr.Count - 1
    Set PlugInfo = SrcPlugMgr.Item(PluginIndex)
    Scheme = PlugInfo.SchemeType
    If Scheme = "DEVICE" Then
        If PlugInfo.Resources = True Then
            For ResourceIndex = 0 To PlugInfo.Count - 1
                Resource = PlugInfo.Item(ResourceIndex)
                If Resource = "Default_Video_Device" Then '

                    ' Retrieve the plug-in GUID.
                    sCLSID = PlugInfo.CLSID

                    ' Retrieve the copyright information.
                    sCopyright = PlugInfo.Copyright

                    ' Determine whether the plug-in can be used
                    ' more than once in a source group.
                    bExclusive = PlugInfo.Exclusive

                    ' Determine whether the plug-in is hidden
                    ' from the UI.
                    bHidden = PlugInfo.Hidden

                    ' Retrieve the URL, if any, of the Web site
                    ' containing information about the plug-in.
                    sURL = PlugInfo.InfoURL

                    ' Retrieve the media types supported by the
                    ' plug-in. This is a bitwise OR of the
                    ' WMENC_SOURCE_TYPE enumeration type.
                    enumMediaType = PlugInfo.MediaType

                    ' Retrieve the name of the plug-in.
                    sName = PlugInfo.Name

                    ' Determine whether the plug-in is a source or
                    ' transform type.
                    enumPluginType = PlugInfo.PluginType

                    ' Determine whether the plug-in supports
                    ' property pages.
                    bPropPage = PlugInfo.PropertyPage
                End If
            Next
        End If
    End If
Next

' Continue configuring the encoder engine.

See Also

  • IWMEncPluginInfo Object


IWMEncPluginInfo.PropertyPage

The PropertyPage property retrieves a Boolean value indicating whether the plug-in supports property pages.

Syntax

VARIANT_BOOL = IWMEncPluginInfo.PropertyPage

Parameters

This property takes no parameters.

Return Values

When getting the value, this property returns a VARIANT_BOOL indicating whether the plug-in supports property pages.

Remarks

This property is read-only and optional. Both source and transform plug-ins can have associated property pages. The Windows Media Encoder user interface creates a dialog box to host the property page. Parameters modified on the property page are aplied to the plug-in.

Example Code

' Declare objects.
Dim Encoder As WMEncoder
Dim PluginIndex As Integer
Dim ResourceIndex As Integer
Dim Scheme As String
Dim Resource As String
Dim SrcPlugMgr As IWMEncSourcePluginInfoManager
Dim PlugInfo As IWMEncPluginInfo

' Create a WMEncoder object and retrieve an
' IWMEncSourcePluginInfoManager object from it.
Set Encoder = New WMEncoder
Set SrcPlugMgr = Encoder.SourcePluginInfoManager

' Loop through the source plug-ins. Call the Item method on each
' plug-in to retrieve an IWMEncPluginInfo object. Use the
' SchemeType property to retrieve a string containing the scheme
' type of the plug-in. If the scheme type is "DEVICE" and if the
' plug-in supports resources, call the Item method to retrieve a
' string identifying the resource. If the resource indicates that
' the plug-in captures streams from the default video device,
' retrieve registry information about the plug-in.

' To capture streams from an attached device, you must choose a
' specific device plug-in.

Dim sCLSID As String
Dim sCopyright As String
Dim bExclusive As Boolean
Dim bHidden As Boolean
Dim pPropPage As Boolean
Dim sURL As String
Dim enumMediaType As WMENC_SOURCE_TYPE
Dim enumPluginType As WMENC_PLUGIN_TYPE
Dim sName As String

For PluginIndex = 0 To SrcPlugMgr.Count - 1
    Set PlugInfo = SrcPlugMgr.Item(PluginIndex)
    Scheme = PlugInfo.SchemeType
    If Scheme = "DEVICE" Then
        If PlugInfo.Resources = True Then
            For ResourceIndex = 0 To PlugInfo.Count - 1
                Resource = PlugInfo.Item(ResourceIndex)
                If Resource = "Default_Video_Device" Then '

                    ' Retrieve the plug-in GUID.
                    sCLSID = PlugInfo.CLSID

                    ' Retrieve the copyright information.
                    sCopyright = PlugInfo.Copyright

                    ' Determine whether the plug-in can be used
                    ' more than once in a source group.
                    bExclusive = PlugInfo.Exclusive

                    ' Determine whether the plug-in is hidden
                    ' from the UI.
                    bHidden = PlugInfo.Hidden

                    ' Retrieve the URL, if any, of the Web site
                    ' containing information about the plug-in.
                    sURL = PlugInfo.InfoURL

                    ' Retrieve the media types supported by the
                    ' plug-in. This is a bitwise OR of the
                    ' WMENC_SOURCE_TYPE enumeration type.
                    enumMediaType = PlugInfo.MediaType

                    ' Retrieve the name of the plug-in.
                    sName = PlugInfo.Name

                    ' Determine whether the plug-in is a source or
                    ' transform type.
                    enumPluginType = PlugInfo.PluginType

                    ' Determine whether the plug-in supports
                    ' property pages.
                    bPropPage = PlugInfo.PropertyPage
                End If
            Next
        End If
    End If
Next

' Continue configuring the encoder engine.

See Also

  • IWMEncPluginInfo Object


IWMEncPluginInfo.Resources

The Resources property retrieves a Boolean value indicating whether the plug-in supports resources.

Syntax

VARIANT_BOOL = IWMEncPluginInfo.Resources

Parameters

This property takes no parameters.

Return Values

When getting the value, this property returns a VARIANT_BOOL indicating whether the plug-in supports resources.

Remarks

Resources are the physical devices that provide a source of content. The array of resources used by the plug-in, if present, must be defined as part of the plug-in. The encoder appends each resource to the scheme type to create a string used by Windows Media Encoder to identify the plug-in. In the following example, Device is the scheme type and Card1 and Card2 are resources.

  • Device://Card1
  • Device://Card2

Example Code

' Declare objects.
Dim Encoder As WMEncoder
Dim PluginIndex As Integer
Dim ResourceIndex As Integer
Dim Scheme As String
Dim Resource As String
Dim SrcPlugMgr As IWMEncSourcePluginInfoManager
Dim PlugInfo As IWMEncPluginInfo

' Create a WMEncoder object and retrieve an
' IWMEncSourcePluginInfoManager object from it.
Set Encoder = New WMEncoder
Set SrcPlugMgr = Encoder.SourcePluginInfoManager

' Loop through the source plug-ins. Call the Item method on each
' plug-in to retrieve an IWMEncPluginInfo object. Use the
' SchemeType property to retrieve a string containing the scheme
' type of the plug-in. If the scheme type is "DEVICE" and if the
' plug-in supports resources, call the Item method to retrieve a
' string identifying the resource. If the resource indicates that
' the plug-in captures streams from the default video device,
' retrieve registry information about the plug-in.

' To capture streams from an attached device, you must choose a
' specific device plug-in.

Dim sCLSID As String
Dim sCopyright As String
Dim bExclusive As Boolean
Dim bHidden As Boolean
Dim pPropPage As Boolean
Dim sURL As String
Dim enumMediaType As WMENC_SOURCE_TYPE
Dim enumPluginType As WMENC_PLUGIN_TYPE
Dim sName As String

For PluginIndex = 0 To SrcPlugMgr.Count - 1
    Set PlugInfo = SrcPlugMgr.Item(PluginIndex)
    Scheme = PlugInfo.SchemeType
    If Scheme = "DEVICE" Then
        If PlugInfo.Resources = True Then
            For ResourceIndex = 0 To PlugInfo.Count - 1
                Resource = PlugInfo.Item(ResourceIndex)
                If Resource = "Default_Video_Device" Then '

                    ' Retrieve the plug-in GUID.
                    sCLSID = PlugInfo.CLSID

                    ' Retrieve the copyright information.
                    sCopyright = PlugInfo.Copyright

                    ' Determine whether the plug-in can be used
                    ' more than once in a source group.
                    bExclusive = PlugInfo.Exclusive

                    ' Determine whether the plug-in is hidden
                    ' from the UI.
                    bHidden = PlugInfo.Hidden

                    ' Retrieve the URL, if any, of the Web site
                    ' containing information about the plug-in.
                    sURL = PlugInfo.InfoURL

                    ' Retrieve the media types supported by the
                    ' plug-in. This is a bitwise OR of the
                    ' WMENC_SOURCE_TYPE enumeration type.
                    enumMediaType = PlugInfo.MediaType

                    ' Retrieve the name of the plug-in.
                    sName = PlugInfo.Name

                    ' Determine whether the plug-in is a source or
                    ' transform type.
                    enumPluginType = PlugInfo.PluginType

                    ' Determine whether the plug-in supports
                    ' property pages.
                    bPropPage = PlugInfo.PropertyPage
                End If
            Next
        End If
    End If
Next

' Continue configuring the encoder engine.

See Also

  • IWMEncPluginInfo Object


IWMEncPluginInfo.SchemeType

The SchemeType property retrieves the scheme type of the plug-in.

Syntax

BSTR = IWMEncPluginInfo.SchemeType

Parameters

This property takes no parameters.

Return Values

When getting the value, this property returns a BSTR containing the scheme type.

Remarks

The scheme type occupies the root position of the registration information structure and broadly categorizes the plug-in. For instance, in the string Device://Card1, Device:// is the scheme type. The following table lists the possible scheme types available in Windows Media Encoder.

Scheme type | Description
Device | Identifies a source plug-in that enables stream capture from a device attached to a computer.
File | Identifies a source plug-in that enables stream capture from a file.
UserScript | Identifies a source plug-in that enables transmission of a script to the encoder engine.
ScreenCap | Identifies a source plug-in that enables screen capture.
TCGroupTransformPlugin | Identifies a transform plug-in that enables time compression.

Example Code

' Declare objects.
Dim Encoder As WMEncoder
Dim PluginIndex As Integer
Dim ResourceIndex As Integer
Dim Scheme As String
Dim Resource As String
Dim SrcPlugMgr As IWMEncSourcePluginInfoManager
Dim PlugInfo As IWMEncPluginInfo

' Create a WMEncoder object and retrieve an
' IWMEncSourcePluginInfoManager object from it.
Set Encoder = New WMEncoder
Set SrcPlugMgr = Encoder.SourcePluginInfoManager

' Loop through the source plug-ins. Call the Item method on each
' plug-in to retrieve an IWMEncPluginInfo object. Use the
' SchemeType property to retrieve a string containing the scheme
' type of the plug-in. If the scheme type is "DEVICE" and if the
' plug-in supports resources, call the Item method to retrieve a
' string identifying the resource. If the resource indicates that
' the plug-in captures streams from the default video device,
' retrieve registry information about the plug-in.

' To capture streams from an attached device, you must choose a
' specific device plug-in.

Dim sCLSID As String
Dim sCopyright As String
Dim bExclusive As Boolean
Dim bHidden As Boolean
Dim pPropPage As Boolean
Dim sURL As String
Dim enumMediaType As WMENC_SOURCE_TYPE
Dim enumPluginType As WMENC_PLUGIN_TYPE
Dim sName As String

For PluginIndex = 0 To SrcPlugMgr.Count - 1
    Set PlugInfo = SrcPlugMgr.Item(PluginIndex)
    Scheme = PlugInfo.SchemeType
    If Scheme = "DEVICE" Then
        If PlugInfo.Resources = True Then
            For ResourceIndex = 0 To PlugInfo.Count - 1
                Resource = PlugInfo.Item(ResourceIndex)
                If Resource = "Default_Video_Device" Then '

                    ' Retrieve the plug-in GUID.
                    sCLSID = PlugInfo.CLSID

                    ' Retrieve the copyright information.
                    sCopyright = PlugInfo.Copyright

                    ' Determine whether the plug-in can be used
                    ' more than once in a source group.
                    bExclusive = PlugInfo.Exclusive

                    ' Determine whether the plug-in is hidden
                    ' from the UI.
                    bHidden = PlugInfo.Hidden

                    ' Retrieve the URL, if any, of the Web site
                    ' containing information about the plug-in.
                    sURL = PlugInfo.InfoURL

                    ' Retrieve the media types supported by the
                    ' plug-in. This is a bitwise OR of the
                    ' WMENC_SOURCE_TYPE enumeration type.
                    enumMediaType = PlugInfo.MediaType

                    ' Retrieve the name of the plug-in.
                    sName = PlugInfo.Name

                    ' Determine whether the plug-in is a source or
                    ' transform type.
                    enumPluginType = PlugInfo.PluginType

                    ' Determine whether the plug-in supports
                    ' property pages.
                    bPropPage = PlugInfo.PropertyPage
                End If
            Next
        End If
    End If
Next

' Continue configuring the encoder engine.

See Also

  • IWMEncPluginInfo Object


IWMEncPluginInfo.TransformFlags

The TransformFlags property retrieves flags indicating whether a transform plug-in is applied to a single stream or to a source group of streams or both.

Syntax

Short = IWMEncPluginInfo.TransformFlags

Parameters

This property takes no parameters.

Return Values

When getting the value, this property returns a SHORT containing the transform plug-in flags.

Remarks

Stream level plug-ins are applied only to a specific stream. Global transform plug-ins are applied to all streams in the active source group.

Example Code

' Declare objects.
Dim Encoder As WMEncoder
Dim PluginIndex As Integer
Dim ResourceIndex As Integer
Dim Scheme As String
Dim Resource As String
Dim SrcPlugMgr As IWMEncSourcePluginInfoManager
Dim PlugInfo As IWMEncPluginInfo

' Create a WMEncoder object and retrieve an
' IWMEncSourcePluginInfoManager object from it.
Set Encoder = New WMEncoder
Set SrcPlugMgr = Encoder.SourcePluginInfoManager

' Loop through the source plug-ins. Call the Item method on each
' plug-in to retrieve an IWMEncPluginInfo object. Use the
' SchemeType property to retrieve a string containing the scheme
' type of the plug-in. If the scheme type is "DEVICE" and if the
' plug-in supports resources, call the Item method to retrieve a
' string identifying the resource. If the resource indicates that
' the plug-in captures streams from the default video device,
' retrieve registry information about the plug-in.

' To capture streams from an attached device, you must choose a
' specific device plug-in.

Dim sCLSID As String
Dim sCopyright As String
Dim bExclusive As Boolean
Dim bHidden As Boolean
Dim pPropPage As Boolean
Dim sURL As String
Dim enumMediaType As WMENC_SOURCE_TYPE
Dim enumPluginType As WMENC_PLUGIN_TYPE
Dim sName As String

For PluginIndex = 0 To SrcPlugMgr.Count - 1
    Set PlugInfo = SrcPlugMgr.Item(PluginIndex)
    Scheme = PlugInfo.SchemeType
    If Scheme = "DEVICE" Then
        If PlugInfo.Resources = True Then
            For ResourceIndex = 0 To PlugInfo.Count - 1
                Resource = PlugInfo.Item(ResourceIndex)
                If Resource = "Default_Video_Device" Then '

                    ' Retrieve the plug-in GUID.
                    sCLSID = PlugInfo.CLSID

                    ' Retrieve the copyright information.
                    sCopyright = PlugInfo.Copyright

                    ' Determine whether the plug-in can be used
                    ' more than once in a source group.
                    bExclusive = PlugInfo.Exclusive

                    ' Determine whether the plug-in is hidden
                    ' from the UI.
                    bHidden = PlugInfo.Hidden

                    ' Retrieve the URL, if any, of the Web site
                    ' containing information about the plug-in.
                    sURL = PlugInfo.InfoURL

                    ' Retrieve the media types supported by the
                    ' plug-in. This is a bitwise OR of the
                    ' WMENC_SOURCE_TYPE enumeration type.
                    enumMediaType = PlugInfo.MediaType

                    ' Retrieve the name of the plug-in.
                    sName = PlugInfo.Name

                    ' Determine whether the plug-in is a source or
                    ' transform type.
                    enumPluginType = PlugInfo.PluginType

                    ' Determine whether the plug-in supports
                    ' property pages.
                    bPropPage = PlugInfo.PropertyPage
                End If
            Next
        End If
    End If
Next

' Continue configuring the encoder engine.

See Also

  • IWMEncPluginInfo Object


IWMEncPluginInfo.Item

The Item method retrieves the resource corresponding to an index entry in the resource array.

Syntax

BSTR = IWMEncPluginInfo.Item(iIndex)

Parameters

iIndex

[in] SHORT containing an index into the resource array.

Return Values

This method returns a BSTR containing the resource specified by iIndex.

Remarks

Resources are the physical devices that provide a source of content. The array of resources used by the plug-in, if present, must be defined as part of the plug-in. The encoder appends each resource to the scheme type to create a string used by Windows Media Encoder to identify the plug-in. In the following example, Device is the scheme type and Card1 and Card2 are resources.

  • Device://Card1
  • Device://Card2

Example Code

' Declare objects.
Dim Encoder As WMEncoder
Dim PluginIndex As Integer
Dim ResourceIndex As Integer
Dim Scheme As String
Dim Resource As String
Dim SrcPlugMgr As IWMEncSourcePluginInfoManager
Dim PlugInfo As IWMEncPluginInfo

' Create a WMEncoder object and retrieve an
' IWMEncSourcePluginInfoManager object from it.
Set Encoder = New WMEncoder
Set SrcPlugMgr = Encoder.SourcePluginInfoManager

' Loop through the source plug-ins. Call the Item method on each
' plug-in to retrieve an IWMEncPluginInfo object. Use the
' SchemeType property to retrieve a string containing the scheme
' type of the plug-in. If the scheme type is "DEVICE" and if the
' plug-in supports resources, call the Item method to retrieve a
' string identifying the resource. If the resource indicates that
' the plug-in captures streams from the default video device,
' retrieve registry information about the plug-in.

' To capture streams from an attached device, you must choose a
' specific device plug-in.

Dim sCLSID As String
Dim sCopyright As String
Dim bExclusive As Boolean
Dim bHidden As Boolean
Dim pPropPage As Boolean
Dim sURL As String
Dim enumMediaType As WMENC_SOURCE_TYPE
Dim enumPluginType As WMENC_PLUGIN_TYPE
Dim sName As String

For PluginIndex = 0 To SrcPlugMgr.Count - 1
    Set PlugInfo = SrcPlugMgr.Item(PluginIndex)
    Scheme = PlugInfo.SchemeType
    If Scheme = "DEVICE" Then
        If PlugInfo.Resources = True Then
            For ResourceIndex = 0 To PlugInfo.Count - 1
                Resource = PlugInfo.Item(ResourceIndex)
                If Resource = "Default_Video_Device" Then '

                    ' Retrieve the plug-in GUID.
                    sCLSID = PlugInfo.CLSID

                    ' Retrieve the copyright information.
                    sCopyright = PlugInfo.Copyright

                    ' Determine whether the plug-in can be used
                    ' more than once in a source group.
                    bExclusive = PlugInfo.Exclusive

                    ' Determine whether the plug-in is hidden
                    ' from the UI.
                    bHidden = PlugInfo.Hidden

                    ' Retrieve the URL, if any, of the Web site
                    ' containing information about the plug-in.
                    sURL = PlugInfo.InfoURL

                    ' Retrieve the media types supported by the
                    ' plug-in. This is a bitwise OR of the
                    ' WMENC_SOURCE_TYPE enumeration type.
                    enumMediaType = PlugInfo.MediaType

                    ' Retrieve the name of the plug-in.
                    sName = PlugInfo.Name

                    ' Determine whether the plug-in is a source or
                    ' transform type.
                    enumPluginType = PlugInfo.PluginType

                    ' Determine whether the plug-in supports
                    ' property pages.
                    bPropPage = PlugInfo.PropertyPage
                End If
            Next
        End If
    End If
Next

' Continue configuring the encoder engine.

See Also

  • IWMEncPluginInfo Object


IWMEncPostViewCollection Object

The IWMEncPostViewCollection object can be used to specify which video stream in a multiple-bit-rate set of output streams will be previewed.

Note You must use C++ to display preview and postview objects. For more information, see the Previewing and Postviewing section in the Programming Guide.

The IWMEncPostViewCollection object exposes the following properties and methods.

Property | Description
ViewBandwidth | Specifies and retrieves the bit rate of the preview video stream.

See Also

  • [Visual C++] IWMEncDataView Interface
  • [Visual C++] IWMEncPostViewCollection Interface
  • IWMEncSource Object
  • Objects (Visual Basic)
  • Previewing and Postviewing
  • Programming Guide


IWMEncPostViewCollection.ViewBandwidth

The ViewBandwidth property specifies and retrieves the bit rate of the preview video stream.

Syntax

IWMEncPostViewCollection.ViewBandwidth = Long
Long = IWMEncPostViewCollection.ViewBandwidth

Parameters

This property takes no parameters.

Return Values

When getting the value, this property returns a Long.

Remarks

If the encoder engine produces multiple-bit-rate streams from a video input stream, you can choose which stream to preview by using the ViewBandwidth property. Set lBandwidth equal to zero to select no video stream for the preview. You can also switch between streams while the encoder engine is running. You must use either the Profile Manager or the Windows Media Format SDK to determine which profiles support multiple-bit-rate streams.

You must create a WMEncPreview object before calling the ViewBandWidth property. However, because the WMEncPreview object and the IWMEncDataView interface it supports are not Automation-compliant, you cannot create the preview object by using Visual Basic. For more information, see the Previewing and Postviewing section in the Programming Guide.

See Also

  • [Visual C++] IWMEncDataView Interface
  • [Visual C++] IWMEncPostViewCollection Interface
  • IWMEncPostViewCollection Object
  • Previewing and Postviewing
  • Programming Guide
  • Running the Profile Manager


IWMEncProfile Object

The IWMEncProfile object is used to retrieve the name, description and media types for a specific profile object. Windows Media Encoder compresses input streams according to a profile tailored to both the content being broadcast and the expected bandwidth of the client computer. Multiple profiles can exist during an encoding session, but only one can be applied to a source group at any time.

Profiles identify the media type of the encoded output stream, the target audience bandwidth, and whether the output stream can be encoded at multiple bit rates. Only one profile can be associated with a specific source group, and only one source group can be encoded at a time. System-defined profiles cannot be changed or removed, but user-defined profiles can be added. To edit a profile, you must use either the Profile Manager or the Windows Media Format SDK. You can use the IWMEncProfileManager object to create the Profile Manager dialog boxes that edit and list profiles. The IWMEncProfile object exposes the following properties.

Property | Description
Description | Retrieves a description of a profile.
MaxPacketSize | Specifies and retrieves the maximum size, in bytes, of the Windows Media data units generated during encoding.
MediaCount | Retrieves the number of audio, video and script streams supported by a profile.
MultipleBitrate | Retrieves a Boolean value indicating whether the profile supports multiple bit rate encoded output.
Name | Retrieves the name of the profile.

See Also

  • [Visual C++] IWMEncProfile Interface
  • IWMEncProfileManager Object
  • Objects (Visual Basic)


IWMEncProfile.Description

The Description property retrieves a description of the profile.

Syntax

BSTR = IWMEncProfile.Description

Parameters

This property takes no parameters.

Return Values

When getting the value, this property returns a BSTR containing a description of the profile.

Remarks

Descriptive information can only be supplied when a profile is created. Use the IWMEncProfileCollection interface to acquire a specific profile.

Example Code

' Create a WMEncoder object.
Dim Encoder As WMEncoder
Set Encoder = New WMEncoder

' Declare objects and variables.
Dim SrcGrpColl As IWMEncSourceGroupCollection
Dim SrcGrp As IWMEncSourceGroup
Dim AudSrc As IWMEncSource
Dim VidSrc As IWMEncVideoSource
Dim ProColl As IWMEncProfileCollection
Dim Pro As IWMEncProfile
Dim i As Integer

' Create an IWMEncSourceGroupCollection object.
Set SrcGrpColl = Encoder.SourceGroupCollection

' Create an IWMEncSourceGroup object.
Set SrcGrp = SrcGrpColl.Add("SG_1")

' Create a video and an audio source object.
Set AudSrc = SrcGrp.AddSource(WMENC_AUDIO)
Set VidSrc = SrcGrp.AddSource(WMENC_VIDEO)

' Specify the .avi source file.
AudSrc.SetInput "C:\filename.avi"
VidSrc.SetInput "C:\filename.avi"

' Loop through the collection of system profiles to set
' a specific profile into the source group object.
Dim sProDesc As String
Dim lMaxPacketSz As Long
Dim iMediaCount As Integer
Dim bMultiBitRate As Boolean

Set ProColl = Encoder.ProfileCollection
For i = 0 To ProColl.Count - 1
    Set Pro = ProColl.Item(i)
    If Pro.Name = "profile_name" Then
        SrcGrp.Profile = Pro
        sProDesc = Pro.Description
        lMaxPacketSize = Pro.MaxPacketSize
        iMediaCount = Pro.MediaCount(WMENC_VIDEO)
        bMultiBitRate = Pro.MultipleBitrate

        Exit For
    End If
Next

See Also

  • IWMEncProfile Object
  • IWMEncProfileCollection Object
  • IWMEncSource Object
  • IWMEncSourceGroup Object
  • IWMEncSourceGroupCollection Object


IWMEncProfile.MaxPacketSize

The MaxPacketSize property specifies and retrieves the maximum size, in bytes, of the Windows Media data units generated during encoding.

Syntax

IWMEncProfile.MaxPacketSize = Long
Long = IWMEncProfile.MaxPacketSize

Parameters

This property takes no parameters.

Return Values

When getting the value, this property returns a Long containing the maximum packet size, in bytes.

If this property fails, it returns an error number.

Number | Meaning
0xC00D0011 | This method cannot be called if the encoder engine is running.
0xC00D1B75L | The packet size must be either 0, or a number between 100 and 65,535.

Remarks

The MaxPacketSize property controls the size of the UDP datagrams streamed by the encoder engine. This value can be either zero or a number between 100 and 65,535 (in bytes). If the value is zero, the encoder engine automatically generates packets that are no larger than 16,000 bytes. If the profile does not support uncompressed streams, the default value is zero. If the profile supports uncompressed streams the default value is 65,535. The maximum packet size does not include the networking packet header or the Windows Media packet header.

Example Code

' Create a WMEncoder object.
Dim Encoder As WMEncoder
Set Encoder = New WMEncoder

' Declare objects and variables.
Dim SrcGrpColl As IWMEncSourceGroupCollection
Dim SrcGrp As IWMEncSourceGroup
Dim AudSrc As IWMEncSource
Dim VidSrc As IWMEncVideoSource
Dim ProColl As IWMEncProfileCollection
Dim Pro As IWMEncProfile
Dim i As Integer

' Create an IWMEncSourceGroupCollection object.
Set SrcGrpColl = Encoder.SourceGroupCollection

' Create an IWMEncSourceGroup object.
Set SrcGrp = SrcGrpColl.Add("SG_1")

' Create a video and an audio source object.
Set AudSrc = SrcGrp.AddSource(WMENC_AUDIO)
Set VidSrc = SrcGrp.AddSource(WMENC_VIDEO)

' Specify the .avi source file.
AudSrc.SetInput "C:\filename.avi"
VidSrc.SetInput "C:\filename.avi"

' Loop through the collection of system profiles to set
' a specific profile into the source group object.
Dim sProDesc As String
Dim lMaxPacketSz As Long
Dim iMediaCount As Integer
Dim bMultiBitRate As Boolean

Set ProColl = Encoder.ProfileCollection
For i = 0 To ProColl.Count - 1
    Set Pro = ProColl.Item(i)
    If Pro.Name = "profile_name" Then
        SrcGrp.Profile = Pro
        sProDesc = Pro.Description
        lMaxPacketSize = Pro.MaxPacketSize
        iMediaCount = Pro.MediaCount(WMENC_VIDEO)
        bMultiBitRate = Pro.MultipleBitrate

        Exit For
    End If
Next

See Also

  • IWMEncProfile Object
  • IWMEncProfileCollection Object
  • IWMEncSource Object
  • IWMEncSourceGroup Object
  • IWMEncSourceGroupCollection Object


IWMEncProfile.MediaCount

The MediaCount property retrieves the number of audio, video and script streams supported by a profile.

Syntax

Short = IWMEncProfile.MediaContent ( enumType )

Parameters

enumType

[in] Member of a WMENC_SOURCE_TYPE enumeration type identifying the media stream type. This must be a bitwise OR of the following values.

Return code | Number | Meaning
WMENC_AUDIO | 1 | Identifies an audio stream.
WMENC_VIDEO | 2 | Identifies a video stream.
WMENC_SCRIPT | 4 | Identifies a text stream.

Return Values

When getting the value, this property returns a SHORT containing the number of each media type the profile can support.

Remarks

This property is read-only.

Example Code

' Create a WMEncoder object.
Dim Encoder As WMEncoder
Set Encoder = New WMEncoder

' Declare objects and variables.
Dim SrcGrpColl As IWMEncSourceGroupCollection
Dim SrcGrp As IWMEncSourceGroup
Dim AudSrc As IWMEncSource
Dim VidSrc As IWMEncVideoSource
Dim ProColl As IWMEncProfileCollection
Dim Pro As IWMEncProfile
Dim i As Integer

' Create an IWMEncSourceGroupCollection object.
Set SrcGrpColl = Encoder.SourceGroupCollection

' Create an IWMEncSourceGroup object.
Set SrcGrp = SrcGrpColl.Add("SG_1")

' Create a video and an audio source object.
Set AudSrc = SrcGrp.AddSource(WMENC_AUDIO)
Set VidSrc = SrcGrp.AddSource(WMENC_VIDEO)

' Specify the .avi source file.
AudSrc.SetInput "C:\filename.avi"
VidSrc.SetInput "C:\filename.avi"

' Loop through the collection of system profiles to set
' a specific profile into the source group object.
Dim sProDesc As String
Dim lMaxPacketSz As Long
Dim iMediaCount As Integer
Dim bMultiBitRate As Boolean

Set ProColl = Encoder.ProfileCollection
For i = 0 To ProColl.Count - 1
    Set Pro = ProColl.Item(i)
    If Pro.Name = "profile_name" Then
        SrcGrp.Profile = Pro
        sProDesc = Pro.Description
        lMaxPacketSize = Pro.MaxPacketSize
        iMediaCount = Pro.MediaCount(WMENC_VIDEO)
        bMultiBitRate = Pro.MultipleBitrate

        Exit For
    End If
Next

See Also

  • IWMEncProfile Object
  • IWMEncProfileCollection Object
  • IWMEncSource Object
  • IWMEncSourceGroup Object
  • IWMEncSourceGroupCollection Object


IWMEncProfile.MultipleBitrate

The MultipleBitrate property retrieves a Boolean value indicating whether the profile supports multiple bit rate encoded output.

Syntax

VARIANT_BOOL = IWMEncProfile.MultipleBitrate

Parameters

This property takes no parameters.

Return Values

When getting the value, this property returns a VARIANT_BOOL indicating whether the profile supports multiple bit rate encoded output.

Example Code

' Create a WMEncoder object.
Dim Encoder As WMEncoder
Set Encoder = New WMEncoder

' Declare objects and variables.
Dim SrcGrpColl As IWMEncSourceGroupCollection
Dim SrcGrp As IWMEncSourceGroup
Dim AudSrc As IWMEncSource
Dim VidSrc As IWMEncVideoSource
Dim ProColl As IWMEncProfileCollection
Dim Pro As IWMEncProfile
Dim i As Integer

' Create an IWMEncSourceGroupCollection object.
Set SrcGrpColl = Encoder.SourceGroupCollection

' Create an IWMEncSourceGroup object.
Set SrcGrp = SrcGrpColl.Add("SG_1")

' Create a video and an audio source object.
Set AudSrc = SrcGrp.AddSource(WMENC_AUDIO)
Set VidSrc = SrcGrp.AddSource(WMENC_VIDEO)

' Specify the .avi source file.
AudSrc.SetInput "C:\filename.avi"
VidSrc.SetInput "C:\filename.avi"

' Loop through the collection of system profiles to set
' a specific profile into the source group object.
Dim sProDesc As String
Dim lMaxPacketSz As Long
Dim iMediaCount As Integer
Dim bMultiBitRate As Boolean

Set ProColl = Encoder.ProfileCollection
For i = 0 To ProColl.Count - 1
    Set Pro = ProColl.Item(i)
    If Pro.Name = "profile_name" Then
        SrcGrp.Profile = Pro
        sProDesc = Pro.Description
        lMaxPacketSize = Pro.MaxPacketSize
        iMediaCount = Pro.MediaCount(WMENC_VIDEO)
        bMultiBitRate = Pro.MultipleBitrate

        Exit For
    End If
Next

See Also

  • IWMEncProfile Object
  • IWMEncProfileCollection Object
  • IWMEncSource Object
  • IWMEncSourceGroup Object
  • IWMEncSourceGroupCollection Object


IWMEncProfile.Name

The Name property retrieves the name of a profile.

Syntax

BSTR = IWMEncProfile.Name

Parameters

This property takes no parameters.

Return Values

When getting the value, this property returns a BSTR containing the name of the profile.

Remarks

This property is read-only. Use the name to retrieve a given profile from the collection. Iterate through the collection, comparing the name retrieved for each profile to the name of the profile desired. When a match is found, use the IWMEncSourceGroup.Profile or the IWMEncProfileCollection.Itemto return the desired profile.

Example Code

' Create a WMEncoder object.
Dim Encoder As WMEncoder
Set Encoder = New WMEncoder

' Declare objects and variables.
Dim SrcGrpColl As IWMEncSourceGroupCollection
Dim SrcGrp As IWMEncSourceGroup
Dim AudSrc As IWMEncSource
Dim VidSrc As IWMEncVideoSource
Dim ProColl As IWMEncProfileCollection
Dim Pro As IWMEncProfile
Dim i As Integer

' Create an IWMEncSourceGroupCollection object.
Set SrcGrpColl = Encoder.SourceGroupCollection

' Create an IWMEncSourceGroup object.
Set SrcGrp = SrcGrpColl.Add("SG_1")

' Create a video and an audio source object.
Set AudSrc = SrcGrp.AddSource(WMENC_AUDIO)
Set VidSrc = SrcGrp.AddSource(WMENC_VIDEO)

' Specify the .avi source file.
AudSrc.SetInput "C:\filename.avi"
VidSrc.SetInput "C:\filename.avi"

' Loop through the collection of system profiles to set
' a specific profile into the source group object.
Dim sProDesc As String
Dim lMaxPacketSz As Long
Dim iMediaCount As Integer
Dim bMultiBitRate As Boolean

Set ProColl = Encoder.ProfileCollection
For i = 0 To ProColl.Count - 1
    Set Pro = ProColl.Item(i)
    If Pro.Name = "profile_name" Then
        SrcGrp.Profile = Pro
        sProDesc = Pro.Description
        lMaxPacketSize = Pro.MaxPacketSize
        iMediaCount = Pro.MediaCount(WMENC_VIDEO)
        bMultiBitRate = Pro.MultipleBitrate

        Exit For
    End If
Next

See Also

  • IWMEncProfile Object
  • IWMEncProfileCollection.Item
  • IWMEncProfileCollection Object
  • IWMEncSource Object
  • IWMEncSourceGroup Object
  • IWMEncSourceGroup.Profile
  • IWMEncSourceGroupCollection Object


IWMEncProfileCollection Object

The IWMEncProfileCollection object contains all of the enumerated profiles that are available to an encoding session. The IWMEncProfileCollection object exposes the following properties and methods.

Property | Description
Count | Retrieves the number of profiles in the collection.
length | Retrieves the number of profiles in the collection. This is the JScript version of Count.
ProfileDirectory | Retrieves the path of the directory containing custom profiles.

Method | Description
Item | Retrieves a specific profile from the collection.
Refresh | Removes the old profile collection and populates a new collection.

See Also

  • [Visual C++] IWMEncProfileCollection Interface
  • Objects (Visual Basic)


IWMEncProfileCollection.Count

The Count property retrieves the number of profiles in the collection.

Syntax

Long = IWMEncProfileCollection.Count

Parameters

This property takes no parameters.

Return Values

When getting the value, this property returns a LONG containing the number of profiles in the collection.

Remarks

This property is read-only. This method is the VB version of the JScript IWMEncProfileCollection.length method.

Example Code

' Create a WMEncoder object.
Dim Encoder As WMEncoder
Set Encoder = New WMEncoder

' Declare objects and variables.
Dim SrcGrpColl As IWMEncSourceGroupCollection
Dim SrcGrp As IWMEncSourceGroup
Dim AudSrc As IWMEncSource
Dim VidSrc As IWMEncVideoSource
Dim ProColl As IWMEncProfileCollection
Dim Pro As IWMEncProfile
Dim i As Integer

' Create an IWMEncSourceGroupCollection object.
Set SrcGrpColl = Encoder.SourceGroupCollection

' Create an IWMEncSourceGroup object.
Set SrcGrp = SrcGrpColl.Add("SG_1")

' Create a video and an audio source object.
Set AudSrc = SrcGrp.AddSource(WMENC_AUDIO)
Set VidSrc = SrcGrp.AddSource(WMENC_VIDEO)

' Specify the .avi source file.
AudSrc.SetInput "C:\filename.avi"
VidSrc.SetInput "C:\filename.avi"

' Loop through the collection of system profiles to set
' a specific profile into the source group object.
Dim sProDesc As String
Dim lMaxPacketSz As Long
Dim iMediaCount As Integer
Dim bMultiBitRate As Boolean

Set ProColl = Encoder.ProfileCollection
For i = 0 To ProColl.Count - 1
    Set Pro = ProColl.Item(i)
    If Pro.Name = "profile_name" Then
        SrcGrp.Profile = Pro
        sProDesc = Pro.Description
        lMaxPacketSize = Pro.MaxPacketSize
        iMediaCount = Pro.MediaCount(WMENC_VIDEO)
        bMultiBitRate = Pro.MultipleBitrate

        Exit For
    End If
Next

See Also

  • IWMEncProfile Object
  • IWMEncProfileCollection.length
  • IWMEncProfileCollection Object
  • IWMEncSource Object
  • IWMEncSourceGroup Object
  • IWMEncSourceGroupCollection Object


IWMEncProfileCollection.length

The length property retrieves the number of profiles in the collection.

Syntax

Long = IWMEncProfileCollection.length

Parameters

This property takes no parameters.

Return Values

When getting the value, this property returns a LONG containing the number of profiles in the collection.

Remarks

This property is read-only. This method performs the same action as the IWMEncProfileCollection.Count method. It is included for JScript developers or developers more comfortable with JScript syntax.

Example Code

' Create a WMEncoder object.
Dim Encoder As WMEncoder
Set Encoder = New WMEncoder

' Declare objects and variables.
Dim SrcGrpColl As IWMEncSourceGroupCollection
Dim SrcGrp As IWMEncSourceGroup
Dim AudSrc As IWMEncSource
Dim VidSrc As IWMEncVideoSource
Dim ProColl As IWMEncProfileCollection
Dim Pro As IWMEncProfile
Dim i As Integer

' Create an IWMEncSourceGroupCollection object.
Set SrcGrpColl = Encoder.SourceGroupCollection

' Create an IWMEncSourceGroup object.
Set SrcGrp = SrcGrpColl.Add("SG_1")

' Create a video and an audio source object.
Set AudSrc = SrcGrp.AddSource(WMENC_AUDIO)
Set VidSrc = SrcGrp.AddSource(WMENC_VIDEO)

' Specify the .avi source file.
AudSrc.SetInput "C:\filename.avi"
VidSrc.SetInput "C:\filename.avi"

' Loop through the collection of system profiles to set
' a specific profile into the source group object.
Dim sProDesc As String
Dim lMaxPacketSz As Long
Dim iMediaCount As Integer
Dim bMultiBitRate As Boolean

Set ProColl = Encoder.ProfileCollection
For i = 0 To ProColl.Count - 1
    Set Pro = ProColl.Item(i)
    If Pro.Name = "profile_name" Then
        SrcGrp.Profile = Pro
        sProDesc = Pro.Description
        lMaxPacketSize = Pro.MaxPacketSize
        iMediaCount = Pro.MediaCount(WMENC_VIDEO)
        bMultiBitRate = Pro.MultipleBitrate

        Exit For
    End If
Next

See Also

  • IWMEncProfileCollection.Count
  • IWMEncProfile Object
  • IWMEncProfileCollection Object
  • IWMEncSource Object
  • IWMEncSourceGroup Object
  • IWMEncSourceGroupCollection Object


IWMEncProfileCollection.ProfileDirectory

The ProfileDirectory property specifies and retrieves .

Syntax

IWMEncProfileCollection.ProfileDirectory = BSTR
BSTR = IWMEncProfileCollection.ProfileDirectory

Parameters

This property takes no parameters.

Return Values

When getting the value, this property returns a BSTR containing the path.

Remarks

The default directory can be found by examining the registry key HKEY_CLASSES_ROOT\Software\Microsoft\Windows Media Tools\Encoder\Profile\Directory. The get_ProfileDirectory method does not return the name of the directory where the system profiles are stored. The file name extension for profiles is .prx.

Example Code

' Create a WMEncoder object.
Dim Encoder As WMEncoder
Set Encoder = New WMEncoder

' Declare objects and variables.
Dim SrcGrpColl As IWMEncSourceGroupCollection
Dim SrcGrp As IWMEncSourceGroup
Dim AudSrc As IWMEncSource
Dim VidSrc As IWMEncVideoSource
Dim ProColl As IWMEncProfileCollection
Dim Pro As IWMEncProfile
Dim i As Integer

' Create an IWMEncSourceGroupCollection object.
Set SrcGrpColl = Encoder.SourceGroupCollection

' Create an IWMEncSourceGroup object.
Set SrcGrp = SrcGrpColl.Add("SG_1")

' Create a video and an audio source object.
Set AudSrc = SrcGrp.AddSource(WMENC_AUDIO)
Set VidSrc = SrcGrp.AddSource(WMENC_VIDEO)

' Specify the .avi source file.
AudSrc.SetInput "C:\filename.avi"
VidSrc.SetInput "C:\filename.avi"

' Loop through the collection of system profiles to set
' a specific profile into the source group object.
Dim sProDesc As String
Dim lMaxPacketSz As Long
Dim iMediaCount As Integer
Dim bMultiBitRate As Boolean

Set ProColl = Encoder.ProfileCollection
For i = 0 To ProColl.Count - 1
    Set Pro = ProColl.Item(i)
    If Pro.Name = "profile_name" Then
        SrcGrp.Profile = Pro
        sProDesc = Pro.Description
        lMaxPacketSize = Pro.MaxPacketSize
        iMediaCount = Pro.MediaCount(WMENC_VIDEO)
        bMultiBitRate = Pro.MultipleBitrate

        Exit For
    End If
Next

See Also

  • IWMEncProfileCollection Object


IWMEncProfileCollection.Item

The Item method retrieves a specific profile from the collection.

Syntax

IWMEncProfile = IWMEncProfileCollection.Item(lIndex)

Parameters

lIndex

[in] LONG containing the index into the collection.

Return Values

This method returns an IWMEncProfile object corresponding to lIndex.

Remarks

The input parameter is an integer index into the collection. If you don’t already know the index associated with the needed profile pointer, you must iterate through the collection starting at item 0. On each iteration increment lIndex and use the Item method to retrieve a pointer to a profile. Call the IWMEncProfile.Name property to find the name of the profile being pointed to and compare the name retrieved to that needed. Exit the loop when a match is found.

Example Code

' Create a WMEncoder object.
Dim Encoder As WMEncoder
Set Encoder = New WMEncoder

' Declare objects and variables.
Dim SrcGrpColl As IWMEncSourceGroupCollection
Dim SrcGrp As IWMEncSourceGroup
Dim AudSrc As IWMEncSource
Dim VidSrc As IWMEncVideoSource
Dim ProColl As IWMEncProfileCollection
Dim Pro As IWMEncProfile
Dim i As Integer

' Create an IWMEncSourceGroupCollection object.
Set SrcGrpColl = Encoder.SourceGroupCollection

' Create an IWMEncSourceGroup object.
Set SrcGrp = SrcGrpColl.Add("SG_1")

' Create a video and an audio source object.
Set AudSrc = SrcGrp.AddSource(WMENC_AUDIO)
Set VidSrc = SrcGrp.AddSource(WMENC_VIDEO)

' Specify the .avi source file.
AudSrc.SetInput "C:\filename.avi"
VidSrc.SetInput "C:\filename.avi"

' Loop through the collection of system profiles to set
' a specific profile into the source group object.
Dim sProDesc As String
Dim lMaxPacketSz As Long
Dim iMediaCount As Integer
Dim bMultiBitRate As Boolean

Set ProColl = Encoder.ProfileCollection
For i = 0 To ProColl.Count - 1
    Set Pro = ProColl.Item(i)
    If Pro.Name = "profile_name" Then
        SrcGrp.Profile = Pro
        sProDesc = Pro.Description
        lMaxPacketSize = Pro.MaxPacketSize
        iMediaCount = Pro.MediaCount(WMENC_VIDEO)
        bMultiBitRate = Pro.MultipleBitrate

        Exit For
    End If
Next

See Also

  • IWMEncProfile.Name
  • IWMEncProfile Object
  • IWMEncProfileCollection Object
  • IWMEncSource Object
  • IWMEncSourceGroup Object
  • IWMEncSourceGroupCollection Object


IWMEncProfileCollection.Refresh

The Refresh method deletes the old profile collection and populates a new collection.

Syntax

IWMEncProfileCollection.Refresh

Parameters

This method takes no parameters.

Return Values

This method does not return a value.

Remarks

Use this method to reveal all of the available profiles after you have modified the collection with either the Profile Manager or the Windows Media Format SDK. You can use the IWMEncProfileManager object to create the Profile Manager dialog boxes that edit and list profiles.

Example Code

' Create a WMEncoder object.
Dim Encoder As WMEncoder
Set Encoder = New WMEncoder

' Declare objects and variables.
Dim SrcGrpColl As IWMEncSourceGroupCollection
Dim SrcGrp As IWMEncSourceGroup
Dim AudSrc As IWMEncSource
Dim VidSrc As IWMEncVideoSource
Dim ProColl As IWMEncProfileCollection
Dim Pro As IWMEncProfile
Dim i As Integer

' Create an IWMEncSourceGroupCollection object.
Set SrcGrpColl = Encoder.SourceGroupCollection

' Create an IWMEncSourceGroup object.
Set SrcGrp = SrcGrpColl.Add("SG_1")

' Create a video and an audio source object.
Set AudSrc = SrcGrp.AddSource(WMENC_AUDIO)
Set VidSrc = SrcGrp.AddSource(WMENC_VIDEO)

' Specify the .avi source file.
AudSrc.SetInput "C:\filename.avi"
VidSrc.SetInput "C:\filename.avi"

' Loop through the collection of system profiles to set
' a specific profile into the source group object.
Dim sProDesc As String
Dim lMaxPacketSz As Long
Dim iMediaCount As Integer
Dim bMultiBitRate As Boolean

Set ProColl = Encoder.ProfileCollection
For i = 0 To ProColl.Count - 1
    Set Pro = ProColl.Item(i)
    If Pro.Name = "profile_name" Then
        SrcGrp.Profile = Pro
        sProDesc = Pro.Description
        lMaxPacketSize = Pro.MaxPacketSize
        iMediaCount = Pro.MediaCount(WMENC_VIDEO)
        bMultiBitRate = Pro.MultipleBitrate

        Exit For
    End If
Next

See Also

  • IWMEncProfile Object
  • IWMEncProfileCollection Object
  • IWMEncProfileManager Object
  • IWMEncSource Object
  • IWMEncSourceGroup Object
  • IWMEncSourceGroupCollection Object


IWMEncProfileManager Object

The IWMEncProfileManager object creates the Profile Manager dialog boxes that allow the user to edit and list profiles. The IWMEncProfileManager object exposes the following properties and methods.

Property | Description
LastCreatedProfile | Retrieves the name of the profile most recently created by the end user during the current encoding session.
ProfileDirectory | Retrieves the path of the directory containing custom profiles.

Method | Description
GetDetailsString | Retrieves a string containing the details of a specific profile.
WMEncProfileEdit | Creates a dialog box that enables users to create a profile.
WMEncProfileList | Creates a dialog box that displays a list of profiles.
WMEncProfileListEx | Creates a dialog box that displays a list of profiles, and automatically sets the checkboxes on a new profile.

See Also

  • [Visual C++] IWMEncProfileManager Interface
  • Objects (Visual Basic)


IWMEncProfileManager.LastCreatedProfile

The LastCreatedProfile property retrieves the name of the profile most recently created by the end user during the current encoding session.

Syntax

BSTR = IWMEncProfileManager.LastCreatedProfile

Parameters

This property takes no parameters.

Return Values

When getting the value, this property returns a BSTR containing the profile name.

Remarks

This property is read-only. You can use the LastCreatedProfile property to determine whether an end user has created a profile. The variable containing the name of the profile is reset when you call WMEncProfileList.

Example Code

' Create a WMEncProfileManager object.
Dim ProfileMgr As WMEncProfileManager
Set ProfileMgr = New WMEncProfileManager

Dim sLastProfile As String
Dim sProfileDirectory As String
Dim sDetailsString As String

' Display the dialog box that lists the profiles. Because you
' are calling WMEncProfileListEx() rather than WMEncProfileList()
' and have indicated that a new profile is audio only, if you
' bring up the New profile dialog box, only the audio checkbox
' will be selected.
ProfileMgr.WMEncProfileListEx WMENC_FILTER_AV, WMENC_FILTER_A, 0

' Display the New Profile dialog box. If you supply the name of an
' existing profile, the new profile will be a copy of that.
ProfileMgr.WMEncProfileEdit "profile_name", WMENC_FILTER_AV, 0

' Retrieve a string containing the details of a specific profile.
sDetailsString = ProfileMgr.GetDetailsString("profile_name", 0)

' Retrieve the name of last profile created during the current
' encoding session.
sLastProfile = ProfileMgr.LastCreatedProfile

' Retrieve a string containing the path of the directory in which
' custom profiles are stored.
sProfileDirectory = ProfileMgr.ProfileDirectory

See Also

  • IWMEncProfileManager Object
  • IWMEncProfileManager.WMEncProfileList


IWMEncProfileManager.ProfileDirectory

The ProfileDirectory property specifies and retrieves the path of the directory containing custom profiles.

Syntax

IWMEncProfileManager.ProfileDirectory = BSTR
BSTR = IWMEncProfileManager.ProfileDirectory

Parameters

This property takes no parameters.

Return Values

When getting the value, this property returns a BSTR containing the path.

Remarks

The default directory can be found by examining the registry key HKEY_CLASSES_ROOT\Software\Microsoft\Windows Media Tools\Encoder\Profile\Directory. The get_ProfileDirectory method does not return the name of the directory where the system profiles are stored. The file name extension for profiles is .prx.

Example Code

' Create a WMEncProfileManager object.
Dim ProfileMgr As WMEncProfileManager
Set ProfileMgr = New WMEncProfileManager

Dim sLastProfile As String
Dim sProfileDirectory As String
Dim sDetailsString As String

' Display the dialog box that lists the profiles. Because you
' are calling WMEncProfileListEx() rather than WMEncProfileList()
' and have indicated that a new profile is audio only, if you
' bring up the New profile dialog box, only the audio checkbox
' will be selected.
ProfileMgr.WMEncProfileListEx WMENC_FILTER_AV, WMENC_FILTER_A, 0

' Display the New Profile dialog box. If you supply the name of an
' existing profile, the new profile will be a copy of that.
ProfileMgr.WMEncProfileEdit "profile_name", WMENC_FILTER_AV, 0

' Retrieve a string containing the details of a specific profile.
sDetailsString = ProfileMgr.GetDetailsString("profile_name", 0)

' Retrieve the name of last profile created during the current
' encoding session.
sLastProfile = ProfileMgr.LastCreatedProfile

' Retrieve a string containing the path of the directory in which
' custom profiles are stored.
sProfileDirectory = ProfileMgr.ProfileDirectory

See Also

  • IWMEncProfileManager Object


IWMEncProfileManager.GetDetailsString

The GetDetailsString method retrieves a string containing the details of a specific profile.

Syntax

bstrDeatilString = IWMEncProfileManager.GetDetailsString( bstrProfileName, lcid)

Parameters

bstrProfileName

[in] BSTR containing the name of the profile.

lcid

[in] LONG containing the locale ID identifying the language that appears in the Profile Manager. If this is left blank, the locale ID defaults to English.

bstrDetailsString

[out] BSTR containing the details of the profile.

Return Values

If this method fails, it returns an error number.

Number | Meaning
0x80070057 | The string containing the profile name cannot be empty.

Remarks

The output string identifies the total number of streams that will be produced by Windows Media Encoder, the bit rate of each, and the specific codecs used. It also indicates the default size, in pixels, of the output video and the number of audio channels produced. The GetDetailsString method does not create a Profile Manager dialog box.

Example Code

' Create a WMEncProfileManager object.
Dim ProfileMgr As WMEncProfileManager
Set ProfileMgr = New WMEncProfileManager

Dim sLastProfile As String
Dim sProfileDirectory As String
Dim sDetailsString As String

' Display the dialog box that lists the profiles. Because you
' are calling WMEncProfileListEx() rather than WMEncProfileList()
' and have indicated that a new profile is audio only, if you
' bring up the New profile dialog box, only the audio checkbox
' will be selected.
ProfileMgr.WMEncProfileListEx WMENC_FILTER_AV, WMENC_FILTER_A, 0

' Display the New Profile dialog box. If you supply the name of an
' existing profile, the new profile will be a copy of that.
ProfileMgr.WMEncProfileEdit "profile_name", WMENC_FILTER_AV, 0

' Retrieve a string containing the details of a specific profile.
sDetailsString = ProfileMgr.GetDetailsString("profile_name", 0)

' Retrieve the name of last profile created during the current
' encoding session.
sLastProfile = ProfileMgr.LastCreatedProfile

' Retrieve a string containing the path of the directory in which
' custom profiles are stored.
sProfileDirectory = ProfileMgr.ProfileDirectory

See Also

  • IWMEncProfileManager Object


IWMEncProfileManager.WMEncProfileEdit

The WMEncProfileEdit method creates a dialog box that enables users to create a profile.

Syntax

IWMEncProfileManager.WMEncProfileEdit bstrProfileName, lfilter, lcid

Parameters

bstrProfileName

[in] BSTR containing the name of the profile. Leave this parameter blank to create a profile.

lfilter

[in] Member of a WMENC_MEDIA_FILTER enumeration type identifying the type of input streams for which the profile is defined. This must be one of the following values.

Value | Number | Description
WMENC_FILTER_NONE | 0 | The profile is not defined for an input stream.
WMENC_FILTER_A | 1 | The profile is defined for one audio input stream.
WMENC_FILTER_AV | 3 | The profile is defined for one audio and one video input stream.
WMENC_FILTER_AS | 4 | The profile is defined for one audio and one text input stream.
WMENC_FILTER_AVS | 5 | The profile is defined for one audio, one video and one text input stream.

lcid

[in] LONG containing the locale ID identifying the language that appears in the Profile Manager. If this is left blank, the locale ID defaults to English.

Return Values

This method does not return a value.

Example Code

' Create a WMEncProfileManager object.
Dim ProfileMgr As WMEncProfileManager
Set ProfileMgr = New WMEncProfileManager

Dim sLastProfile As String
Dim sProfileDirectory As String
Dim sDetailsString As String

' Display the dialog box that lists the profiles. Because you
' are calling WMEncProfileListEx() rather than WMEncProfileList()
' and have indicated that a new profile is audio only, if you
' bring up the New profile dialog box, only the audio checkbox
' will be selected.
ProfileMgr.WMEncProfileListEx WMENC_FILTER_AV, WMENC_FILTER_A, 0

' Display the New Profile dialog box. If you supply the name of an
' existing profile, the new profile will be a copy of that.
ProfileMgr.WMEncProfileEdit "profile_name", WMENC_FILTER_AV, 0

' Retrieve a string containing the details of a specific profile.
sDetailsString = ProfileMgr.GetDetailsString("profile_name", 0)

' Retrieve the name of last profile created during the current
' encoding session.
sLastProfile = ProfileMgr.LastCreatedProfile

' Retrieve a string containing the path of the directory in which
' custom profiles are stored.
sProfileDirectory = ProfileMgr.ProfileDirectory

See Also

  • IWMEncProfileManager Object
  • IWMEncProfileManager.WMEncProfileList


IWMEncProfileManager.WMEncProfileList

The WMEncProfileList method creates a dialog box that displays a list of profiles.

Syntax

IWMEncProfileManager.WMEncProfileList filter, lcid

Parameters

filter

[in] Member of a WMENC_MEDIA_FILTER enumeration type identifying the type of input streams for which the profiles in the list are defined. This must be one of the following values.

Value | Number | Description
WMENC_FILTER_NONE | 0 | The profile is not defined for an input stream.
WMENC_FILTER_A | 1 | The profile is defined for one audio input stream.
WMENC_FILTER_AV | 3 | The profile is defined for one audio and one video input stream.
WMENC_FILTER_AS | 4 | The profile is defined for one audio and one text input stream.
WMENC_FILTER_AVS | 5 | The profile is defined for one audio, one video and one text input stream.

lcid

[in] LCID containing the locale ID identifying the language that appears in the Profile Manager. If this is left blank, the locale ID defaults to English.

Return Values

This method does not return a value.

Example Code

' Create a WMEncProfileManager object.
Dim ProfileMgr As WMEncProfileManager
Set ProfileMgr = New WMEncProfileManager

Dim sLastProfile As String
Dim sProfileDirectory As String
Dim sDetailsString As String

' Display the dialog box that lists the profiles. Because you
' are calling WMEncProfileListEx() rather than WMEncProfileList()
' and have indicated that a new profile is audio only, if you
' bring up the New profile dialog box, only the audio checkbox
' will be selected.
ProfileMgr.WMEncProfileListEx WMENC_FILTER_AV, WMENC_FILTER_A, 0

' Display the New Profile dialog box. If you supply the name of an
' existing profile, the new profile will be a copy of that.
ProfileMgr.WMEncProfileEdit "profile_name", WMENC_FILTER_AV, 0

' Retrieve a string containing the details of a specific profile.
sDetailsString = ProfileMgr.GetDetailsString("profile_name", 0)

' Retrieve the name of last profile created during the current
' encoding session.
sLastProfile = ProfileMgr.LastCreatedProfile

' Retrieve a string containing the path of the directory in which
' custom profiles are stored.
sProfileDirectory = ProfileMgr.ProfileDirectory

See Also

  • IWMEncProfileManager Object
  • IWMEncProfileManager.WMEncProfileEdit


IWMEncProfileManager.WMEncProfileListEx

The WMEncProfileListEx method creates a dialog box that displays a list of profiles, and automatically sets the checkboxes on a new profile.

Syntax

IWMEncProfileManager.WMEncProfileListEx filter, newDefault, lcid

Parameters

filter

[in] Member of a WMENC_MEDIA_FILTER enumeration type identifying the type of input streams for which the profiles in the list are defined. This must be one of the following values.

Value | Number | Description
WMENC_FILTER_NONE | 0 | The profile is not defined for an input stream.
WMENC_FILTER_A | 1 | The profile is defined for one audio input stream.
WMENC_FILTER_AV | 3 | The profile is defined for one audio and one video input stream.
WMENC_FILTER_AS | 4 | The profile is defined for one audio and one text input stream.
WMENC_FILTER_AVS | 5 | The profile is defined for one audio, one video and one text input stream.

newDefault

[in] Member of a WMENC_MEDIA_FILTER enumeration type identifying the type of input streams for which a new profile will be defined. This must be one of the following values.

Value | Number | Description
WMENC_FILTER_NONE | 0 | The profile is not defined for an input stream.
WMENC_FILTER_A | 1 | The profile is defined for one audio input stream.
WMENC_FILTER_AV | 3 | The profile is defined for one audio and one video input stream.
WMENC_FILTER_AS | 4 | The profile is defined for one audio and one text input stream.
WMENC_FILTER_AVS | 5 | The profile is defined for one audio, one video and one text input stream.

lcid

[in] long containing the locale ID identifying the language that appears in the Profile Manager. The locale ID for English is zero.

Return Values

This method does not return a value.

Remarks

When the end user chooses New to create a profile, the checkboxes in the dialog box will be set according to the filter chosen for newDefault.

Example Code

' Create a WMEncProfileManager object.
Dim ProfileMgr As WMEncProfileManager
Set ProfileMgr = New WMEncProfileManager

Dim sLastProfile As String
Dim sProfileDirectory As String
Dim sDetailsString As String

' Display the dialog box that lists the profiles. Because you
' are calling WMEncProfileListEx() rather than WMEncProfileList()
' and have indicated that a new profile is audio only, if you
' bring up the New profile dialog box, only the audio checkbox
' will be selected.
ProfileMgr.WMEncProfileListEx WMENC_FILTER_AV, WMENC_FILTER_A, 0

' Display the New Profile dialog box. If you supply the name of an
' existing profile, the new profile will be a copy of that.
ProfileMgr.WMEncProfileEdit "profile_name", WMENC_FILTER_AV, 0

' Retrieve a string containing the details of a specific profile.
sDetailsString = ProfileMgr.GetDetailsString("profile_name", 0)

' Retrieve the name of last profile created during the current
' encoding session.
sLastProfile = ProfileMgr.LastCreatedProfile

' Retrieve a string containing the path of the directory in which
' custom profiles are stored.
sProfileDirectory = ProfileMgr.ProfileDirectory

See Also

  • IWMEncProfileManager Object
  • IWMEncProfileManager.WMEncProfileList


IWMEncSource Object

The IWMEncSource object loads a source capture plug-in, trims and repeats a specific stream, and retrieves transformation plug-ins and data view objects. The IWMEncSource object exposes the following properties and methods.

Property | Description
MarkIn | Specifies and retrieves the starting point of a media stream.
MarkOut | Specifies and retrieves the end point of a media stream.
PostviewCollection | Retrieves a collection of postview objects for the source stream. The collection consists of IWMEncDataView objects that are not Automation-compliant.
PreviewCollection | Retrieves a collection of preview objects for the source stream. The collection consists of IWMEncDataView objects that are not Automation-compliant.
TransformCollection | Retrieves the collection of all registered transform plug-ins.
Type | Retrieves the type of the input media stream.
Repeat | Specifies and retrieves the repeat property of a stream.

Method | Description
GetInput | Retrieves the stream capture source. This is usually either a file or a plug-in.
GetSourcePlugin | Retrieves the source plug-in associated with the source stream. This is not an Automation-compliant method.
GetTransformPlugin | Retrieves a specific transform plug-in, by index, for the source stream. This is a non-Automation compliant method.
GetTransformPluginCount | Retrieves the number of transform plug-ins that can be applied to the source stream.
SetInput | Specifies the stream capture source.

See Also

  • [Visual C++] IWMEncDataView Interface
  • [Visual C++] IWMEncSource Interface
  • Objects (Visual Basic)


IWMEncSource.MarkIn

The MarkIn property sets and retrieves the starting point of a media stream, in milliseconds (ms), from the start of the original stream.

Syntax

IWMEncSource.MarkIn = Long
Long = IWMEncSource.MarkIn

Parameters

This property takes no parameters.

Return Values

When getting the value, this property returns a LONG containing the starting point of the stream.

If this property fails, it returns an error number.

Number | Meaning
0xC00D1B58 | The specified starting point is less than 0 or greater than the end point.
0xC00D0011 | This property cannot be set if the encoder engine is running.
0xC00D002B | You must index the Windows Media file before setting this property.

Example Code

' Create a WMEncoder object.
Dim Encoder As WMEncoder
Set Encoder = New WMEncoder

' Declare objects and variables.
Dim SrcGrpColl As IWMEncSourceGroupCollection
Dim SrcGrp As IWMEncSourceGroup
Dim AudSrc As IWMEncSource
Dim VidSrc As IWMEncVideoSource
Dim ProColl As IWMEncProfileCollection
Dim Pro As IWMEncProfile
Dim i As Integer

' Create an IWMEncSourceGroupCollection object.
Set SrcGrpColl = Encoder.SourceGroupCollection

' Create an IWMEncSourceGroup object.
Set SrcGrp = SrcGrpColl.Add("SG_1")

' Create a video and an audio source object.
Set AudSrc = SrcGrp.AddSource(WMENC_AUDIO)
Set VidSrc = SrcGrp.AddSource(WMENC_VIDEO)

' Loop through the collection of system profiles to set
' a specific profile into the source group object.

Set ProColl = Encoder.ProfileCollection
For i = 0 To ProColl.Count - 1
    Set Pro = ProColl.Item(i)
    If Pro.Name = "Video for LAN, cable modem, or xDSL (100 to 768 Kbps)" Then
        SrcGrp.Profile = Pro
        Exit For
    End If
Next

' Specify live stream capture from the installed video
' and audio cards.

VidSrc.SetInput "DEVICE://Default_Video_Device"
AudSrc.SetInput "DEVICE://Default_Audio_Device"

' Verify that the repeat property is turned off. This is
' the default.

VidSrc.Repeat = False
AudSrc.Repeat = False

' Start the encoding process 10 seconds after the source
' has started, and stop the encoding process 25 seconds
' after the source has started.

VidSrc.MarkIn = 10000
AudSrc.MarkIn = 10000
VidSrc.MarkOut = 25000
AudSrc.MarkOut = 25000

' Initialize the encoder engine.

SrcGrp.PrepareToEncode (True)

See Also

  • IWMEncSource.MarkOut
  • IWMEncSource Object


IWMEncSource.MarkOut

The MarkOut property sets and retrieves the end point of a media stream, in milliseconds (ms), from the start of the original stream.

Syntax

IWMEncSource.MarkOut = Long
Long = IWMEncSource.MarkOut

Parameters

This property takes no parameters.

Return Values

When getting the value, this property returns a LONG containing the end point of the stream.

If this property fails, it returns an error number.

Number | Meaning
0xC00D1B59 | The specified ending point is either less than 0 or less than the starting point.
0xC00D0011 | This property cannot be set if the encoder engine is running.
0xC00D002B | You must index the Windows Media file before setting this property.

Example Code

' Create a WMEncoder object.
Dim Encoder As WMEncoder
Set Encoder = New WMEncoder

' Declare objects and variables.
Dim SrcGrpColl As IWMEncSourceGroupCollection
Dim SrcGrp As IWMEncSourceGroup
Dim AudSrc As IWMEncSource
Dim VidSrc As IWMEncVideoSource
Dim ProColl As IWMEncProfileCollection
Dim Pro As IWMEncProfile
Dim i As Integer

' Create an IWMEncSourceGroupCollection object.
Set SrcGrpColl = Encoder.SourceGroupCollection

' Create an IWMEncSourceGroup object.
Set SrcGrp = SrcGrpColl.Add("SG_1")

' Create a video and an audio source object.
Set AudSrc = SrcGrp.AddSource(WMENC_AUDIO)
Set VidSrc = SrcGrp.AddSource(WMENC_VIDEO)

' Loop through the collection of system profiles to set
' a specific profile into the source group object.

Set ProColl = Encoder.ProfileCollection
For i = 0 To ProColl.Count - 1
    Set Pro = ProColl.Item(i)
    If Pro.Name = "Video for LAN, cable modem, or xDSL (100 to 768 Kbps)" Then
        SrcGrp.Profile = Pro
        Exit For
    End If
Next

' Specify live stream capture from the installed video
' and audio cards.

VidSrc.SetInput "DEVICE://Default_Video_Device"
AudSrc.SetInput "DEVICE://Default_Audio_Device"

' Verify that the repeat property is turned off. This is
' the default.

VidSrc.Repeat = False
AudSrc.Repeat = False

' Start the encoding process 10 seconds after the source
' has started, and stop the encoding process 25 seconds
' after the source has started.

VidSrc.MarkIn = 10000
AudSrc.MarkIn = 10000
VidSrc.MarkOut = 25000
AudSrc.MarkOut = 25000

' Initialize the encoder engine.

SrcGrp.PrepareToEncode (True)

See Also

  • IWMEncSource.MarkIn
  • IWMEncSource Object


IWMEncSource.PostviewCollection

The PostviewCollection property retrieves a collection of postview objects for the source stream.

Syntax

IWMEncDataViewCollection = IWMEncSource.PostviewCollection

Parameters

This property takes no parameters.

Return Values

When getting the value, this property returns a collection of postview objects.

Remarks

This property is read-only. A postview is an IWMEncDataView object that renders content in a window after the content has been both compressed and decompressed. Postviews more closely approximate the appearance of the output in Windows Media Player.

See Also

  • IWMEncSource Object


IWMEncSource.PreviewCollection

The PreviewCollection property retrieves a collection of preview objects for the source stream.

Syntax

IWMEncDataViewCollection = IWMEncSource.PreviewCollection

Parameters

This property takes no parameters.

Return Values

When getting the value, this property returns a collection of preview objects.

Remarks

This property is read-only. A preview is an IWMEncDataview object that renders content in a window before compression.

See Also

  • IWMEncSource Object


IWMEncSource.Repeat

The Repeat property sets and retrieves the repeat property of a stream.

Syntax

IWMEncSource.Repeat = VARIANT_BOOL
VARIANT_BOOL = IWMEncSource.Repeat

Parameters

This property takes no parameters.

Return Values

When getting the value, this property returns a VARIANT_BOOL identifying whether the stream repeats.

If this property fails, it returns an error number.

Number | Meaning
0xC00D0011 | This property cannot be set if the encoder engine is running.

Remarks

Set this property to True to repeatedly capture input from the same source.

Example Code

' Create a WMEncoder object.
Dim Encoder As WMEncoder
Set Encoder = New WMEncoder

' Declare objects and variables.
Dim SrcGrpColl As IWMEncSourceGroupCollection
Dim SrcGrp As IWMEncSourceGroup
Dim AudSrc As IWMEncSource
Dim VidSrc As IWMEncVideoSource
Dim ProColl As IWMEncProfileCollection
Dim Pro As IWMEncProfile
Dim i As Integer

' Create an IWMEncSourceGroupCollection object.
Set SrcGrpColl = Encoder.SourceGroupCollection

' Create an IWMEncSourceGroup object.
Set SrcGrp = SrcGrpColl.Add("SG_1")

' Create a video and an audio source object.
Set AudSrc = SrcGrp.AddSource(WMENC_AUDIO)
Set VidSrc = SrcGrp.AddSource(WMENC_VIDEO)

' Loop through the collection of system profiles to set
' a specific profile into the source group object.

Set ProColl = Encoder.ProfileCollection
For i = 0 To ProColl.Count - 1
    Set Pro = ProColl.Item(i)
    If Pro.Name = "Video for LAN, cable modem, or xDSL (100 to 768 Kbps)" Then
        SrcGrp.Profile = Pro
        Exit For
    End If
Next

' Specify live stream capture from the installed video
' and audio cards.

VidSrc.SetInput "DEVICE://Default_Video_Device"
AudSrc.SetInput "DEVICE://Default_Audio_Device"

' Verify that the repeat property is turned off. This is
' the default.

VidSrc.Repeat = False
AudSrc.Repeat = False

' Start the encoding process 10 seconds after the source
' has started, and stop the encoding process 25 seconds
' after the source has started.

VidSrc.MarkIn = 10000
AudSrc.MarkIn = 10000
VidSrc.MarkOut = 25000
AudSrc.MarkOut = 25000

' Initialize the encoder engine.

SrcGrp.PrepareToEncode (True)

See Also

  • IWMEncSource Object


IWMEncSource.TransformCollection

The TransformCollection property retrieves a collection of transform plug-ins.

Syntax

IWMEncTransformCollection = IWMEncSource.TransformCollection

Parameters

This property takes no parameters.

Return Values

When getting the value, this property returns an IWMEncTransformCollection object.

Remarks

This property is read-only.

See Also

  • IWMEncSource Object
  • IWMEncTransformCollection Object


IWMEncSource.Type

The Type property retrieves the media stream type.

Syntax

WMENC_SOURCE_TYPE = IWMEncSource.Type

Parameters

This property takes no parameters.

Return Values

When getting the value, this property returns a member of the WMENC_SOURCE_TYPE enumeration containing the media type of the current source. This must be one of the folowing values.

Value | Number | Meaning
WMENC_AUDIO | 1 | Identifies an audio stream.
WMENC_VIDEO | 2 | Identifies a video stream.
WMENC_SCRIPT | 4 | Identifies a text stream.

Example Code

' Create a WMEncoder object.
Dim Encoder As WMEncoder
Set Encoder = New WMEncoder

' Declare objects and variables.
Dim SrcGrpColl As IWMEncSourceGroupCollection
Dim SrcGrp As IWMEncSourceGroup
Dim AudSrc As IWMEncSource
Dim VidSrc As IWMEncVideoSource
Dim ProColl As IWMEncProfileCollection
Dim Pro As IWMEncProfile
Dim i As Integer

' Create an IWMEncSourceGroupCollection object.
Set SrcGrpColl = Encoder.SourceGroupCollection

' Create an IWMEncSourceGroup object.
Set SrcGrp = SrcGrpColl.Add("SG_1")

' Create a video and an audio source object.
Set AudSrc = SrcGrp.AddSource(WMENC_AUDIO)
Set VidSrc = SrcGrp.AddSource(WMENC_VIDEO)

' Loop through the collection of system profiles to set
' a specific profile into the source group object.

Set ProColl = Encoder.ProfileCollection
For i = 0 To ProColl.Count - 1
    Set Pro = ProColl.Item(i)
    If Pro.Name = "Video for LAN, cable modem, or xDSL (100 to 768 Kbps)" Then
        SrcGrp.Profile = Pro
        Exit For
    End If
Next

' Specify live stream capture from the installed video
' and audio cards.

VidSrc.SetInput "DEVICE://Default_Video_Device"
AudSrc.SetInput "DEVICE://Default_Audio_Device"

' Verify that the repeat property is turned off. This is
' the default.

VidSrc.Repeat = False
AudSrc.Repeat = False

' Start the encoding process 10 seconds after the source
' has started, and stop the encoding process 25 seconds
' after the source has started.

VidSrc.MarkIn = 10000
AudSrc.MarkIn = 10000
VidSrc.MarkOut = 25000
AudSrc.MarkOut = 25000

' Initialize the encoder engine.

SrcGrp.PrepareToEncode (True)

See Also

  • IWMEncSource Object


IWMEncSource.GetInput

The GetInput method retrieves the stream capture source.

Syntax

BSTR = IWMEncSource.GetInput( bstrStreamName, bstrScheme )

Parameters

bstrStreamName

[out] BSTR containing the name of the input source.

bstrScheme

[out] BSTR containing the scheme type.

Return Values

This method returns a BSTR containing the full name of a plug-in or file from which the source stream is captured.

If this method fails, it returns an error number.

Number | Meaning
0x8007000E | Memory cannot be allocated

Example Code

' Create a WMEncoder object.
Dim Encoder As WMEncoder
Set Encoder = New WMEncoder

' Declare objects and variables.
Dim SrcGrpColl As IWMEncSourceGroupCollection
Dim SrcGrp As IWMEncSourceGroup
Dim AudSrc As IWMEncSource
Dim VidSrc As IWMEncVideoSource
Dim ProColl As IWMEncProfileCollection
Dim Pro As IWMEncProfile
Dim i As Integer

' Create an IWMEncSourceGroupCollection object.
Set SrcGrpColl = Encoder.SourceGroupCollection

' Create an IWMEncSourceGroup object.
Set SrcGrp = SrcGrpColl.Add("SG_1")

' Create a video and an audio source object.
Set AudSrc = SrcGrp.AddSource(WMENC_AUDIO)
Set VidSrc = SrcGrp.AddSource(WMENC_VIDEO)

' Loop through the collection of system profiles to set
' a specific profile into the source group object.

Set ProColl = Encoder.ProfileCollection
For i = 0 To ProColl.Count - 1
    Set Pro = ProColl.Item(i)
    If Pro.Name = "Video for LAN, cable modem, or xDSL (100 to 768 Kbps)" Then
        SrcGrp.Profile = Pro
        Exit For
    End If
Next

' Specify live stream capture from the installed video
' and audio cards.

VidSrc.SetInput "DEVICE://Default_Video_Device"
AudSrc.SetInput "DEVICE://Default_Audio_Device"

' Verify that the repeat property is turned off. This is
' the default.

VidSrc.Repeat = False
AudSrc.Repeat = False

' Start the encoding process 10 seconds after the source
' has started, and stop the encoding process 25 seconds
' after the source has started.

VidSrc.MarkIn = 10000
AudSrc.MarkIn = 10000
VidSrc.MarkOut = 25000
AudSrc.MarkOut = 25000

' Initialize the encoder engine.

SrcGrp.PrepareToEncode (True)

See Also

  • IWMEncSource Object
  • IWMEncSource.SetInput


IWMEncSource.GetSourcePlugin

The GetSourcePlugin method retrieves the source plug-in associated with the source stream.

Syntax

IUnknown = IWMEncSource.GetSourcePlugin

Parameters

This method takes no parameters.

Return Values

This method returns an IUnknown.

Remarks

This is not an Automation-compliant method.

See Also

  • IWMEncSource Object


IWMEncSource.GetTransformPlugin

The GetTransformPlugin method retrieves a specific transform plug-in, by index, for the source stream.

Syntax

IUnknown = IWMEncSource.GetTransformPlugin(dwIndex)

Parameters

dwIndex

[in] DWORD containing the zero-based index of the plug-in.

Return Values

This method returns an IUnknown.

If this method fails, it returns an error number.

Number | Meaning
0x80070057 | The plug-in index is not valid.
0xC00D1B66 | No plug-in corresponds to the index.

Remarks

This is not an Automation-compliant method.

See Also

  • IWMEncSource.GetTransformPluginCount
  • IWMEncSource Object


IWMEncSource.GetTransformPluginCount

The GetTransformPluginCount method retrieves the number of transform plug-ins that can be applied to the source stream.

Syntax

DWORD = IWMEncSource.GetTransformPluginCount

Parameters

This method takes no parameters.

Return Values

This method returns a DWORD containing the plug-in count.

See Also

  • IWMEncSource.GetTransformPlugin
  • IWMEncSource Object


IWMEncSource.SetInput

The SetInput method specifies the stream capture source.

Syntax

IWMEncSource.SetInput bstrInput, bstrScheme, bstrStreamName

Parameters

bstrInput

[in] BSTR containing the full name of a plug-in or file from which the source stream is captured. Specify a plug-in name in the "scheme://resource" format. Specify the full path name of a file. If you put only the "resource" in pbstrInput, Windows Media Encoder examines bstrScheme to find the scheme type.

bstrScheme

[in] BSTR containing the scheme type. If you supply a value for this parameter, Windows Media Encoder examines bstrInput to form a "scheme://resource" plug-in identifier without parsing the stream. This is useful if the "resource" part of the string contains special characters or symbols that cannot be interpreted as part of a standard URL.

bstrStreamName

[in] BSTR containing the name of a stream. Use this parameter to identify specific information for a plug-in object. In the current version of Windows Media Encoder, this parameter is not used.

Return Values

If this method fails, it returns an error number.

Number | Meaning
0xC00D0011 | This method cannot be called if the encoder engine is running.

Example Code

' Create a WMEncoder object.
Dim Encoder As WMEncoder
Set Encoder = New WMEncoder

' Declare objects and variables.
Dim SrcGrpColl As IWMEncSourceGroupCollection
Dim SrcGrp As IWMEncSourceGroup
Dim AudSrc As IWMEncSource
Dim VidSrc As IWMEncVideoSource
Dim ProColl As IWMEncProfileCollection
Dim Pro As IWMEncProfile
Dim i As Integer

' Create an IWMEncSourceGroupCollection object.
Set SrcGrpColl = Encoder.SourceGroupCollection

' Create an IWMEncSourceGroup object.
Set SrcGrp = SrcGrpColl.Add("SG_1")

' Create a video and an audio source object.
Set AudSrc = SrcGrp.AddSource(WMENC_AUDIO)
Set VidSrc = SrcGrp.AddSource(WMENC_VIDEO)

' Loop through the collection of system profiles to set
' a specific profile into the source group object.

Set ProColl = Encoder.ProfileCollection
For i = 0 To ProColl.Count - 1
    Set Pro = ProColl.Item(i)
    If Pro.Name = "Video for LAN, cable modem, or xDSL (100 to 768 Kbps)" Then
        SrcGrp.Profile = Pro
        Exit For
    End If
Next

' Specify live stream capture from the installed video
' and audio cards.

VidSrc.SetInput "DEVICE://Default_Video_Device"
AudSrc.SetInput "DEVICE://Default_Audio_Device"

' Verify that the repeat property is turned off. This is
' the default.

VidSrc.Repeat = False
AudSrc.Repeat = False

' Start the encoding process 10 seconds after the source
' has started, and stop the encoding process 25 seconds
' after the source has started.

VidSrc.MarkIn = 10000
AudSrc.MarkIn = 10000
VidSrc.MarkOut = 25000
AudSrc.MarkOut = 25000

' Initialize the encoder engine.

SrcGrp.PrepareToEncode (True)

See Also

  • IWMEncSource.GetInput
  • IWMEncSource Object


IWMEncSourceGroup Object

The IWMEncSourceGroup object manages a source group of media streams. Currently, a source group can contain no more than one audio, one script and one video stream. Only one source group can be encoded at a time, and a source group can be associated with only one profile. The IWMEncSourceGroup object exposes the following properties and methods.

Property | Description
AutoArchive | Specifies and retrieves an enumeration type that indicates the nature of the archiving operation if WMEncoder.EnableAutoArchive is set to True.
GroupTransformCollection | Retrieves a collection of group level transform plug-ins for the source group.
Name | Specifies and retrieves the name of the source group.
Profile | Specifies and retrieves the profile for the source group.
Source | Retrieves a specific media stream from the source group
SourceCount | Retrieves the number of streams of a specific type in the source group. Currently, this cannot exceed three.

Method | Description
AddSource | Adds a media stream to the source group.
AutoSetFileSource | Automatically parses a multimedia file and adds up to one audio and one video stream from that file to the source group.
GetGroupTransformPlugin | Retrieves a specific group level transform plug-in.
GetGroupTransformPluginCount | Retrieves the number of transform plug-ins that can be applied to the source group.
PrepareToEncode | Creates an encoding session and initializes Windows Media Encoder.
RemoveSource | Removes a media stream from the source group.

See Also

  • [Visual C++] IWMEncSourceGroup Interface
  • Objects (Visual Basic)


IWMEncSourceGroup.AutoArchive

The AutoArchive property specifies and retrieves an enumeration type that indicates the nature of the archiving operation if WMEncoder.EnableAutoArchive is set to True.

Syntax

IWMEncSourceGroup.AutoArchive(enumArchiveType) = WMENC_ARCHIVE_OPERATION
WMENC_ARCHIVE_OPERATION = IWMEncSourceGroup.AutoArchive(enumArchiveType)

Parameters

enumArchiveType

[in] Specifies a WMENC_ARCHIVE_TYPE enumeration type indicating where content can be archived. This must be the following value.

Value | Number | Description
WMENC_ARCHIVE_LOCAL | 1 | The encoded content can only be saved to a local destination defined as the computer on which the content was originated and the network on which that computer is located.

Return Values

When getting the value, this property returns a WMENC_ARCHIVE_OPERATION enumeration type indicating whether encoded content will be archived when the source group is made active and the encoder engine starts. This must be one of the following values.

Value | Number | Description
WMENC_ARCHIVE_START | 1 | The encoded content from the source group will be archived.
WMENC_ARCHIVE_STOP | 2 | The archiving process for the source group is stopped.
WMENC_ARCHIVE_PAUSE | 3 | The archiving process for the source group will be paused.

If this property fails, it returns an error number.

Number | Meaning
0xC00D1B77 | You can save encoded content only to a local file.
0xC00D1B78 | You can only start, stop, or pause the archiving process.

Remarks

Use the AutoArchive property to selectively archive source groups. For instance, if you are encoding a static welcome screen, a live presentation and a static goodbye screen, you can utilize disk space more efficiently by only archiving the live presentation. Use the WMEncoder.EnableAutoArchive property to specify whether archiving will automatically occur when the encoder engine starts. Use the WMEncoder.Archive method to manually control the archiving process. If both the EnableAutoArchive and AutoArchive properties are set to True, archiving automatically starts when encoding of the relevant source group starts.

Example Code

' Create a WMEncoder object.
Dim Encoder As WMEncoder
Set Encoder = New WMEncoder

' Declare objects and variables.
Dim SrcGrpColl As IWMEncSourceGroupCollection
Dim SrcGrp As IWMEncSourceGroup
Dim AudSrc As IWMEncSource
Dim VidSrc As IWMEncVideoSource
Dim ProColl As IWMEncProfileCollection
Dim Pro As IWMEncProfile
Dim i As Integer
Dim iAudCount As Integer
Dim iVidCount As Integer

' Create an IWMEncSourceGroupCollection object.
Set SrcGrpColl = Encoder.SourceGroupCollection

' Create an IWMEncSourceGroup object.
Set SrcGrp = SrcGrpColl.Add("SG_1")

' Create a video and an audio source object.
Set AudSrc = SrcGrp.AddSource(WMENC_AUDIO)
Set VidSrc = SrcGrp.AddSource(WMENC_VIDEO)

' Specify the .avi source file.
AudSrc.SetInput "C:\filename.avi"
VidSrc.SetInput "C:\filename.avi"

' You can also use the AutoSetFileSource property to
' automatically parse a file and add the source streams
' to the source group.
'
'    SrcGrp.AutoSetFileSource ("C:\filename.avi")

' Loop through the collection of system profiles to set
' a specific profile into the source group object.

Set ProColl = Encoder.ProfileCollection
For i = 0 To ProColl.Count - 1
    Set Pro = ProColl.Item(i)
    If Pro.Name = "profile name" Then
        SrcGrp.Profile = Pro
        Exit For
    End If
Next

' Change the name of the source group.
SrcGrp.Name = "Music Only"

' Retrieve the number of audio and video streams
' in the source group.
iAudCount = SrcGrp.SourceCount(WMENC_AUDIO)
iVidCount = SrcGrp.SourceCount(WMENC_VIDEO)

' Remove the video stream. In the current release of the
' Windows Media Encoder SDK, a source group can contain
' at most only one audio, one video, and one script stream.
' You must verify that the count is not zero before deleting
' the source stream.
If iVidCount <> 0 Then
    SrcGrp.RemoveSource WMENC_VIDEO, 0
End If

' Specify automatic archiving when the source group
' is active.
SrcGrp.AutoArchive(WMENC_ARCHIVE_LOCAL) = WMENC_ARCHIVE_START

' Initialize the encoder engine.
SrcGrp.PrepareToEncode True

See Also

  • IWMEncSourceGroup Object
  • WMEncoder.Archive
  • WMEncoder.EnableAutoArchive


IWMEncSourceGroup.GroupTransformCollection

The GroupTransformCollection property retrieves a collection of group level transform plug-ins for the source group.

Syntax

IWMEncTransformCollection = IWMEncSourceGroup.GroupTransformCollection

Parameters

This property takes no parameters.

Return Values

When getting the value, this property returns an IWMEncTransformCollection object

Remarks

This property is read-only.

See Also

  • IWMEncSourceGroup Object
  • IWMEncTransformCollection Object


IWMEncSourceGroup.Name

The Name property specifies and retrieves the name of the source group.

Syntax

IWMEncSourceGroup.Name = BSTR
BSTR = IWMEncSourceGroup.Name

Parameters

This property takes no parameters.

Return Values

When getting the value, this property returns a BSTR string containing the source group name.

Example Code

' Create a WMEncoder object.
Dim Encoder As WMEncoder
Set Encoder = New WMEncoder

' Declare objects and variables.
Dim SrcGrpColl As IWMEncSourceGroupCollection
Dim SrcGrp As IWMEncSourceGroup
Dim AudSrc As IWMEncSource
Dim VidSrc As IWMEncVideoSource
Dim ProColl As IWMEncProfileCollection
Dim Pro As IWMEncProfile
Dim i As Integer
Dim iAudCount As Integer
Dim iVidCount As Integer

' Create an IWMEncSourceGroupCollection object.
Set SrcGrpColl = Encoder.SourceGroupCollection

' Create an IWMEncSourceGroup object.
Set SrcGrp = SrcGrpColl.Add("SG_1")

' Create a video and an audio source object.
Set AudSrc = SrcGrp.AddSource(WMENC_AUDIO)
Set VidSrc = SrcGrp.AddSource(WMENC_VIDEO)

' Specify the .avi source file.
AudSrc.SetInput "C:\filename.avi"
VidSrc.SetInput "C:\filename.avi"

' You can also use the AutoSetFileSource property to
' automatically parse a file and add the source streams
' to the source group.
'
'    SrcGrp.AutoSetFileSource ("C:\filename.avi")

' Loop through the collection of system profiles to set
' a specific profile into the source group object.

Set ProColl = Encoder.ProfileCollection
For i = 0 To ProColl.Count - 1
    Set Pro = ProColl.Item(i)
    If Pro.Name = "profile name" Then
        SrcGrp.Profile = Pro
        Exit For
    End If
Next

' Change the name of the source group.
SrcGrp.Name = "Music Only"

' Retrieve the number of audio and video streams
' in the source group.
iAudCount = SrcGrp.SourceCount(WMENC_AUDIO)
iVidCount = SrcGrp.SourceCount(WMENC_VIDEO)

' Remove the video stream. In the current release of the
' Windows Media Encoder SDK, a source group can contain
' at most only one audio, one video, and one script stream.
' You must verify that the count is not zero before deleting
' the source stream.
If iVidCount <> 0 Then
    SrcGrp.RemoveSource WMENC_VIDEO, 0
End If

' Specify automatic archiving when the source group
' is active.
SrcGrp.AutoArchive(WMENC_ARCHIVE_LOCAL) = WMENC_ARCHIVE_START

' Initialize the encoder engine.
SrcGrp.PrepareToEncode True

See Also

  • IWMEncSourceGroup Object


IWMEncSourceGroup.Profile

The Profile property specifies and retrieves a profile for the source group.

Syntax

IWMEncSourceGroup.Profile = IWMEncProfile
IWMEncProfile = IWMEncSourceGroup.Profile

Parameters

This property takes no parameters.

Return Values

When getting the value, this property returns a profile object.

If this property fails, it returns an error number.

Number | Meaning
0xC00D1B67 | You must specify a profile for the source group.
0xC00D0011 | This method cannot be called if the encoder engine is running.
0xC00D1B5F | The media content defined in the profile does not match the media content defined in the source group.

Remarks

Only one profile at a time can be associated with a source group. The system contains several predefined profiles, which cannot be either removed or changed. You can use the IWMEncProfileManager object to create the Profile Manager dialog boxes that edit and list profiles, and you can use C++ and the Windows Media Format SDK to create a custom profile. When setting a profile, you can specify any of the following:

  • A string specifying the path and name of a profile. File names must end with a .prx file name extension.
  • An index into the profile collection.
  • A WMEncProfile object.

Example Code

' Create a WMEncoder object.
Dim Encoder As WMEncoder
Set Encoder = New WMEncoder

' Declare objects and variables.
Dim SrcGrpColl As IWMEncSourceGroupCollection
Dim SrcGrp As IWMEncSourceGroup
Dim AudSrc As IWMEncSource
Dim VidSrc As IWMEncVideoSource
Dim ProColl As IWMEncProfileCollection
Dim Pro As IWMEncProfile
Dim i As Integer
Dim iAudCount As Integer
Dim iVidCount As Integer

' Create an IWMEncSourceGroupCollection object.
Set SrcGrpColl = Encoder.SourceGroupCollection

' Create an IWMEncSourceGroup object.
Set SrcGrp = SrcGrpColl.Add("SG_1")

' Create a video and an audio source object.
Set AudSrc = SrcGrp.AddSource(WMENC_AUDIO)
Set VidSrc = SrcGrp.AddSource(WMENC_VIDEO)

' Specify the .avi source file.
AudSrc.SetInput "C:\filename.avi"
VidSrc.SetInput "C:\filename.avi"

' You can also use the AutoSetFileSource property to
' automatically parse a file and add the source streams
' to the source group.
'
'    SrcGrp.AutoSetFileSource ("C:\filename.avi")

' Loop through the collection of system profiles to set
' a specific profile into the source group object.

Set ProColl = Encoder.ProfileCollection
For i = 0 To ProColl.Count - 1
    Set Pro = ProColl.Item(i)
    If Pro.Name = "profile name" Then
        SrcGrp.Profile = Pro
        Exit For
    End If
Next

' Change the name of the source group.
SrcGrp.Name = "Music Only"

' Retrieve the number of audio and video streams
' in the source group.
iAudCount = SrcGrp.SourceCount(WMENC_AUDIO)
iVidCount = SrcGrp.SourceCount(WMENC_VIDEO)

' Remove the video stream. In the current release of the
' Windows Media Encoder SDK, a source group can contain
' at most only one audio, one video, and one script stream.
' You must verify that the count is not zero before deleting
' the source stream.
If iVidCount <> 0 Then
    SrcGrp.RemoveSource WMENC_VIDEO, 0
End If

' Specify automatic archiving when the source group
' is active.
SrcGrp.AutoArchive(WMENC_ARCHIVE_LOCAL) = WMENC_ARCHIVE_START

' Initialize the encoder engine.
SrcGrp.PrepareToEncode True

See Also

  • IWMEncProfileManager Object
  • IWMEncSourceGroup Object


IWMEncSourceGroup.Source

The Source property retrieves a specific media stream from the source group.

Syntax

IWMEncSource = IWMEncSourceGroup.Source( enumType, iIndex )

Parameters

enumType

[in] Member of a WMENC_SOURCE_TYPE enumeration type identifying the type of source stream. This parameter must take one of the following values.

Value | Number | Meaning
WMENC_AUDIO | 1 | Identifies an audio stream.
WMENC_VIDEO | 2 | Identifies a video stream.
WMENC_SCRIPT | 4 | Identifies a text stream

iIndex

[in] SHORT containing an index used to identify a stream when multiple streams of the same type exist. Since a source group cannot currently support multiple streams of the same type, this parameter must be zero.

Return Values

When getting the value, this property returns an IWMEncSource object.

If this property fails, it returns an error number.

Number | Meaning
0xC00D1B5A | No matching media source is found in source group.

Remarks

This property is read-only.

Example Code

' Create a WMEncoder object.
Dim Encoder As WMEncoder
Set Encoder = New WMEncoder

' Declare objects and variables.
Dim SrcGrpColl As IWMEncSourceGroupCollection
Dim SrcGrp As IWMEncSourceGroup
Dim AudSrc As IWMEncSource
Dim VidSrc As IWMEncVideoSource
Dim ProColl As IWMEncProfileCollection
Dim Pro As IWMEncProfile
Dim i As Integer
Dim iAudCount As Integer
Dim iVidCount As Integer

' Create an IWMEncSourceGroupCollection object.
Set SrcGrpColl = Encoder.SourceGroupCollection

' Create an IWMEncSourceGroup object.
Set SrcGrp = SrcGrpColl.Add("SG_1")

' Create a video and an audio source object.
Set AudSrc = SrcGrp.AddSource(WMENC_AUDIO)
Set VidSrc = SrcGrp.AddSource(WMENC_VIDEO)

' Specify the .avi source file.
AudSrc.SetInput "C:\filename.avi"
VidSrc.SetInput "C:\filename.avi"

' You can also use the AutoSetFileSource property to
' automatically parse a file and add the source streams
' to the source group.
'
'    SrcGrp.AutoSetFileSource ("C:\filename.avi")

' Loop through the collection of system profiles to set
' a specific profile into the source group object.

Set ProColl = Encoder.ProfileCollection
For i = 0 To ProColl.Count - 1
    Set Pro = ProColl.Item(i)
    If Pro.Name = "profile name" Then
        SrcGrp.Profile = Pro
        Exit For
    End If
Next

' Change the name of the source group.
SrcGrp.Name = "Music Only"

' Retrieve the number of audio and video streams
' in the source group.
iAudCount = SrcGrp.SourceCount(WMENC_AUDIO)
iVidCount = SrcGrp.SourceCount(WMENC_VIDEO)

' Remove the video stream. In the current release of the
' Windows Media Encoder SDK, a source group can contain
' at most only one audio, one video, and one script stream.
' You must verify that the count is not zero before deleting
' the source stream.
If iVidCount <> 0 Then
    SrcGrp.RemoveSource WMENC_VIDEO, 0
End If

' Specify automatic archiving when the source group
' is active.
SrcGrp.AutoArchive(WMENC_ARCHIVE_LOCAL) = WMENC_ARCHIVE_START

' Initialize the encoder engine.
SrcGrp.PrepareToEncode True

See Also

  • IWMEncSourceGroup.AddSource
  • IWMEncSourceGroup Object
  • IWMEncSourceGroup.RemoveSource
  • IWMEncSourceGroup.SourceCount


IWMEncSourceGroup.SourceCount

The SourceCount property retrieves the number of streams of a specific type in the source group.

Syntax

Short = IWMEncSourceGroup.SourceCount( enumType )

Parameters

enumType

[in] Member of a WMENC_SOURCE_TYPE enumeration type identifying the stream type. This parameter must be one of the following values.

Return code | Number | Meaning
WMENC_AUDIO | 1 | Identifies an audio stream.
WMENC_VIDEO | 2 | Identifies a video stream.
WMENC_SCRIPT | 4 | Identifies a text stream.

Return Values

When getting the value, this property returns a SHORT containing the number of enumType streams.

Remarks

This property is read-only. A source group can currently contain one audio, one video, and one script stream. Therefore, SourceCount can return either 0 or 1.

Example Code

' Create a WMEncoder object.
Dim Encoder As WMEncoder
Set Encoder = New WMEncoder

' Declare objects and variables.
Dim SrcGrpColl As IWMEncSourceGroupCollection
Dim SrcGrp As IWMEncSourceGroup
Dim AudSrc As IWMEncSource
Dim VidSrc As IWMEncVideoSource
Dim ProColl As IWMEncProfileCollection
Dim Pro As IWMEncProfile
Dim i As Integer
Dim iAudCount As Integer
Dim iVidCount As Integer

' Create an IWMEncSourceGroupCollection object.
Set SrcGrpColl = Encoder.SourceGroupCollection

' Create an IWMEncSourceGroup object.
Set SrcGrp = SrcGrpColl.Add("SG_1")

' Create a video and an audio source object.
Set AudSrc = SrcGrp.AddSource(WMENC_AUDIO)
Set VidSrc = SrcGrp.AddSource(WMENC_VIDEO)

' Specify the .avi source file.
AudSrc.SetInput "C:\filename.avi"
VidSrc.SetInput "C:\filename.avi"

' You can also use the AutoSetFileSource property to
' automatically parse a file and add the source streams
' to the source group.
'
'    SrcGrp.AutoSetFileSource ("C:\filename.avi")

' Loop through the collection of system profiles to set
' a specific profile into the source group object.

Set ProColl = Encoder.ProfileCollection
For i = 0 To ProColl.Count - 1
    Set Pro = ProColl.Item(i)
    If Pro.Name = "profile name" Then
        SrcGrp.Profile = Pro
        Exit For
    End If
Next

' Change the name of the source group.
SrcGrp.Name = "Music Only"

' Retrieve the number of audio and video streams
' in the source group.
iAudCount = SrcGrp.SourceCount(WMENC_AUDIO)
iVidCount = SrcGrp.SourceCount(WMENC_VIDEO)

' Remove the video stream. In the current release of the
' Windows Media Encoder SDK, a source group can contain
' at most only one audio, one video, and one script stream.
' You must verify that the count is not zero before deleting
' the source stream.
If iVidCount <> 0 Then
    SrcGrp.RemoveSource WMENC_VIDEO, 0
End If

' Specify automatic archiving when the source group
' is active.
SrcGrp.AutoArchive(WMENC_ARCHIVE_LOCAL) = WMENC_ARCHIVE_START

' Initialize the encoder engine.
SrcGrp.PrepareToEncode True

See Also

  • IWMEncSourceGroup Object
  • IWMEncSourceGroup.Source


IWMEncSourceGroup.AddSource

The AddSource method adds a media stream to the source group.

Syntax

IWMEncSource = IWMEncSourceGroup.AddSource( enumType )

Parameters

enumType

[in] Member of a WMENC_SOURCE_TYPE enumeration type identifying the type of the media stream being added. This must be one of the following values.

Value | Number | Meaning
WMENC_AUDIO | 1 | The source being added is an audio stream.
WMENC_VIDEO | 2 | The source being added is a video stream.
WMENC_SCRIPT | 4 | The source being added is a script stream.

Return Values

This method returns an IWMEncSource object.

If this method fails, it returns an error number.

Number | Meaning
0x8007000E | Memory cannot be allocated
0xC00D0011 | This method cannot be called if the encoder engine is running.
0xC00D1B5B | The input source type must be either audio, video, or script.

Remarks

Only one audio, one video, and one script stream can be added to a source group.

Example Code

' Create a WMEncoder object.
Dim Encoder As WMEncoder
Set Encoder = New WMEncoder

' Declare objects and variables.
Dim SrcGrpColl As IWMEncSourceGroupCollection
Dim SrcGrp As IWMEncSourceGroup
Dim AudSrc As IWMEncSource
Dim VidSrc As IWMEncVideoSource
Dim ProColl As IWMEncProfileCollection
Dim Pro As IWMEncProfile
Dim i As Integer
Dim iAudCount As Integer
Dim iVidCount As Integer

' Create an IWMEncSourceGroupCollection object.
Set SrcGrpColl = Encoder.SourceGroupCollection

' Create an IWMEncSourceGroup object.
Set SrcGrp = SrcGrpColl.Add("SG_1")

' Create a video and an audio source object.
Set AudSrc = SrcGrp.AddSource(WMENC_AUDIO)
Set VidSrc = SrcGrp.AddSource(WMENC_VIDEO)

' Specify the .avi source file.
AudSrc.SetInput "C:\filename.avi"
VidSrc.SetInput "C:\filename.avi"

' You can also use the AutoSetFileSource property to
' automatically parse a file and add the source streams
' to the source group.
'
'    SrcGrp.AutoSetFileSource ("C:\filename.avi")

' Loop through the collection of system profiles to set
' a specific profile into the source group object.

Set ProColl = Encoder.ProfileCollection
For i = 0 To ProColl.Count - 1
    Set Pro = ProColl.Item(i)
    If Pro.Name = "profile name" Then
        SrcGrp.Profile = Pro
        Exit For
    End If
Next

' Change the name of the source group.
SrcGrp.Name = "Music Only"

' Retrieve the number of audio and video streams
' in the source group.
iAudCount = SrcGrp.SourceCount(WMENC_AUDIO)
iVidCount = SrcGrp.SourceCount(WMENC_VIDEO)

' Remove the video stream. In the current release of the
' Windows Media Encoder SDK, a source group can contain
' at most only one audio, one video, and one script stream.
' You must verify that the count is not zero before deleting
' the source stream.
If iVidCount <> 0 Then
    SrcGrp.RemoveSource WMENC_VIDEO, 0
End If

' Specify automatic archiving when the source group
' is active.
SrcGrp.AutoArchive(WMENC_ARCHIVE_LOCAL) = WMENC_ARCHIVE_START

' Initialize the encoder engine.
SrcGrp.PrepareToEncode True

See Also

  • IWMEncSourceGroup Object
  • IWMEncSourceGroup.RemoveSource
  • IWMEncSourceGroup.Source


IWMEncSourceGroup.AutoSetFileSource

The AutoSetFileSource method automatically parses a multimedia file and adds up to one audio and one video stream from that file to the source group.

Syntax

IWMEncSourceGroup.AutoSetFileSource bstrFileName

Parameters

This method takes no parameters.

Return Values

If this method fails, it returns an error number.

Number | Meaning
0x80070057 | The string identifying the file name is NULL.
0xC00D0011 | This method cannot be called if the encoder engine is running.

Example Code

' Create a WMEncoder object.
Dim Encoder As WMEncoder
Set Encoder = New WMEncoder

' Declare objects and variables.
Dim SrcGrpColl As IWMEncSourceGroupCollection
Dim SrcGrp As IWMEncSourceGroup
Dim AudSrc As IWMEncSource
Dim VidSrc As IWMEncVideoSource
Dim ProColl As IWMEncProfileCollection
Dim Pro As IWMEncProfile
Dim i As Integer
Dim iAudCount As Integer
Dim iVidCount As Integer

' Create an IWMEncSourceGroupCollection object.
Set SrcGrpColl = Encoder.SourceGroupCollection

' Create an IWMEncSourceGroup object.
Set SrcGrp = SrcGrpColl.Add("SG_1")

' Create a video and an audio source object.
Set AudSrc = SrcGrp.AddSource(WMENC_AUDIO)
Set VidSrc = SrcGrp.AddSource(WMENC_VIDEO)

' Specify the .avi source file.
AudSrc.SetInput "C:\filename.avi"
VidSrc.SetInput "C:\filename.avi"

' You can also use the AutoSetFileSource property to
' automatically parse a file and add the source streams
' to the source group.
'
'    SrcGrp.AutoSetFileSource ("C:\filename.avi")

' Loop through the collection of system profiles to set
' a specific profile into the source group object.

Set ProColl = Encoder.ProfileCollection
For i = 0 To ProColl.Count - 1
    Set Pro = ProColl.Item(i)
    If Pro.Name = "profile name" Then
        SrcGrp.Profile = Pro
        Exit For
    End If
Next

' Change the name of the source group.
SrcGrp.Name = "Music Only"

' Retrieve the number of audio and video streams
' in the source group.
iAudCount = SrcGrp.SourceCount(WMENC_AUDIO)
iVidCount = SrcGrp.SourceCount(WMENC_VIDEO)

' Remove the video stream. In the current release of the
' Windows Media Encoder SDK, a source group can contain
' at most only one audio, one video, and one script stream.
' You must verify that the count is not zero before deleting
' the source stream.
If iVidCount <> 0 Then
    SrcGrp.RemoveSource WMENC_VIDEO, 0
End If

' Specify automatic archiving when the source group
' is active.
SrcGrp.AutoArchive(WMENC_ARCHIVE_LOCAL) = WMENC_ARCHIVE_START

' Initialize the encoder engine.
SrcGrp.PrepareToEncode True

See Also

  • IWMEncSourceGroup Object


IWMEncSourceGroup.GetGroupTransformPlugin

The GetGroupTransformPlugin method retrieves a specific group level transform plug-in.

Syntax

IUnknown = IWMEncSourceGroup.GetGroupTransformPlugin(dwIndex)

Parameters

dwIndex

[in] DWORD containing the index of the plug-in to retrieve.

Return Values

This method returns an GroupTransformPlugin object.

If this method fails, it returns an error number.

Number | Meaning
0xC00D002 | The request is not valid for the current state of the encoder engine.

See Also

  • IWMEncSourceGroup.GetGroupTransformPluginCount
  • IWMEncSourceGroup Object


IWMEncSourceGroup.GetGroupTransformPluginCount

The GetGroupTransformPluginCount method retrieves the number of transform plug-ins that can be applied to the source group.

Syntax

DWORD = IWMEncSourceGroup.GetGroupTransformPluginCount

Parameters

This method takes no parameters.

Return Values

This method returns a DWORD containing the count.

See Also

  • IWMEncSourceGroup Object


IWMEncSourceGroup.PrepareToEncode

The PrepareToEncode method initializes the source group in the encoding session.

Syntax

IWMEncSourceGroup.PrepareToEncode bPrepare

Parameters

bPrepare

[in] VARIANT_BOOL indicating whether to initialize an encoding session.

Return Values

If this method fails, it returns an error number.

Number | Meaning
0x8007000E | Memory cannot be allocated.
0xC00D0011 | This method cannot be called if the encoder engine is running.
0xC00D002 | The request is not valid for the current state of the encoder engine.
0xC00D1B67 | You must specify a profile for the source group.

Remarks

You can use this method to prepare the encoding session on a source group by source group basis. You can also use this method during a running encoding session to create and initialize source groups without affecting the operation of the encoder engine.

Example Code

' Create a WMEncoder object.
Dim Encoder As WMEncoder
Set Encoder = New WMEncoder

' Declare objects and variables.
Dim SrcGrpColl As IWMEncSourceGroupCollection
Dim SrcGrp As IWMEncSourceGroup
Dim AudSrc As IWMEncSource
Dim VidSrc As IWMEncVideoSource
Dim ProColl As IWMEncProfileCollection
Dim Pro As IWMEncProfile
Dim i As Integer
Dim iAudCount As Integer
Dim iVidCount As Integer

' Create an IWMEncSourceGroupCollection object.
Set SrcGrpColl = Encoder.SourceGroupCollection

' Create an IWMEncSourceGroup object.
Set SrcGrp = SrcGrpColl.Add("SG_1")

' Create a video and an audio source object.
Set AudSrc = SrcGrp.AddSource(WMENC_AUDIO)
Set VidSrc = SrcGrp.AddSource(WMENC_VIDEO)

' Specify the .avi source file.
AudSrc.SetInput "C:\filename.avi"
VidSrc.SetInput "C:\filename.avi"

' You can also use the AutoSetFileSource property to
' automatically parse a file and add the source streams
' to the source group.
'
'    SrcGrp.AutoSetFileSource ("C:\filename.avi")

' Loop through the collection of system profiles to set
' a specific profile into the source group object.

Set ProColl = Encoder.ProfileCollection
For i = 0 To ProColl.Count - 1
    Set Pro = ProColl.Item(i)
    If Pro.Name = "profile name" Then
        SrcGrp.Profile = Pro
        Exit For
    End If
Next

' Change the name of the source group.
SrcGrp.Name = "Music Only"

' Retrieve the number of audio and video streams
' in the source group.
iAudCount = SrcGrp.SourceCount(WMENC_AUDIO)
iVidCount = SrcGrp.SourceCount(WMENC_VIDEO)

' Remove the video stream. In the current release of the
' Windows Media Encoder SDK, a source group can contain
' at most only one audio, one video, and one script stream.
' You must verify that the count is not zero before deleting
' the source stream.
If iVidCount <> 0 Then
    SrcGrp.RemoveSource WMENC_VIDEO, 0
End If

' Specify automatic archiving when the source group
' is active.
SrcGrp.AutoArchive(WMENC_ARCHIVE_LOCAL) = WMENC_ARCHIVE_START

' Initialize the encoder engine.
SrcGrp.PrepareToEncode True

See Also

  • IWMEncSourceGroup Object
  • WMEncoder Object
  • WMEncoder.Start


IWMEncSourceGroup.RemoveSource

The RemoveSource method removes a media stream from the source group.

Syntax

IWMEncSourceGroup.RemoveSource enumType, var

Parameters

enumType

[in] Member of a WMENC_SOURCE_TYPE enumeration type identifying the type of the media stream being added as one of the following values.

Value | Number | Meaning
WMENC_AUDIO | 1 | Identifies an audio stream.
WMENC_VIDEO | 2 | Identifies a video stream.
WMENC_SCRIPT | 4 | Identifies a text stream.

varIndex

[in] VARIANT containing the index of the media source. Each type of media stream has a separate index. In the current release of the Windows Media Encoder SDK, all index values must be zero (0).

Return Values

If this method fails, it returns an error number.

Number | Meaning
0xC00D0011 | This method cannot be called if the encoder engine is running.
0xC00D1B5F | The media content defined in the profile does not match the media content defined in the source group.

Example Code

' Create a WMEncoder object.
Dim Encoder As WMEncoder
Set Encoder = New WMEncoder

' Declare objects and variables.
Dim SrcGrpColl As IWMEncSourceGroupCollection
Dim SrcGrp As IWMEncSourceGroup
Dim AudSrc As IWMEncSource
Dim VidSrc As IWMEncVideoSource
Dim ProColl As IWMEncProfileCollection
Dim Pro As IWMEncProfile
Dim i As Integer
Dim iAudCount As Integer
Dim iVidCount As Integer

' Create an IWMEncSourceGroupCollection object.
Set SrcGrpColl = Encoder.SourceGroupCollection

' Create an IWMEncSourceGroup object.
Set SrcGrp = SrcGrpColl.Add("SG_1")

' Create a video and an audio source object.
Set AudSrc = SrcGrp.AddSource(WMENC_AUDIO)
Set VidSrc = SrcGrp.AddSource(WMENC_VIDEO)

' Specify the .avi source file.
AudSrc.SetInput "C:\filename.avi"
VidSrc.SetInput "C:\filename.avi"

' You can also use the AutoSetFileSource property to
' automatically parse a file and add the source streams
' to the source group.
'
'    SrcGrp.AutoSetFileSource ("C:\filename.avi")

' Loop through the collection of system profiles to set
' a specific profile into the source group object.

Set ProColl = Encoder.ProfileCollection
For i = 0 To ProColl.Count - 1
    Set Pro = ProColl.Item(i)
    If Pro.Name = "profile name" Then
        SrcGrp.Profile = Pro
        Exit For
    End If
Next

' Change the name of the source group.
SrcGrp.Name = "Music Only"

' Retrieve the number of audio and video streams
' in the source group.
iAudCount = SrcGrp.SourceCount(WMENC_AUDIO)
iVidCount = SrcGrp.SourceCount(WMENC_VIDEO)

' Remove the video stream. In the current release of the
' Windows Media Encoder SDK, a source group can contain
' at most only one audio, one video, and one script stream.
' You must verify that the count is not zero before deleting
' the source stream.
If iVidCount <> 0 Then
    SrcGrp.RemoveSource WMENC_VIDEO, 0
End If

' Specify automatic archiving when the source group
' is active.
SrcGrp.AutoArchive(WMENC_ARCHIVE_LOCAL) = WMENC_ARCHIVE_START

' Initialize the encoder engine.
SrcGrp.PrepareToEncode True

See Also

  • IWMEncSourceGroup.AddSource
  • IWMEncSourceGroup Object
  • IWMEncSourceGroup.Source


IWMEncSourceGroupCollection Object

The IWMEncSourceGroupCollection object contains the enumerated source groups that are available to an encoding session. The IWMEncSourceGroupCollection object exposes the following properties and methods.

Property | Description
Active | Specifies and retrieves the active source group.
Count | Retrieves the number of source groups in the source group collection.
length | Retrieves the number of source groups in the source group collection. This is the JScript version of Count.

Method | Description
Add | Appends a new source group to the collection.
Item | Retrieves the source group identified by a specific integer index.
Move | Repositions a given source group directly in front of another in the collection.
Remove | Removes a source group from the collection.

See Also

  • Visual C++] IWMEncSourceGroupCollection Interface
  • Objects (Visual Basic)


IWMEncSourceGroupCollection.Active

The Active property specifies and retrieves the active source group.

Syntax

IWMEncSourceGroupCollection.Active = IWMEncSourceGroup
IWMEncSourceGroup = IWMEncSourceGroupCollection.Active

Parameters

This property takes no parameters.

Return Values

When getting the value, this property returns an IWMEncSourceGroup object.

If this property fails, it returns an error number.

Number | Meaning
0xC00D1B72 | No source group is currently active.

Remarks

The active source group is the one currently being encoded. Only one source group can be active at a time.

Example Code

' Create a WMEncoder object.
Dim Encoder As WMEncoder
Set Encoder = New WMEncoder

' Declare objects and variables.
Dim SrcGrpColl As IWMEncSourceGroupCollection
Dim SrcGrp As IWMEncSourceGroup
Dim SrcGrp1 As IWMEncSourceGroup
Dim SrcGrp2 As IWMEncSourceGroup
Dim SrcGrp3 As IWMEncSourceGroup
Dim i As Integer

' Create an IWMEncSourceGroupCollection object.
Set SrcGrpColl = Encoder.SourceGroupCollection

' Add new source groups to the collection.
Set SrcGrp1 = SrcGrpColl.Add("SG_1")
Set SrcGrp2 = SrcGrpColl.Add("SG_2")
Set SrcGrp3 = SrcGrpColl.Add("SG_3")

' Loop through the collection to find a specific
' source group.
For i = 0 To SrcGrpColl.Count - 1
    Set SrcGrp = SrcGrpColl.Item(i)
    If SrcGrp.Name = "SG_3" Then
        ' Move SrcGrp3 in front of SrcGrp1.
        SrcGrpColl.Move SrcGrp3, SrcGrp1
        ' Make ScrGrp3 active.
        SrcGrpColl.Active = SrcGrp3
    End If
Next

' Remove SrcGrp2, by index, from the collection.
SrcGrpColl.Remove 2

See Also

  • IWMEncSourceGroup Object
  • IWMEncSourceGroupCollection Object


IWMEncSourceGroupCollection.Count

The Count property retrieves the number of source groups in the collection.

Syntax

Long = IWMEncSourceGroupCollection.Count

Parameters

This property takes no parameters.

Return Values

This property returns a LONG containing the number of source groups in the collection.

Remarks

This property is read-only. This method is the Visual Basic version of the JScript IWMEncSourceGroupCollection.length method.

Example Code

' Create a WMEncoder object.
Dim Encoder As WMEncoder
Set Encoder = New WMEncoder

' Declare objects and variables.
Dim SrcGrpColl As IWMEncSourceGroupCollection
Dim SrcGrp As IWMEncSourceGroup
Dim SrcGrp1 As IWMEncSourceGroup
Dim SrcGrp2 As IWMEncSourceGroup
Dim SrcGrp3 As IWMEncSourceGroup
Dim i As Integer

' Create an IWMEncSourceGroupCollection object.
Set SrcGrpColl = Encoder.SourceGroupCollection

' Add new source groups to the collection.
Set SrcGrp1 = SrcGrpColl.Add("SG_1")
Set SrcGrp2 = SrcGrpColl.Add("SG_2")
Set SrcGrp3 = SrcGrpColl.Add("SG_3")

' Loop through the collection to find a specific
' source group.
For i = 0 To SrcGrpColl.Count - 1
    Set SrcGrp = SrcGrpColl.Item(i)
    If SrcGrp.Name = "SG_3" Then
        ' Move SrcGrp3 in front of SrcGrp1.
        SrcGrpColl.Move SrcGrp3, SrcGrp1
        ' Make ScrGrp3 active.
        SrcGrpColl.Active = SrcGrp3
    End If
Next

' Remove SrcGrp2, by index, from the collection.
SrcGrpColl.Remove 2

See Also

  • IWMEncSourceGroupCollection.length
  • IWMEncSourceGroupCollection Object


IWMEncSourceGroupCollection.length

The length property retrieves the number of source groups in the collection.

Syntax

Long = IWMEncSourceGroupCollection.length

Parameters

This property takes no parameters.

Return Values

This property returns a LONG containing the number of source groups in the collection.

Remarks

This method performs the same action as the IWMEncSourceGroupCollection.Count method. It is included for JScript developers or developers more comfortable with JScript syntax.

Example Code

' Create a WMEncoder object.
Dim Encoder As WMEncoder
Set Encoder = New WMEncoder

' Declare objects and variables.
Dim SrcGrpColl As IWMEncSourceGroupCollection
Dim SrcGrp As IWMEncSourceGroup
Dim SrcGrp1 As IWMEncSourceGroup
Dim SrcGrp2 As IWMEncSourceGroup
Dim SrcGrp3 As IWMEncSourceGroup
Dim i As Integer

' Create an IWMEncSourceGroupCollection object.
Set SrcGrpColl = Encoder.SourceGroupCollection

' Add new source groups to the collection.
Set SrcGrp1 = SrcGrpColl.Add("SG_1")
Set SrcGrp2 = SrcGrpColl.Add("SG_2")
Set SrcGrp3 = SrcGrpColl.Add("SG_3")

' Loop through the collection to find a specific
' source group.
For i = 0 To SrcGrpColl.Count - 1
    Set SrcGrp = SrcGrpColl.Item(i)
    If SrcGrp.Name = "SG_3" Then
        ' Move SrcGrp3 in front of SrcGrp1.
        SrcGrpColl.Move SrcGrp3, SrcGrp1
        ' Make ScrGrp3 active.
        SrcGrpColl.Active = SrcGrp3
    End If
Next

' Remove SrcGrp2, by index, from the collection.
SrcGrpColl.Remove 2

See Also

  • IWMEncSourceGroupCollection.Count
  • IWMEncSourceGroupCollection Object


IWMEncSourceGroupCollection.Add

The Add method appends a new source group to the collection.

Syntax

IWMEncSourceGroup = IWMEncSourceGroupCollection.Add ( bstrName )

Parameters

bstrName

[in] BSTR containing the name of the source group to be added to the collection.

Return Values

This method returns an IWMEncSourceGroup object.

If this method fails, it returns an error number.

Number | Meaning
0x80070057 | The string containing the name of the source group cannot be empty.
0x8007000E | Memory cannot be allocated.

Remarks

The source group being added must be identified by a valid name assigned with the IWMEncSourceGroup.Name property. The Add method creates a source group object for the input name, adds the source group to the collection and returns the object to the caller. The IWMEncSourceGroupCollection.Item method can be used to retrieve a source group from the collection.

Example Code

' Create a WMEncoder object.
Dim Encoder As WMEncoder
Set Encoder = New WMEncoder

' Declare objects and variables.
Dim SrcGrpColl As IWMEncSourceGroupCollection
Dim SrcGrp As IWMEncSourceGroup
Dim SrcGrp1 As IWMEncSourceGroup
Dim SrcGrp2 As IWMEncSourceGroup
Dim SrcGrp3 As IWMEncSourceGroup
Dim i As Integer

' Create an IWMEncSourceGroupCollection object.
Set SrcGrpColl = Encoder.SourceGroupCollection

' Add new source groups to the collection.
Set SrcGrp1 = SrcGrpColl.Add("SG_1")
Set SrcGrp2 = SrcGrpColl.Add("SG_2")
Set SrcGrp3 = SrcGrpColl.Add("SG_3")

' Loop through the collection to find a specific
' source group.
For i = 0 To SrcGrpColl.Count - 1
    Set SrcGrp = SrcGrpColl.Item(i)
    If SrcGrp.Name = "SG_3" Then
        ' Move SrcGrp3 in front of SrcGrp1.
        SrcGrpColl.Move SrcGrp3, SrcGrp1
        ' Make ScrGrp3 active.
        SrcGrpColl.Active = SrcGrp3
    End If
Next

' Remove SrcGrp2, by index, from the collection.
SrcGrpColl.Remove 2

See Also

  • IWMEncSourceGroup Object
  • IWMEncSourceGroup.Name
  • IWMEncSourceGroupCollection.Item
  • IWMEncSourceGroupCollection Object
  • IWMEncSourceGroupCollection.Remove


IWMEncSourceGroupCollection.Item

The Item method retrieves the source group identified by a specific integer index within the source group collection.

Syntax

IWMEncSourceGroup = IWMEncSourceGroupCollection.Item ( var )

Parameters

var

[in] VARIANT containing either the index or name of the source group to retrieve.

Return Values

This method returns a source group object.

Remarks

The input parameter is either an integer index into the collection or a source group name. If a name is used, the first source group that matches the name is returned. If you don't already know the index associated with the needed source group pointer, you must iterate through the collection starting at item 0. On each iteration increment the index and use the Item method to retrieve a source group object. Call the IWMEncSourceGroup.Name to find the name of the source group being pointed to and compare the name retrieved to that needed. Exit the loop when a match is found.

Example Code

' Create a WMEncoder object.
Dim Encoder As WMEncoder
Set Encoder = New WMEncoder

' Declare objects and variables.
Dim SrcGrpColl As IWMEncSourceGroupCollection
Dim SrcGrp As IWMEncSourceGroup
Dim SrcGrp1 As IWMEncSourceGroup
Dim SrcGrp2 As IWMEncSourceGroup
Dim SrcGrp3 As IWMEncSourceGroup
Dim i As Integer

' Create an IWMEncSourceGroupCollection object.
Set SrcGrpColl = Encoder.SourceGroupCollection

' Add new source groups to the collection.
Set SrcGrp1 = SrcGrpColl.Add("SG_1")
Set SrcGrp2 = SrcGrpColl.Add("SG_2")
Set SrcGrp3 = SrcGrpColl.Add("SG_3")

' Loop through the collection to find a specific
' source group.
For i = 0 To SrcGrpColl.Count - 1
    Set SrcGrp = SrcGrpColl.Item(i)
    If SrcGrp.Name = "SG_3" Then
        ' Move SrcGrp3 in front of SrcGrp1.
        SrcGrpColl.Move SrcGrp3, SrcGrp1
        ' Make ScrGrp3 active.
        SrcGrpColl.Active = SrcGrp3
    End If
Next

' Remove SrcGrp2, by index, from the collection.
SrcGrpColl.Remove 2

See Also

  • IWMEncSourceGroup Object
  • IWMEncSourceGroupCollection Object
  • IWMEncSourceGroup.Name


IWMEncSourceGroupCollection.Move

The Move method repositions a given source group directly in front of another source group in the collection.

Syntax

IWMEncSourceGroupCollection.Move( SourceGroup, SourceGroupInfront )

Parameters

SourceGroup

[in] Repositioned source group object.

SourceGroupInfront

[in] Source group object before which pSourceGroup is placed.

Return Values

This method does not return a value.

Remarks

Use the IWMEncSourceGroupCollection.Add method to add a source group. Use the IWMEncSourceGroupCollection.Item method to retrieve both SourceGroup and SourceGroupInfront.

Example Code

' Create a WMEncoder object.
Dim Encoder As WMEncoder
Set Encoder = New WMEncoder

' Declare objects and variables.
Dim SrcGrpColl As IWMEncSourceGroupCollection
Dim SrcGrp As IWMEncSourceGroup
Dim SrcGrp1 As IWMEncSourceGroup
Dim SrcGrp2 As IWMEncSourceGroup
Dim SrcGrp3 As IWMEncSourceGroup
Dim i As Integer

' Create an IWMEncSourceGroupCollection object.
Set SrcGrpColl = Encoder.SourceGroupCollection

' Add new source groups to the collection.
Set SrcGrp1 = SrcGrpColl.Add("SG_1")
Set SrcGrp2 = SrcGrpColl.Add("SG_2")
Set SrcGrp3 = SrcGrpColl.Add("SG_3")

' Loop through the collection to find a specific
' source group.
For i = 0 To SrcGrpColl.Count - 1
    Set SrcGrp = SrcGrpColl.Item(i)
    If SrcGrp.Name = "SG_3" Then
        ' Move SrcGrp3 in front of SrcGrp1.
        SrcGrpColl.Move SrcGrp3, SrcGrp1
        ' Make ScrGrp3 active.
        SrcGrpColl.Active = SrcGrp3
    End If
Next

' Remove SrcGrp2, by index, from the collection.
SrcGrpColl.Remove 2

See Also

  • IWMEncSourceGroupCollection.Add
  • IWMEncSourceGroupCollection.Item
  • IWMEncSourceGroupCollection Object


IWMEncSourceGroupCollection.Remove

The Remove method removes a source group from the collection.

Syntax

IWMEncSourceGroupCollection.Remove var

Parameters

var

[in] VARIANT containing the name, index or object ID of the source group.

Return Values

If this method fails, it returns an error number.

Number | Meaning
0xC00D1B60 | The active source group cannot be deleted while the encoder engine is running.

Example Code

' Create a WMEncoder object.
Dim Encoder As WMEncoder
Set Encoder = New WMEncoder

' Declare objects and variables.
Dim SrcGrpColl As IWMEncSourceGroupCollection
Dim SrcGrp As IWMEncSourceGroup
Dim SrcGrp1 As IWMEncSourceGroup
Dim SrcGrp2 As IWMEncSourceGroup
Dim SrcGrp3 As IWMEncSourceGroup
Dim i As Integer

' Create an IWMEncSourceGroupCollection object.
Set SrcGrpColl = Encoder.SourceGroupCollection

' Add new source groups to the collection.
Set SrcGrp1 = SrcGrpColl.Add("SG_1")
Set SrcGrp2 = SrcGrpColl.Add("SG_2")
Set SrcGrp3 = SrcGrpColl.Add("SG_3")

' Loop through the collection to find a specific
' source group.
For i = 0 To SrcGrpColl.Count - 1
    Set SrcGrp = SrcGrpColl.Item(i)
    If SrcGrp.Name = "SG_3" Then
        ' Move SrcGrp3 in front of SrcGrp1.
        SrcGrpColl.Move SrcGrp3, SrcGrp1
        ' Make ScrGrp3 active.
        SrcGrpColl.Active = SrcGrp3
    End If
Next

' Remove SrcGrp2, by index, from the collection.
SrcGrpColl.Remove 2

See Also

  • IWMEncSourceGroupCollection.Add
  • IWMEncSourceGroupCollection Object


IWMEncSourcePluginInfoManager Object

The IWMEncSourcePluginInfoManager object searches the plug-in registration information to populate a collection of source IWMEncPluginInfo objects. The IWMEncSourcePluginInfoManager object exposes the following properties and methods.

Property | Description
Count | Retrieves the number of installed source plug-ins.
Length | Retrieves the number of installed source plug-ins. This is the JScript version of the Count method.

Method | Description
Item | Retrieves information about a specific plug-in object in the collection.
Refresh | Removes the old collection and populates a new collection of source plug-in information structures.

See Also

  • [Visual C++] IWMEncSourcePluginInfoManager Interface
  • IWMEncPluginInfo Object
  • Objects (Visual Basic)


IWMEncSourcePluginInfoManager.Count

The Count property retrieves the number of installed source plug-ins.

Syntax

Long = IWMEncSourcePluginInfoManager.Count

Parameters

This property takes no parameters.

Return Values

When getting the value, this property returns a LONG containing the number of registered plug-ins.

Remarks

This property is read-only.

Example Code

' Declarations.
Dim Encoder As WMEncoder
Dim PluginIndex As Integer
Dim ResourceIndex As Integer
Dim Scheme As String
Dim Resource As String
Dim SrcPlugMgr As IWMEncSourcePluginInfoManager
Dim PlugInfo As IWMEncPluginInfo

' Create a WMEncoder object and retrieve an
' IWMEncSourcePluginInfoManager object from it
Set Encoder = New WMEncoder
Set SrcPlugMgr = Encoder.SourcePluginInfoManager

' Loop through the source plug-ins. Call the Item method on each
' plug-in to retrieve an IWMEncPluginInfo object. Use the
' SchemeType property to retrieve a string containing the scheme
' type of the plug-in. If the scheme type is "DEVICE" and if the
' plug-in supports resources, call the Item method to retrieve a
' string identifying the resource.
' To capture streams from an attached device, you must choose a
' specific device plug-in.
For PluginIndex = 0 To SrcPlugMgr.Count - 1
    Set PlugInfo = SrcPlugMgr.Item(PluginIndex)
    Scheme = PlugInfo.SchemeType
    If Scheme = "DEVICE" Then
        If PlugInfo.Resources = True Then
            For ResourceIndex = 0 To PlugInfo.Count - 1
                Resource = PlugInfo.Item(ResourceIndex)
            Next
        End If
    End If
Next

' Choose one of the device plug-ins identified in the preceeding
' step. For example, you can choose "DEVICE://Default_Video_Device"
' if you have a video capture card attached to your computer.
' Declare a source group object and a source group collection object.
' Get the source group collection object from the encoder object.
Dim SrcGrpColl As IWMEncSourceGroupCollection
Dim SrcGrp As IWMEncSourceGroup
Set SrcGrpColl = Encoder.SourceGroupCollection

' Add an empty source group to the source group collection.
Set SrcGrp = SrcGrpColl.Add("SG_1")

' Add video and audio streams to the new source group.
Dim SrcAud As IWMEncSource
Dim SrcVid As IWMEncSource
Set SrcVid = SrcGrp.AddSource(WMENC_VIDEO)
Set SrcAud = SrcGrp.AddSource(WMENC_AUDIO)

' Specify the plug-in to use for capturing streams from the
' video card.
SrcVid.SetInput "DEVICE://Default_Video_Device"
SrcAud.SetInput "DEVICE://Default_Audio_Device"

' Specify a broadcast port number, select a profile for
' the source group, and start the encoder engine.

See Also

  • IWMEncSourcePluginInfoManager Object


IWMEncSourcePluginInfoManager.length

The length property retrieves the number of installed source plug-ins.

Syntax

Long = IWMEncSourcePluginInfoManager.length

Parameters

This property takes no parameters.

Return Values

When getting the value, this property returns a LONG containing the number of registered plug-ins

Remarks

This property is read-only. This is the JScript version of the IWMEncSourcePluginInfoManager.Count method. It is provided for JScript developers or developers more accustomed to JScript syntax.

Example Code

' Declarations
Dim Encoder As WMEncoder
Dim PluginIndex As Integer
Dim ResourceIndex As Integer
Dim Scheme As String
Dim Resource As String
Dim SrcPlugMgr As IWMEncSourcePluginInfoManager
Dim PlugInfo As IWMEncPluginInfo

' Create a WMEncoder object and retrieve an
' IWMEncSourcePluginInfoManager object from it
Set Encoder = New WMEncoder
Set SrcPlugMgr = Encoder.SourcePluginInfoManager

' Loop through the source plug-ins. Call the Item method on each
' plug-in to retrieve an IWMEncPluginInfo object. Use the
' SchemeType property to retrieve a string containing the scheme
' type of the plug-in. If the scheme type is "DEVICE" and if the
' plug-in supports resources, call the Item method to retrieve a
' string identifying the resource.
' To capture streams from an attached device, you must choose a
' specific device plug-in.
For PluginIndex = 0 To SrcPlugMgr.Count - 1
    Set PlugInfo = SrcPlugMgr.Item(PluginIndex)
    Scheme = PlugInfo.SchemeType
    If Scheme = "DEVICE" Then
        If PlugInfo.Resources = True Then
            For ResourceIndex = 0 To PlugInfo.Count - 1
                Resource = PlugInfo.Item(ResourceIndex)
            Next
        End If
    End If
Next

' Choose one of the device plug-ins identified in the preceeding
' step. For example, you can choose "DEVICE://Default_Video_Device"
' if you havea video capture card attached to your computer.
' Declare a source group object and a source group collection object.
' Get the source group collection object from the encoder object.
Dim SrcGrpColl As IWMEncSourceGroupCollection
Dim SrcGrp As IWMEncSourceGroup
Set SrcGrpColl = Encoder.SourceGroupCollection

' Add an empty source group to the source group collection.
Set SrcGrp = SrcGrpColl.Add("SG_1")

' Add video and audio streams to the new source group.
Dim SrcAud As IWMEncSource
Dim SrcVid As IWMEncSource
Set SrcVid = SrcGrp.AddSource(WMENC_VIDEO)
Set SrcAud = SrcGrp.AddSource(WMENC_AUDIO)

' Specify the plug-in to use for capturing streams from the
' video card.
SrcVid.SetInput "DEVICE://Default_Video_Device"
SrcAud.SetInput "DEVICE://Default_Audio_Device"

' Specify a broadcast port number, select a profile for
' the source group, and start the encoder engine.

See Also

  • IWMEncSourcePluginInfoManager.Count
  • IWMEncSourcePluginInfoManager Object


IWMEncSourcePluginInfoManager.Item

The Item method retrieves information about a specific plug-in object in the collection.

Syntax

IWMEncPluginInfo = IWMEncSourcePluginInfoManager.Item ( lIndex )

Parameters

lIndex

[in] LONG containing the index of the plug-in in the plug-in collection.

Return Values

This method returns an IWMEncPluginInfo object, containing general information.

Example Code

' Declarations
Dim Encoder As WMEncoder
Dim PluginIndex As Integer
Dim ResourceIndex As Integer
Dim Scheme As String
Dim Resource As String
Dim SrcPlugMgr As IWMEncSourcePluginInfoManager
Dim PlugInfo As IWMEncPluginInfo

' Create a WMEncoder object and retrieve an
' IWMEncSourcePluginInfoManager object from it
Set Encoder = New WMEncoder
Set SrcPlugMgr = Encoder.SourcePluginInfoManager

' Loop through the source plug-ins. Call the Item method on each
' plug-in to retrieve an IWMEncPluginInfo object. Use the
' SchemeType property to retrieve a string containing the scheme
' type of the plug-in. If the scheme type is "DEVICE" and if the
' plug-in supports resources, call the Item method to retrieve a
' string identifying the resource.
' To capture streams from an attached device, you must choose a
' specific device plug-in.
For PluginIndex = 0 To SrcPlugMgr.Count - 1
    Set PlugInfo = SrcPlugMgr.Item(PluginIndex)
    Scheme = PlugInfo.SchemeType
    If Scheme = "DEVICE" Then
        If PlugInfo.Resources = True Then
            For ResourceIndex = 0 To PlugInfo.Count - 1
                Resource = PlugInfo.Item(ResourceIndex)
            Next
        End If
    End If
Next

' Choose one of the device plug-ins identified in the preceeding
' step. For example, you can choose "DEVICE://Default_Video_Device"
' if you havea video capture card attached to your computer.
' Declare a source group object and a source group collection object.
' Get the source group collection object from the encoder object.
Dim SrcGrpColl As IWMEncSourceGroupCollection
Dim SrcGrp As IWMEncSourceGroup
Set SrcGrpColl = Encoder.SourceGroupCollection

' Add an empty source group to the source group collection.
Set SrcGrp = SrcGrpColl.Add("SG_1")

' Add video and audio streams to the new source group.
Dim SrcAud As IWMEncSource
Dim SrcVid As IWMEncSource
Set SrcVid = SrcGrp.AddSource(WMENC_VIDEO)
Set SrcAud = SrcGrp.AddSource(WMENC_AUDIO)

' Specify the plug-in to use for capturing streams from the
' video card.
SrcVid.SetInput "DEVICE://Default_Video_Device"
SrcAud.SetInput "DEVICE://Default_Audio_Device"

' Specify a broadcast port number, select a profile for
' the source group, and start the encoder engine.

See Also

  • IWMEncPluginInfo Object
  • IWMEncSourcePluginInfoManager Object


IWMEncSourcePluginInfoManager.Refresh

The Refresh method removes the old collection and populates a new collection of source plug-in information structures.

Syntax

IWMEncSourcePluginInfoManager.Refresh

Parameters

This method takes no parameters.

Return Values

This method does not return a value.

Remarks

Use this method to re-create a plug-in registration collection when you either add or removes a plug-in.

Example Code

' Declarations
Dim Encoder As WMEncoder
Dim PluginIndex As Integer
Dim ResourceIndex As Integer
Dim Scheme As String
Dim Resource As String
Dim SrcPlugMgr As IWMEncSourcePluginInfoManager
Dim PlugInfo As IWMEncPluginInfo

' Create a WMEncoder object and retrieve an
' IWMEncSourcePluginInfoManager object from it
Set Encoder = New WMEncoder
Set SrcPlugMgr = Encoder.SourcePluginInfoManager

' Loop through the source plug-ins. Call the Item method on each
' plug-in to retrieve an IWMEncPluginInfo object. Use the
' SchemeType property to retrieve a string containing the scheme
' type of the plug-in. If the scheme type is "DEVICE" and if the
' plug-in supports resources, call the Item method to retrieve a
' string identifying the resource.
' To capture streams from an attached device, you must choose a
' specific device plug-in.
For PluginIndex = 0 To SrcPlugMgr.Count - 1
    Set PlugInfo = SrcPlugMgr.Item(PluginIndex)
    Scheme = PlugInfo.SchemeType
    If Scheme = "DEVICE" Then
        If PlugInfo.Resources = True Then
            For ResourceIndex = 0 To PlugInfo.Count - 1
                Resource = PlugInfo.Item(ResourceIndex)
            Next
        End If
    End If
Next

' Choose one of the device plug-ins identified in the preceeding
' step. For example, you can choose "DEVICE://Default_Video_Device"
' if you havea video capture card attached to your computer.
' Declare a source group object and a source group collection object.
' Get the source group collection object from the encoder object.
Dim SrcGrpColl As IWMEncSourceGroupCollection
Dim SrcGrp As IWMEncSourceGroup
Set SrcGrpColl = Encoder.SourceGroupCollection

' Add an empty source group to the source group collection.
Set SrcGrp = SrcGrpColl.Add("SG_1")

' Add video and audio streams to the new source group.
Dim SrcAud As IWMEncSource
Dim SrcVid As IWMEncSource
Set SrcVid = SrcGrp.AddSource(WMENC_VIDEO)
Set SrcAud = SrcGrp.AddSource(WMENC_AUDIO)

' Specify the plug-in to use for capturing streams from the
' video card.
SrcVid.SetInput "DEVICE://Default_Video_Device"
SrcAud.SetInput "DEVICE://Default_Audio_Device"

' Specify a broadcast port number, select a profile for
' the source group, and start the encoder engine.

See Also

  • IWMEncSourcePluginInfoManager Object


IWMEncStatistics Object

The IWMEncStatistics object provides status information about the encoding session. The IWMEncStatistics object exposes the following properties.

Property | Description
EncodingTime | Retrieves the elapsed time of the encoding session.
FileArchiveStats | Retrieves an IWMEncFileArchiveStats object to determine the size of the archive file and the duration of the encoded content stored in the file.
IndexerStats | Retrieves an indexer statistics object to determine the number of files being indexed, the name of a file in the queue, and the percentage of indexing completed on the current file.
NetConnectionStats | Retrieves a network connection statistics object.
StreamOutputCount | Retrieves the number of multiple bit rate output streams generated from a specific input stream.
StreamOutputStats | Retrieves the encoding and broadcasting statistics for a specific output stream.
WMFOutputStats | Retrieves status information for the encoded output.

See Also

  • [Visual C++] IWMEncStatistics Interface
  • Objects (Visual Basic)


IWMEncStatistics.EncodingTime

The EncodingTime property retrieves the elapsed time of the encoding session.

Syntax

WMENC_LONGLONG = IWMEncStatistics.EncodingTime

Parameters

This property takes no parameters.

Return Values

When getting the value, this property returns a QWORD containing the elapsed time.

Remarks

This property is read-only. You can use this property in a timer object. The elapsed time, in milliseconds, is measured from the start of the encoding session to the moment at which EncodingTime is processed. The WMENC_LONGLONG data type is a typedef from the CURRENCY type. A 64-bit integer is needed to hold the elapsed time, and CURRENCY is the only 64-bit integer type that Automation supports. However, CURRENCY is a fixed-point type that has the decimal point moved four places to the left. Therefore, to display the CURRENCY value as a true integer and retrieve the correct elapsed time, you must multiply the return value by 10,000.

See Also

  • IWMEncStatistics Object


IWMEncStatistics.FileArchiveStats

The FileArchiveStats property retrieves an IWMEncFileArchiveStats object to determine the size of the archive file and the duration of the encoded content stored in the file.

Syntax

IDispatch = IWMEncStatistics.FileArchiveStats

Parameters

This property takes no parameters.

Return Values

When getting the value, this property returns an IWMEncFileArchiveStats object.

If this property fails, it returns an error number.

Number | Meaning
0xC00D1B7D | No statistics are currently available.
0xC00D1B7E | The encoder engine is not currently archiving.

Remarks

This property is read-only. File size and duration information does not persist after the encoding process has stopped. You can create a timer object to retrieve the archiving statistics.

The WMENC_LONGLONG data type used in the following example is a typedef from the CURRENCY type. A 64-bit integer is needed to hold the duration, and CURRENCY is the only 64-bit integer type that Automation supports. However, CURRENCY is a fixed-point type that has the decimal point moved four places to the left. Therefore, to display the CURRENCY value as a true integer and retrieve the correct file duration, you must multiply the return value by 10,000.

Example Code

' Create a WMEncoder object
Dim Encoder As WMEncoder
Set Encoder = New WMEncoder

' Declare objects and variables.
Dim Statistics As IWMEncStatistics
Dim FileStats As IWMEncFileArchiveStats
Dim Duration As WMENC_LONGLONG
Dim Size As WMENC_LONGLONG

' Retrieve a IWMEncStatistics object and retrieve
' the IWMEncFileArchiveStats object from it.
Set Statistics = Encoder.Statistics
Set FileStats = Statistics.FileArchiveStats

' Find the duration and size of the archive file.
Duration = FileStats.FileDuration * 10000
Size = FileStats.FileSize * 10000

See Also

  • IWMEncFileArchiveStats Object
  • IWMEncStatistics Object


IWMEncStatistics.IndexerStats

The IndexerStats property retrieves an indexer statistics object to determine the number of files being indexed, the name of a file in the queue, and the percentage of indexing completed on the current file.

Syntax

IDispatch = IWMEncStatistics.IndexerStats

Parameters

This property takes no parameters.

Return Values

When getting the value, this property returns an EncIndexerStats object.

If this property fails, it returns an error number.

Number | Meaning
0xC00D1B7D | No statistics are currently available.

Remarks

This property is read-only. The IWMEncIndexerStats object monitors the indexing process for a Windows Media file. A file index enables operations, such as fast forwarding, that must seek to specific time offsets in the file. If you specify an archive file, Windows Media Encoder automatically starts the indexing process on a separate thread in the background of the encoder engine immediately after the archiving process stops. The indexing process stops at the end of the file.

Example Code

' Create a WMEncoder object.
Dim Encoder As WMEncoder
Set Encoder = New WMEncoder

' Declare objects and variables.
Dim Statistics As IWMEncStatistics
Dim IndexStats As IWMEncIndexerStats
Dim lFileCount As Long
Dim sFileName As String
Dim lPercent As Long

' Retrieve an IWMEncStatistics object, and use it to
' retrieve an IWMEncIndexerStats object.
Set Statistics = Encoder.Statistics
Set IndexStats = Statistics.IndexerStats

' Retrieve the number of files remaining in the queue.
lFileCount = IndexStats.FileCount

' Retrieve the name of a specific file in the queue.
sFileName = IndexStats.FileName(0)

' Retrieve the percentage of indexing completed on the
' current file.
lPercent = IndexStats.PercentComplete

See Also

  • IWMEncIndexerStats Object
  • IWMEncStatistics Object


IWMEncStatistics.NetConnectionStats

The NetConnection property retrieves a network connection object.

Syntax

IDispatch = IWMEncStatistics.NetConnectionStats

Parameters

This property takes no parameters.

Return Values

When getting the value, this property returns a network connection object.

If this property fails, it returns an error number.

Number | Meaning
0xC00D1B7D | No statistics are currently available.

Remarks

This property is read-only. The IWMEncNetConnectionStats object identifies the number of clients connected to the computer that is hosting Windows Media Encoder, and the protocol and IP address of a specific client.

Example Code

' Create a WMEncoder object.

Dim Encoder As WMEncoder

Set Encoder = New WMEncoder

' Declare objects and variables.
Dim Statistics As IWMEncStatistics
Dim NetClient As IWMEncNetConnectionStats
Dim lClients As Long
Dim sAddr As String
Dim i As Integer

' Retrieve an IWMEncStatistics object and an IWMEncNetConnections
' object.
Set Statistics = Encoder.Statistics
Set NetClient = Statistics.NetConnectionStats

' Retrieve the number of clients connected.
lClients = NetClient.ClientCount

' Retrieve the IP address of each client.
For i = 1 To lClients
    sAddr = NetClient.ClientInfo(i, WMENC_PROTOCOL_HTTP)
Next

See Also

  • IWMEncNetConnectionStats Object
  • IWMEncStatistics Object


IWMEncStatistics.StreamOutputCount

The StreamOutputCount property retrieves the number of multiple bit rate output streams generated from a specific input stream.

Syntax

Short = IWMEncStatistics.StreamOutputCount(enumType, iMediaIndex)

Parameters

enumType

[in] Specifies a member of an WMENC_SOURCE_TYPE enumeration type indicating the type of the specific stream. This must be one of the following values. Only video streams, however, can generate multiple bit rate output streams.

Return code | Number | Description
WMENC_AUDIO | 1 | Identifies an audio stream.
WMENC_VIDEO | 2 | Identifies a video stream.
WMENC_SCRIPT | 4 | Identifies a text stream.

iMediaIndex

[in] short containing the source group index number for a specific input media stream of the type identified by enumType. Because Windows Media Encoder supports only one audio, one video and one text stream per source group, iMediaIndex must be zero. The index is zero-based.

Return Values

When getting the value, this property returns a SHORT containing the number of multiple bit-rate output streams generated from a specific input stream.

Remarks

This property is read-only. If you specify a source type that does not exist in the source group, the StreamOutputCount property returns an error code. It does not return zero.

Example Code

' Create a WMEncoder Object.
Dim Encoder As WMEncoder
Set Encoder = New WMEncoder

' Retrieve an IWMEncStatistics object
Dim Statistics As IWMEncStatistics
Set Statistics = Encoder.Statistics

' Configure the encoder engine
' For configuration code see the IWMEncSource object

' Retrieve the number of multiple bit rate output streams.

Dim iStreamCount As Integer
iStreamCount = Statistics.StreamOutputCount(WMENC_VIDEO,0)

' Retrieve an IWMEncOutputStats object from the
' IWMEncStatistics object
Dim OutputStats As IWMEncOutputStats
Set OutputStats = Statistics.StreamOutputStats(WMENC_VIDEO, 0, 0)

' You can create a timer control to retrieve the statistics
' (as follows) after you start the encoder engine.
Dim lAvgBitrate As Long
Dim lAvgSampleRate As Long
Dim lByteCount As WMENC_LONGLONG
Dim lCurrentBitRate As Long
Dim lCurrentSampleRate As Long
Dim lDroppedByteCount As WMENC_LONGLONG
Dim lDroppedSampleCount As WMENC_LONGLONG
Dim lExpectedBitRate As Long
Dim lExpectedSampleRate As Long
Dim lSampleCount As WMENC_LONGLONG

lAvgBitrate = OutputStats.AverageBitrate
lAvgSampleRate = OutputStats.AverageSampleRate
lByteCount = OutputStats.ByteCount
lCurrentBitRate = OutputStats.CurrentBitrate
lCurrentSampleRate = OutputStats.CurrentSampleRate
lDroppedByteCount = OutputStats.DroppedByteCount
lDroppedSampleCount = OutputStats.DroppedSampleCount
lExpectedBitRate = OutputStats.ExpectedBitrate
lExpectedSampleRate = OutputStats.ExpectedSampleRate
lSampleCount = OutputStats.SampleCount

See Also

  • IWMEncStatistics Object


IWMEncStatistics.StreamOutputStats

The StreamOutputStats property retrieves the encoding and broadcasting statistics for a specific output stream.

Syntax

IDispatch = IWMEncStatistics.StreamOutputStats(enumType, iMediaIndex, iStreamIndex)

Parameters

enumType

[in] Member of a WMENC_SOURCE_TYPE enumeration type indicating the type of the specific stream. This must be one of the following values.

Return code | Number | Description
WMENC_AUDIO | 1 | Identifies an audio stream.
WMENC_VIDEO | 2 | Identifies a video stream.
WMENC_SCRIPT | 4 | Identifies a text stream.

iMediaIndex

[in] SHORT containing the source group index number for a specific input media stream of the type identified by enumType. Because a source group can only contain one audio, one video and one text stream, iMediaIndex must be zero.

iStreamIndex

[in] SHORT containing the index of a specific multiple bit rate output stream for the input stream identified by iMediaIndex. A profile identifies the number of multiple output streams for a given input stream. Only the bit rate varies among the streams.

Return Values

When getting the value, this property returns an IWMEncOutputStats object containing status information about the output stream.

If this property fails, it returns an error number.

Number | Meaning
0xC00D1B7D | No statistics are currently available.

Remarks

This property is read-only. The IWMEncOutputStats object contains information about the number of media samples received and dropped; the current, average and expected bit rate of the broadcast; and the current, average and expected rates at which media samples are encoded. You can use the StreamOutputStats property in a timer control.

Example Code

' Create a WMEncoder Object.
Dim Encoder As WMEncoder
Set Encoder = New WMEncoder

' Retrieve an IWMEncStatistics object
Dim Statistics As IWMEncStatistics
Set Statistics = Encoder.Statistics

' Configure the encoder engine
' For configuration code see the IWMEncSource object

' Retrieve the number of multiple bit rate output streams.

Dim iStreamCount As Integer
iStreamCount = Statistics.StreamOutputCount(WMENC_VIDEO,0)

' Retrieve an IWMEncOutputStats object from the
' IWMEncStatistics object
Dim OutputStats As IWMEncOutputStats
Set OutputStats = Statistics.StreamOutputStats(WMENC_VIDEO, 0, 0)

' You can create a timer control to retrieve the statistics
' (as follows) after you start the encoder engine.
Dim lAvgBitrate As Long
Dim lAvgSampleRate As Long
Dim lByteCount As WMENC_LONGLONG
Dim lCurrentBitRate As Long
Dim lCurrentSampleRate As Long
Dim lDroppedByteCount As WMENC_LONGLONG
Dim lDroppedSampleCount As WMENC_LONGLONG
Dim lExpectedBitRate As Long
Dim lExpectedSampleRate As Long
Dim lSampleCount As WMENC_LONGLONG

lAvgBitrate = OutputStats.AverageBitrate
lAvgSampleRate = OutputStats.AverageSampleRate
lByteCount = OutputStats.ByteCount
lCurrentBitRate = OutputStats.CurrentBitrate
lCurrentSampleRate = OutputStats.CurrentSampleRate
lDroppedByteCount = OutputStats.DroppedByteCount
lDroppedSampleCount = OutputStats.DroppedSampleCount
lExpectedBitRate = OutputStats.ExpectedBitrate
lExpectedSampleRate = OutputStats.ExpectedSampleRate
lSampleCount = OutputStats.SampleCount

See Also

  • IWMEncOutputStats Object
  • IWMEncStatistics Object


IWMEncStatistics.WMFOutputStats

The WMFOutputStats property retrieves status information for the encoded output.

Syntax

IWMEncOutputStats = IWMEncStatistics.WMFOutputStats

Parameters

This property takes no parameters.

Return Values

When getting the value, this property returns an IWMEncOutputStats object containing encoding and broadcasting statistics for the encoded output.

Remarks

This property is read-only. The IWMEncOutputStats object contains information about the number of media samples received and dropped; the current, average and expected bit rate of the broadcast; and the current, average and expected rates at which media samples are encoded.

Example Code

' Create a WMEncoder Object.
Dim Encoder As WMEncoder
Set Encoder = New WMEncoder

' Retrieve an IWMEncStatistics object
Dim Statistics As IWMEncStatistics
Set Statistics = Encoder.Statistics

' Configure the encoder engine
' For configuration code see the IWMEncSource object

' Retrieve an IWMEncOutputStats object from the
' IWMEncStatistics object
Dim OutputStats As IWMEncOutputStats
Set OutputStats = Statistics.WMFOutputStats

' You can create a timer control to retrieve the statistics
' (as follows) after you start the encoder engine.
Dim lAvgBitrate As Long
Dim lAvgSampleRate As Long
Dim lByteCount As WMENC_LONGLONG
Dim lCurrentBitRate As Long
Dim lCurrentSampleRate As Long
Dim lDroppedByteCount As WMENC_LONGLONG
Dim lDroppedSampleCount As WMENC_LONGLONG
Dim lExpectedBitRate As Long
Dim lExpectedSampleRate As Long
Dim lSampleCount As WMENC_LONGLONG

lAvgBitrate = OutputStats.AverageBitrate
lAvgSampleRate = OutputStats.AverageSampleRate
lByteCount = OutputStats.ByteCount
lCurrentBitRate = OutputStats.CurrentBitrate
lCurrentSampleRate = OutputStats.CurrentSampleRate
lDroppedByteCount = OutputStats.DroppedByteCount
lDroppedSampleCount = OutputStats.DroppedSampleCount
lExpectedBitRate = OutputStats.ExpectedBitrate
lExpectedSampleRate = OutputStats.ExpectedSampleRate
lSampleCount = OutputStats.SampleCount

See Also

  • IWMEncStatistics Object
  • IWMEncOutputStats Object


IWMEncTransform Object

The IWMEncTransform object specifies and retrieves transform plug-ins. The IWMEncTransform object exposes the following methods.

Method | Description
GetInput | Retrieves the name and scheme of a transform plug-in.
GetTransformPlugin | Retrieves a specific transform plug-in.
SetInput | Specifies a transform plug-in by name and scheme.

See Also

  • [Visual C++] IWMEncTransform Interface


IWMEncTransform.GetInput

The GetInput method retrieves the name and scheme of a transform plug-in.

Syntax

BSTR = IWMEncTransform.GetInput(pbstrScheme, pbstrInitData)

Parameters

bstrScheme

[out] BSTR containing the scheme type.

bstrInitData

[out] BSTR containing optional initialization data.

Return Values

This method returns a BSTR containing the name of the transform plug-in.

If this method fails, it returns an error number.

Number | Meaning
0x8007000E | Memory cannot be allocated.

Example Code

' Create a WMEncoder object.
Dim Encoder As WMEncoder
Set Encoder = New WMEncoder

' Declare a source group object and a source group collection object.
' Get the source group collection object from the encoder object.
Dim SrcGrpColl As IWMEncSourceGroupCollection
Dim SrcGrp As IWMEncSourceGroup
Set SrcGrpColl = Encoder.SourceGroupCollection

' Add an emtpy source group to the source group collection.
Set SrcGrp = SrcGrpColl.Add("SG_1")

' Add audio (mandatory) and video sources to the new source group.
Dim SrcVid As IWMEncSource
Dim SrcAud As IWMEncSource
Set SrcVid = SrcGrp.AddSource(WMENC_VIDEO)
Set SrcAud = SrcGrp.AddSource(WMENC_AUDIO)

' Specify the audio and video capture source.
SrcVid.SetInput "DEVICE://Default_Video_Device"
SrcAud.SetInput "DEVICE://Default_Audio_Device"

' Select a profile for the source.
Dim ProColl As IWMEncProfileCollection
Dim Pro As IWMEncProfile

Set ProColl = Encoder.ProfileCollection
For i = 0 To ProColl.Count - 1
    Set Pro = ProColl.Item(i)
    If Pro.Name = "profile_name" Then
        SrcGrp.Profile = Pro
        Exit For
    End If
Next

' Retrieve the transform collection from the source group.

Dim GrpTrnsColl As IWMEncTransformCollection
Set GrpTrnsColl = SrcGrp.GroupTransformCollection

' Add a transform plugin to the collection.

Dim TCTrans As IWMEncTransform
Set TCTrans = GrpTrnsColl.Add

' Set the time compression plug-in into the source group.

TCTrans.SetInput "TCGroupTransformPlugin://TimeCompression1"

' Retrieve the name and scheme type of the transform plug-in.

Dim bstrScheme As String
Dim bstrInitData As String
Dim bstrTransName As String
bstrTransName = TCTrans.GetInput(bstrScheme, bstrInitData)

' To configure the time compression plug-in, you must enable the
' relevant property page and retrieve input from the end-user.
' The plug-in defaults to no compression.
' You must also create an IWMEncFile object and configure the
' archiving process.

' Initialize the encoder engine.
Encoder.PrepareToEncode (True)

See Also

  • IWMEncTransform Object
  • IWMEncTransform.SetInput


IWMEncTransform.GetTransformPlugin

The GetTransformPlugin method retrieves a specific transform plug-in.

Syntax

IUnknown = IWMEncTransform.GetTransformPlugin

Parameters

This method takes no parameters.

Return Values

This method returns the transform plug-in object.

Remarks

Only the time compression plug-in is included in the current release of the Windows Media Encoder SDK. If you are programming with C++, you can use the GetTransformPlugin method on the IWMEncTransform interface to retrieve the property pages supported by the time compression plug-in. However, because the time compression plug-in does not support Automation and does not provide a type library, you cannot use the GetTransformPlugin method if you are programming with either a scripting language or Visual Basic.

See Also

  • [Visual C++] IWMEncTransform Interface
  • IWMEncTransform Object
  • IWMEncTransform::GetTransformPlugin


IWMEncTransform.SetInput

The SetInput method specifies a transform plug-in by name and scheme.

Syntax

IWMEncTransform.SetInput bstrInput, bstrScheme, bstrInitData

Parameters

bstrInput

[in] BSTR containing the full name of a transform plug-in. Specify a plug-in name in the "scheme://resource" format. If you put only the "resource" in bstrInput, and not the full path, Windows Media Encoder examines pbstrScheme to find the scheme type.

bstrScheme

[in] BSTR containing the scheme type. If you supply a value for this parameter, Windows Media Encoder examines bstrInput to form a "scheme://resource" plug-in identifier without parsing the stream. This is useful if the "resource" part of the string contains special characters or symbols that cannot be interpreted as part of a standard URL..

bstrInitData

[in] BSTR containing optional initialization data for the plug-in.

Return Values

If this method fails, it returns an error number.

Number | Meaning
0xC00D0011 | This method cannot be called if the encoder engine is running.

Remarks

You must call the Add method in the IWMEncTransformCollection object before calling SetInput.

Example Code

' Create a WMEncoder object.
Dim Encoder As WMEncoder
Set Encoder = New WMEncoder

' Declare a source group object and a source group collection object.
' Get the source group collection object from the encoder object.
Dim SrcGrpColl As IWMEncSourceGroupCollection
Dim SrcGrp As IWMEncSourceGroup
Set SrcGrpColl = Encoder.SourceGroupCollection

' Add an emtpy source group to the source group collection.
Set SrcGrp = SrcGrpColl.Add("SG_1")

' Add audio (mandatory) and video sources to the new source group.
Dim SrcVid As IWMEncSource
Dim SrcAud As IWMEncSource
Set SrcVid = SrcGrp.AddSource(WMENC_VIDEO)
Set SrcAud = SrcGrp.AddSource(WMENC_AUDIO)

' Specify the audio and video capture source.
SrcVid.SetInput "DEVICE://Default_Video_Device"
SrcAud.SetInput "DEVICE://Default_Audio_Device"

' Select a profile for the source.
Dim ProColl As IWMEncProfileCollection
Dim Pro As IWMEncProfile

Set ProColl = Encoder.ProfileCollection
For i = 0 To ProColl.Count - 1
    Set Pro = ProColl.Item(i)
    If Pro.Name = "profile_name" Then
        SrcGrp.Profile = Pro
        Exit For
    End If
Next

' Retrieve the transform collection from the source group.

Dim GrpTrnsColl As IWMEncTransformCollection
Set GrpTrnsColl = SrcGrp.GroupTransformCollection

' Add a transform plugin to the collection.

Dim TCTrans As IWMEncTransform
Set TCTrans = GrpTrnsColl.Add

' Set the time compression plug-in into the source group.

TCTrans.SetInput "TCGroupTransformPlugin://TimeCompression1"

' Retrieve the name and scheme type of the transform plug-in.

Dim bstrScheme As String
Dim bstrInitData As String
Dim bstrTransName As String
bstrTransName = TCTrans.GetInput(bstrScheme, bstrInitData)

' To configure the time compression plug-in, you must enable the
' relevant property page and retrieve input from the end-user.
' The plug-in defaults to no compression.
' You must also create an IWMEncFile object and configure the
' archiving process.

' Initialize the encoder engine.
Encoder.PrepareToEncode (True)

See Also

  • IWMEncTransform.GetInput
  • IWMEncTransform Object
  • IWMEncTransformCollection.Add
  • IWMEncTransformCollection Object


IWMEncTransformCollection Object

The IWMEncTransformCollection object manages the collection of transform plug-ins used by Windows Media Encoder. The order of plug-ins in this collection determines the order that the transformations are applied to the media streams. This collection contains only the transform plug-ins that are applied during the current session. The entire collection of transform plug-ins is enumerated by the IWMEncTransformPluginInfoManager object. The IWMEncTransformCollection object exposes the following properties and methods.

Property | Description
Count | Retrieves the number of transform plug-ins in the collection.
length | Retrieves the number of transform plug-ins in the collection.

Method | Description
Add | Adds a transform plug-in to the collection.
Item | Retrieves a specific transform plug-in.
Move | Places one transform plug-in in front of another in the collection.
Remove | Removes a specific plug-in from the collection.
RemoveAll | Removes all plug-ins from the collection.

See Also

  • [Visual C++] IWMEncTransformCollection Interface
  • IWMEncTransformPluginInfoManager Object
  • Objects (Visual Basic)


IWMEncTransformCollection.Count

The Count property retrieves the number of transform plug-ins in the collection.

Syntax

Long = IWMEncTransformCollection.Count

Parameters

This property takes no parameters.

Return Values

When getting the value, this property returns a LONG containing the number of plug-ins.

Remarks

This property is read-only. The current version of the Windows Media Encoder SDK includes only one transform plug-in. For more information, see the Time Compression Plug-in section of the Programming Guide.

See Also

  • IWMEncTransformCollection Object
  • Programming Guide
  • Time Compression Plug-in


IWMEncTransformCollection.length

The length property retrieves the number of transform plug-ins in the collection.

Syntax

Long = IWMEncTransformCollection.length

Parameters

This property takes no parameters.

Return Values

When getting the value, this property returns a LONG containing the number of source groups.

Remarks

This property is read-only. The current version of the Windows Media Encoder SDK includes only one transform plug-in. For more information, see the Time Compression Plug-in section of the Programming Guide.

See Also

  • IWMEncTransformCollection Object
  • Programming Guide
  • Time Compression Plug-in


IWMEncTransformCollection.Add

The Add method adds a plug-in to a source group.

Syntax

IWMEncTransform = IWMEncTransformCollection.Add

Parameters

This method takes no parameters.

Return Values

This method returns an IWMEncTransform object.

If this method fails, it returns an error number.

Number | Meaning
0x8007000E | Memory cannot be allocated.

Remarks

Use the Add method to reserve the memory needed to add a transform plug-in to the collection. Use the SetInput method in the IWMEncTransform object to add a specific plug-in.

Example Code

' Create a WMEncoder object.
Dim Encoder As WMEncoder
Set Encoder = New WMEncoder

' Declare a source group object and a source group collection object.
' Get the source group collection object from the encoder object.
Dim SrcGrpColl As IWMEncSourceGroupCollection
Dim SrcGrp As IWMEncSourceGroup
Set SrcGrpColl = Encoder.SourceGroupCollection

' Add an emtpy source group to the source group collection.
Set SrcGrp = SrcGrpColl.Add("SG_1")

' Add audio (mandatory) and video sources to the new source group.
Dim SrcVid As IWMEncSource
Dim SrcAud As IWMEncSource
Set SrcVid = SrcGrp.AddSource(WMENC_VIDEO)
Set SrcAud = SrcGrp.AddSource(WMENC_AUDIO)

' Specify the audio and video capture source.
SrcVid.SetInput "DEVICE://Default_Video_Device"
SrcAud.SetInput "DEVICE://Default_Audio_Device"

' Select a profile for the source.
Dim ProColl As IWMEncProfileCollection
Dim Pro As IWMEncProfile

Set ProColl = Encoder.ProfileCollection
For i = 0 To ProColl.Count - 1
    Set Pro = ProColl.Item(i)
    If Pro.Name = "profile_name" Then
        SrcGrp.Profile = Pro
        Exit For
    End If
Next

' Retrieve the transform collection from the source group.

Dim GrpTrnsColl As IWMEncTransformCollection
Set GrpTrnsColl = SrcGrp.GroupTransformCollection

' Add a transform plugin to the collection.

Dim TCTrans As IWMEncTransform
Set TCTrans = GrpTrnsColl.Add

' Set the time compression plug-in into the source group.

TCTrans.SetInput "TCGroupTransformPlugin://TimeCompression1"

' Retrieve the name and scheme type of the transform plug-in.

Dim bstrScheme As String
Dim bstrInitData As String
Dim bstrTransName As String
bstrTransName = TCTrans.GetInput(bstrScheme, bstrInitData)

' To configure the time compression plug-in, you must enable the
' relevant property page and retrieve input from the end-user.
' The plug-in defaults to no compression.
' You must also create an IWMEncFile object and configure the
' archiving process.

' Initialize the encoder engine.
Encoder.PrepareToEncode (True)

See Also

  • IWMEncTransform Object
  • IWMEncTransform.SetInput
  • IWMEncTransformCollection Object
  • IWMEncTransformCollection.Remove


IWMEncTransformCollection.Item

The Item method retrieves a specific transform plug-in.

Syntax

IWMEncTransform = IWMEncTransformCollection.Item( lIndex )

Parameters

lIndex

[in] LONG containing the index of the plug-in.

Return Values

This method returns an IWMEncTransform object.

Remarks

The current version of the Windows Media Encoder SDK includes only one transform plug-in. For more information, see the Time Compression Plug-in section of the Programming Guide.

See Also

  • IWMEncTransformCollection Object
  • Programming Guide
  • Time Compression Plug-in


IWMEncTransformCollection.Move

The Move method places one transform plug-in in front of another in the collection.

Syntax

IWMEncTransformCollection.Move lMove, lInFrontOf

Parameters

lMove

[in] LONG containing the numeric index of the plug-in.

lInFrontOf

[in] LONG containing the numeric index of the plug-in that varMove is placed in front of.

Return Values

If this method fails, it returns an error number.

Number | Meaning
0xC00D1B66 | An index identifying the position of a plug-in in the collection is not valid.
0xC00D0011 | This method cannot be called if the encoder engine is running.

Remarks

The order of the transform plug-ins in the collection dictates the order that the plug-ins are applied to a stream. However, the current version of the Windows Media Encoder SDK includes only one transform plug-in. For more information, see the Time Compression Plug-in section of the Programming Guide.

See Also

  • IWMEncTransformCollection Object
  • Programming Guide
  • Time Compression Plug-in


IWMEncTransformCollection.Remove

The Remove method removes a specific plug-in from the collection.

Syntax

IWMEncTransformCollection.Remove lIndex

Parameters

lIndex

[in] LONG containing the numeric index of the plug-in.

Return Values

If this method fails, it returns an error number.

Number | Meaning
0xC00D0011 | This method cannot be called if the encoder engine is running.

See Also

  • IWMEncTransformCollection.Add
  • IWMEncTransformCollection Object
  • IWMEncTransformCollection.RemoveAll


IWMEncTransformCollection.RemoveAll

The RemoveAll method removes all plug-ins from the collection.

Syntax

IWMEncTransformCollection.RemoveAll

Parameters

This method takes no parameters.

Return Values

If this method fails, it returns an error number.

Number | Meaning
0xC00D0011 | This method cannot be called if the encoder engine is running.

See Also

  • IWMEncTransformCollection Object
  • IWMEncTransformCollection.Remove


IWMEncTransformPluginInfoManager Object

The IWMEncTransformPluginInfoManager object searches the plug-in registration information to populate a collection of transform IWMEncPluginInfo objects. The IWMEncTransformPluginInfoManager object exposes the following properties and methods.

Property | Description
Count | Retrieves the number of registered transform plug-ins.
length | Retrieves the number of registered transform plug-ins. This is the JScript version of the Count property.

Method | Description
Item | Retrieves registry information about a specific transform plug-in object in the collection.
Refresh | Removes the old collection and populates a new collection of transform plug-in registration structures.

See Also

  • [Visual C++] IWMEncTransformPluginInfoManager Interface
  • IWMEncPluginInfo Object
  • Objects (Visual Basic)


IWMEncTransformPluginInfoManager.Count

The Count property retrieves the number of registered transform plug-ins.

Syntax

Long = IWMEncTransformPluginInfoManager.Count

Parameters

This property takes no parameters.

Return Values

When getting the value, this property returns a LONG containing the number of plug-ins.

Remarks

This property is read-only. This is the Visual Basic version of the JScript length property.

Example Code

' Create a WMEncoder object and retrieve an
' IWMEncTransformPluginInfoManager from it.
Dim Encoder As WMEncoder
Set Encoder = New WMEncoder
Dim TransPlugMgr As IWMEncTransformPluginInfoManager
Set TransPlugMgr = Encoder.TransformPluginInfoManager

' Loop through the transform plug-in collection. Call the Item
' method on each plug-in to retrieve an IWMEncPluginInfo object.
' Use the IWMEncPluginInfo object to retrieve information
' about the plug-in.

Dim PlugInfo As IWMEncPluginInfo
Dim Scheme As String
Dim sCLSID As String
Dim sCopyright As String
Dim bExclusive As Boolean
Dim bHidden As Boolean
Dim bResources As Boolean
Dim pPropPage As Boolean
Dim sURL As String
Dim enumMediaType As WMENC_SOURCE_TYPE
Dim enumPluginType As WMENC_PLUGIN_TYPE
Dim sName As String

For PluginIndex = 0 To TransPlugMgr.Count - 1
    Set PlugInfo = TransPlugMgr.Item(PluginIndex)

    ' Retrieve the plug-in scheme type.
    Scheme = PlugInfo.SchemeType

    ' Determine whether the plug-in supports resources.
    bResources = PlugInfo.Resources

    ' Retrieve the plug-in GUID.
    sCLSID = PlugInfo.CLSID

    ' Retrieve the copyright information.
    sCopyright = PlugInfo.Copyright

    ' Determine whether the plug-in can be used
    ' more than once in a source group.
    bExclusive = PlugInfo.Exclusive

    ' Determine whether the plug-in is hidden
    ' from the UI.
    bHidden = PlugInfo.Hidden

    ' Retrieve the URL, if any, of the Web site
    ' containing information about the plug-in.
    sURL = PlugInfo.InfoURL

    ' Retrieve the media types supported by the
    ' plug-in. This is a bitwise OR of the
    ' WMENC_SOURCE_TYPE enumeration type.
    enumMediaType = PlugInfo.MediaType

    ' Retrieve the name of the plug-in.
    sName = PlugInfo.Name

    ' Determine whether the plug-in is a source or
    ' transform type.
    enumPluginType = PlugInfo.PluginType

    ' Determine whether the plug-in supports
    ' property pages.
    bPropPage = PlugInfo.PropertyPage

Next

' Continue configuring the encoder engine.

See Also

  • IWMEncTransformPluginInfoManager.length
  • IWMEncTransformPluginInfoManager Object


IWMEncTransformPluginInfoManager.length

The length property retrieves the number of registered transform plug-ins.

Syntax

Long = IWMEncTransformPluginInfoManager.length

Parameters

This property takes no parameters.

Return Values

When getting the value, this property returns a LONG.

Remarks

This property is read-only. This is the JScript version of the Count property. It is provided for JScript developers or developers more accustomed to the JScript syntax.

Example Code

' Create a WMEncoder object and retrieve an
' IWMEncTransformPluginInfoManager from it.
Dim Encoder As WMEncoder
Set Encoder = New WMEncoder
Dim TransPlugMgr As IWMEncTransformPluginInfoManager
Set TransPlugMgr = Encoder.TransformPluginInfoManager

' Loop through the transform plug-in collection. Call the Item
' method on each plug-in to retrieve an IWMEncPluginInfo object.
' Use the IWMEncPluginInfo object to retrieve information
' about the plug-in.

Dim PlugInfo As IWMEncPluginInfo
Dim Scheme As String
Dim sCLSID As String
Dim sCopyright As String
Dim bExclusive As Boolean
Dim bHidden As Boolean
Dim bResources As Boolean
Dim pPropPage As Boolean
Dim sURL As String
Dim enumMediaType As WMENC_SOURCE_TYPE
Dim enumPluginType As WMENC_PLUGIN_TYPE
Dim sName As String

For PluginIndex = 0 To TransPlugMgr.Count - 1
    Set PlugInfo = TransPlugMgr.Item(PluginIndex)

    ' Retrieve the plug-in scheme type.
    Scheme = PlugInfo.SchemeType

    ' Determine whether the plug-in supports resources.
    bResources = PlugInfo.Resources

    ' Retrieve the plug-in GUID.
    sCLSID = PlugInfo.CLSID

    ' Retrieve the copyright information.
    sCopyright = PlugInfo.Copyright

    ' Determine whether the plug-in can be used
    ' more than once in a source group.
    bExclusive = PlugInfo.Exclusive

    ' Determine whether the plug-in is hidden
    ' from the UI.
    bHidden = PlugInfo.Hidden

    ' Retrieve the URL, if any, of the Web site
    ' containing information about the plug-in.
    sURL = PlugInfo.InfoURL

    ' Retrieve the media types supported by the
    ' plug-in. This is a bitwise OR of the
    ' WMENC_SOURCE_TYPE enumeration type.
    enumMediaType = PlugInfo.MediaType

    ' Retrieve the name of the plug-in.
    sName = PlugInfo.Name

    ' Determine whether the plug-in is a source or
    ' transform type.
    enumPluginType = PlugInfo.PluginType

    ' Determine whether the plug-in supports
    ' property pages.
    bPropPage = PlugInfo.PropertyPage

Next

' Continue configuring the encoder engine.

See Also

  • IWMEncTransformPluginInfoManager.Count
  • IWMEncTransformPluginInfoManager Object


IWMEncTransformPluginInfoManager.Item

The Item method retrieves registry information about a specific transform plug-in object in the collection.

Syntax

IWMEncPluginInfo = IWMEncTransformPluginInfoManager.Item ( iIndex )

Parameters

iIndex

[in] LONG containing the numeric index of the plug-in.

Return Values

This method returns an IWMEncPluginInfo object.

Example Code

' Create a WMEncoder object and retrieve an
' IWMEncTransformPluginInfoManager from it.
Dim Encoder As WMEncoder
Set Encoder = New WMEncoder
Dim TransPlugMgr As IWMEncTransformPluginInfoManager
Set TransPlugMgr = Encoder.TransformPluginInfoManager

' Loop through the transform plug-in collection. Call the Item
' method on each plug-in to retrieve an IWMEncPluginInfo object.
' Use the IWMEncPluginInfo object to retrieve information
' about the plug-in.

Dim PlugInfo As IWMEncPluginInfo
Dim Scheme As String
Dim sCLSID As String
Dim sCopyright As String
Dim bExclusive As Boolean
Dim bHidden As Boolean
Dim bResources As Boolean
Dim pPropPage As Boolean
Dim sURL As String
Dim enumMediaType As WMENC_SOURCE_TYPE
Dim enumPluginType As WMENC_PLUGIN_TYPE
Dim sName As String

For PluginIndex = 0 To TransPlugMgr.Count - 1
    Set PlugInfo = TransPlugMgr.Item(PluginIndex)

    ' Retrieve the plug-in scheme type.
    Scheme = PlugInfo.SchemeType

    ' Determine whether the plug-in supports resources.
    bResources = PlugInfo.Resources

    ' Retrieve the plug-in GUID.
    sCLSID = PlugInfo.CLSID

    ' Retrieve the copyright information.
    sCopyright = PlugInfo.Copyright

    ' Determine whether the plug-in can be used
    ' more than once in a source group.
    bExclusive = PlugInfo.Exclusive

    ' Determine whether the plug-in is hidden
    ' from the UI.
    bHidden = PlugInfo.Hidden

    ' Retrieve the URL, if any, of the Web site
    ' containing information about the plug-in.
    sURL = PlugInfo.InfoURL

    ' Retrieve the media types supported by the
    ' plug-in. This is a bitwise OR of the
    ' WMENC_SOURCE_TYPE enumeration type.
    enumMediaType = PlugInfo.MediaType

    ' Retrieve the name of the plug-in.
    sName = PlugInfo.Name

    ' Determine whether the plug-in is a source or
    ' transform type.
    enumPluginType = PlugInfo.PluginType

    ' Determine whether the plug-in supports
    ' property pages.
    bPropPage = PlugInfo.PropertyPage

Next

' Continue configuring the encoder engine.

See Also

  • IWMEncPluginInfo Object
  • IWMEncTransformPluginInfoManager Object


IWMEncTransformPluginInfoManager.Refresh

The Refresh method removes the old collection and populates a new collection of transform plug-in registration structures.

Syntax

IWMEncTransformPluginInfoManager.Refresh

Parameters

This method takes no parameters.

Return Values

This method does not return a value.

Remarks

Because you cannot register new plug-ins in the current version of Windows Media Encoder, the Refresh method provides no useful functionality.

See Also

  • IWMEncTransformPluginInfoManager Object


IWMEncVideoSource Object

The IWMEncVideoSource object manages video image cropping to eliminate the bad pixels that often occur at the edges of video streams and imported images. Windows Media Encoder adjusts the cropped image to fill the destination size specified in the associated profile.

In addition to the properties inherited from the IWMEncSource object the IWMEncVideoSource object exposes the following properties.

Property | Description
CroppingBottomMargin | Specifies and retrieves the number of pixels to be removed from the bottom edge of an image.
CroppingLeftMargin | Specifies and retrieves the number of pixels to be removed from the left edge of an image.
CroppingMode | Specifies and retrieves a member of an enumeration type that identifies the image cropping mode.
CroppingRightMargin | Specifies and retrieves the number of pixels to be removed from the right edge of an image.
CroppingTopMargin | Specifies and retrieves the number of pixels to be removed from the top edge of an image.
Optimization | Specifies and retrieves the type of video optimization performed during the encoding process.
PixelFormat | Specifies and retrieves the pixel format for the video image.

See Also

  • [Visual C++] IWMEncVideoSource Interface
  • IWMEncSource Object
  • Objects (Visual Basic)


IWMEncVideoSource.CroppingBottomMargin

The CroppingBottomMargin property specifies and retrieves the number of pixels to be removed from the bottom edge of an image.

Syntax

IWMEncVideoSource.CroppingBottomMargin = Long
Long = IWMEncVideoSource.CroppingBottomMargin

Parameters

This property takes no parameters.

Return Values

When getting the value, this property returns a LONG containing the number of pixels to be cropped.

If this property fails, it returns an error number.

Number | Meaning
0xC00D0011 | This method cannot be called if the encoder engine is running.

Example Code

' Create a WMEncoder object.
Dim Encoder As WMEncoder
Set Encoder = New WMEncoder

' Specify the source for the input stream.
Dim SrcGrpColl As IWMEncSourceGroupCollection
Dim SrcGrp As IWMEncSourceGroup
Dim SrcVid As IWMEncVideoSource
Dim SrcAud As IWMEncSource

' Add a source group to the collection.
Set SrcGrpColl = Encoder.SourceGroupCollection
Set SrcGrp = SrcGrpColl.Add("SG_1")

' Add a video and audio source to the source group.
Set SrcVid = SrcGrp.AddSource(WMENC_VIDEO)
Set SrcAud = SrcGrp.AddSource(WMENC_AUDIO)

' Specify the cropping margins.
VidSrc.CroppingBottomMargin = 5
VidSrc.CroppingTopMargin = 5
VidSrc.CroppingLeftMargin = 3
VidSrc.CroppingRightMargin = 3

' Continue configuring Windows Media Encoder.

See Also

  • IWMEncVideoSource Object


IWMEncVideoSource.CroppingLeftMargin

The CroppingLeftMargin property specifies and retrieves the number of pixels to be removed from the left edge of an image.

Syntax

IWMEncVideoSource.CroppingLeftMargin = Long
Long = IWMEncVideoSource.CroppingLeftMargin

Parameters

This property takes no parameters.

Return Values

When getting the value, this property returns a LONG containing the number of pixels to crop.

If this property fails, it returns an error number.

Number | Meaning
0xC00D0011 | This method cannot be called if the encoder engine is running.

Example Code

' Create a WMEncoder object.
Dim Encoder As WMEncoder
Set Encoder = New WMEncoder

' Specify the source for the input stream.
Dim SrcGrpColl As IWMEncSourceGroupCollection
Dim SrcGrp As IWMEncSourceGroup
Dim SrcVid As IWMEncVideoSource
Dim SrcAud As IWMEncSource

' Add a source group to the collection.
Set SrcGrpColl = Encoder.SourceGroupCollection
Set SrcGrp = SrcGrpColl.Add("SG_1")

' Add a video and audio source to the source group.
Set SrcVid = SrcGrp.AddSource(WMENC_VIDEO)
Set SrcAud = SrcGrp.AddSource(WMENC_AUDIO)

' Specify the cropping margins.
VidSrc.CroppingBottomMargin = 5
VidSrc.CroppingTopMargin = 5
VidSrc.CroppingLeftMargin = 3
VidSrc.CroppingRightMargin = 3

' Continue configuring Windows Media Encoder.

See Also

  • IWMEncVideoSource Object


IWMEncVideoSource.CroppingMode

The CroppingMode property specifies and retrieves a member of an enumeration type that identifies the image cropping mode.

Syntax

IWMEncVideoSource.CroppingMode = WMENC_CROPPING_MODE
WMENC_CROPPING_MODE = IWMEncVideoSource.CroppingMode

Parameters

This property takes no parameters.

Return Values

When getting the value, this property returns a WMENC_CROPPING_MODE enumeration type specifying the cropping mode. This must be the following value.

Value | Number | Description
WMENC_CROPPING_ABSOLUTE | 0 | The amount of an image to crop must be specified as an absolute number of pixels.

If this property fails, it returns an error number.

Number | Meaning
0xC00D0011 | This method cannot be called if the encoder engine is running.

See Also

  • IWMEncVideoSource Object


IWMEncVideoSource.CroppingRightMargin

The CroppingRightMargin property specifies and retrieves the number of pixels to be removed from the right edge of an image.

Syntax

IWMEncVideoSource.CroppingRightMargin = Long
Long = IWMEncVideoSource.CroppingRightMargin

Parameters

This property takes no parameters.

Return Values

When getting the value, this property returns a LONG containing the number of pixels to crop.

If this property fails, it returns an error number.

Number | Meaning
0xC00D0011 | This method cannot be called if the encoder engine is running.

Example Code

' Create a WMEncoder object.
Dim Encoder As WMEncoder
Set Encoder = New WMEncoder

' Specify the source for the input stream.
Dim SrcGrpColl As IWMEncSourceGroupCollection
Dim SrcGrp As IWMEncSourceGroup
Dim SrcVid As IWMEncVideoSource
Dim SrcAud As IWMEncSource

' Add a source group to the collection.
Set SrcGrpColl = Encoder.SourceGroupCollection
Set SrcGrp = SrcGrpColl.Add("SG_1")

' Add a video and audio source to the source group.
Set SrcVid = SrcGrp.AddSource(WMENC_VIDEO)
Set SrcAud = SrcGrp.AddSource(WMENC_AUDIO)

' Specify the cropping margins.
VidSrc.CroppingBottomMargin = 5
VidSrc.CroppingTopMargin = 5
VidSrc.CroppingLeftMargin = 3
VidSrc.CroppingRightMargin = 3

' Continue configuring Windows Media Encoder.

See Also

  • IWMEncVideoSource Object


IWMEncVideoSource.CroppingTopMargin

The CroppingTopMargin property specifies and retrieves the number of pixels to be removed from the top edge of an image.

Syntax

IWMEncVideoSource.CroppingTopMargin = Long
Long = IWMEncVideoSource.CroppingTopMargin

Parameters

This property takes no parameters.

Return Values

When getting the value, this property returns a LONG containing the number of pixels to crop.

If this property fails, it returns an error number.

Number | Meaning
0xC00D0011 | This method cannot be called if the encoder engine is running.

Example Code

' Create a WMEncoder object.
Dim Encoder As WMEncoder
Set Encoder = New WMEncoder

' Specify the source for the input stream.
Dim SrcGrpColl As IWMEncSourceGroupCollection
Dim SrcGrp As IWMEncSourceGroup
Dim SrcVid As IWMEncVideoSource
Dim SrcAud As IWMEncSource

' Add a source group to the collection.
Set SrcGrpColl = Encoder.SourceGroupCollection
Set SrcGrp = SrcGrpColl.Add("SG_1")

' Add a video and audio source to the source group.
Set SrcVid = SrcGrp.AddSource(WMENC_VIDEO)
Set SrcAud = SrcGrp.AddSource(WMENC_AUDIO)

' Specify the cropping margins.
VidSrc.CroppingBottomMargin = 5
VidSrc.CroppingTopMargin = 5
VidSrc.CroppingLeftMargin = 3
VidSrc.CroppingRightMargin = 3

' Continue configuring Windows Media Encoder.

See Also

  • IWMEncVideoSource Object


IWMEncVideoSource.Optimization

The Optimization property specifies and retrieves the type of video optimization performed during the encoding process..

Syntax

IWMEncVideoSource.Optimization = WMENC_VIDEO_OPTIMIZATION
WMENC_VIDEO_OPTIMIZATION = IWMEncVideoSource.Optimization

Parameters

This property takes no parameters.

Return Values

When getting the value, this property returns a member of a WMENC_VIDEO_OPTIMIZATION enumeration type that indicates the encoding optimization. This must be one of the following values.

Return code | Number | Meaning
WMENC_VIDEO_STANDARD | 1 | Applies the standard compression algorithm during the encoding process.
WMENC_VIDEO_DEINTERLACE | 2 | Separates the interlaced video source to restore the original frames.
WMENC_VIDEO_INVERSETELECINE | 3 | Removes redundant video data from the video source.

If this property fails, it returns an error number.

Number | Meaning
0x80070057 | The video optimization specified is not valid.
0xC00D0011 | This method cannot be called if the encoder engine is running.

Remarks

Television signals are interlaced by combining two frames into one image. Windows Media Encoder can separate the frames to restore the original content. When film is translated to a digital format, frames may be added using the telecine process to increase the frame rate. Windows Media Encoder can eliminate the redundant frames. In both cases, Windows Media Encoder uses optimization to produce higher quality output. However, you must choose the correct optimization for the content being encoded.

See Also

  • IWMEncVideoSource Object


IWMEncVideoSource.PixelFormat

The PixelFormat property specifies and retrieves the pixel format for the video image.

Syntax

IWMEncVideoSource.PixelFormat = WMENC_PIXELFORMAT_VIDEO
WMENC_PIXELFORMAT_VIDEO = IWMEncVideoSource.PixelFormat

Parameters

This property takes no parameters.

Return Values

When getting the value, this property returns a member of a WMENC_PIXELFORMAT_VIDEO enumeration type that identifies the pixel format. This must be one of the following values.

Return code | Number | Meaning
WMENC_PIXELFORMAT_AUTO | 0x00000001 | Windows Media Encoder chooses the current format of the video image. This is the default value.
WMENC_PIXELFORMAT_IYUV | 0x56555949 | The IYUV format.
WMENC_PIXELFORMAT_I420 | 0x30323449 | The I420 format.
WMENC_PIXELFORMAT_YV12 | 0x32315659 | The YV12 format.
WMENC_PIXELFORMAT_YUY2 | 0x32595559 | The YUY2 format.
WMENC_PIXELFORMAT_UYVY | 0x59565955 | The UYVY format.
WMENC_PIXELFORMAT_YVYU | 0x55595659 | The YVYU format.
WMENC_PIXELFORMAT_YVU9 | 0x39555659 | The YVU9 format.
WMENC_PIXELFORMAT_RGB24 | 0xE436EB7D | The RGB24 format.
WMENC_PIXELFORMAT_RGB32 | 0xE436EB7E | The RGB32 format.
WMENC_PIXELFORMAT_RGB555 | 0xE436EB7C | The RGB555 format.
WMENC_PIXELFORMAT_RGB565 | 0xE436EB7B | The RGB565 format.
WMENC_PIXELFORMAT_RGB8 | 0xE436EB7A | The RGB8 format.
WMENC_PIXELFORMAT_RGB4 | 0xE436EB79 | The RGB4 format.
WMENC_PIXELFORMAT_RGB1 | 0xE436EB78 | The RGB1 format.

If this property fails, it returns an error number.

Number | Meaning
0x80070057 | The video optimization specified is not valid.
0xC00D0011 | This method cannot be called if the encoder engine is running.

Remarks

The formats are listed in the order of decreasing preference for use in Windows Media Encoder.

See Also

  • IWMEncVideoSource Object


WMEncoder Object

The WMEncoder object runs Windows Media Encoder. If you are implementing the predefined user interface, you must create a WMEncoder object through a WMEncoderApp object. If you are not implementing a UI or are implementing a custom UI, you must independently create a WMEncoder object. The WMEncoder object exposes the following properties and methods.

Property | Description
ArchiveState | Retrieves a member of an enumeration type indicating whether the archiving process is running.
Attributes | Retrieves a collection of user-defined name-value pairs.
AutoIndex | Specifies and retrieves a Boolean value indicating whether the archive file will be indexed after the archiving process is completed.
AutoStop | Specifies and retrieves a Boolean value that indicates whether the encoding process will be automatically stopped after source content from an audio/visual file has been completely encoded to a Windows Media file.
Broadcast | Retrieves the port number and protocol for broadcasting encoded content.
DisplayInfo | Retrieves a description of the encoded content. Typically this includes author, copyright, rating and title information.
EnableAutoArchive | Specifies and retrieves a Boolean value indicating whether the archiving process will start automatically when the encoder engine starts.
ErrorState | Retrieves Windows Media Encoder run-time errors.
File | Retrieves an IWMEncFile object that can be used to specify the name of an archive file.
IndexerState | Retrieves the state of the indexing process.
Name | Retrieves the unique name of a WMEncoder object for remote administration.
ProfileCollection | Retrieves the collection of profiles.
RecordingLevel | Specifies and retrieves the volume level of a specific audio source stream.
RecordingMute | Specifies and retrieves a Boolean value indicating whether a specific audio stream is muted.
RemoteAdmin | Retrieves a Boolean value indicating whether Windows Media Encoder can be remotely controlled.
RunState | Retrieves a member of an enumeration type indicating whether the encoder is running.
SourceGroupCollection | Retrieves the collection of source groups.
SourcePluginInfoManager | Retrieves a collection of objects that contain source plug-in information.
Statistics | Retrieves a statistics object that can be used to provide status information about the encoding session.
TransformPluginInfoManager | Retrieves a collection of objects that contain transform plug-in information.

Method | Description
Archive | Starts, pauses, or stops the archiving process.
GenerateBroadcastInfo | Configures the encoder engine to facilitate the creation of a multicast publishing point.
GetAudioLevel | Retrieves the minimum, average, and maximum volume for the left and right channels of an audio source stream.
Indexer | Cancels the indexing process before it is complete.
Load | Loads an existing configuration from a file.
PrepareToEncode | Prepares the encoder engine for starting.
Reset | Eliminates the current configuration settings.
Save | Saves the current configuration to a file.
SendScript | Sends script to Windows Media Encoder.
SetLocaleID | Specifies the national language displayed in the user interface.
Start | Starts Windows Media Encoder.
Stop | Stops Windows Media Encoder.

See Also

  • [Visual C++] IWMEncoder Interface
  • Objects (Visual Basic)
  • WMEncoderApp Object


WMEncoder.ArchiveState

The ArchiveState property retrieves a member of an enumeration type indicating whether content is being archived.

Syntax

WMENC_ARCHIVE_OPERATION = WMEncoder.ArchiveState( enumType )

Parameters

enumType

[in] Member of a WMENC_ARCHIVE_TYPE enumeration type indicating where encoded content is stored. This parameter must be the following value.

Value | Number | Meaning
WMENC_ARCHIVE_LOCAL | 1 | Encoded content is saved on the computer performing the encoding or the local network to which that computer is connected.

Return Values

When getting the value, this property returns a member of a WMENC_ARCHIVE_OPERATION enumeration type indicating whether the archiving process has been started or stopped. This must be one of the following values.

Return code | Number | Meaning
WMENC_ARCHIVE_RUNNING | 1 | The archiving process is running.
WMENC_ARCHIVE_PAUSED | 2 | The archiving process has paused.
WMENC_ARCHIVE_STOPPED | 3 | The archiving process has stopped.

If this property fails, it returns an error number.

Number | Meaning
0xC00D1B77 | You can only specify WMENC_ARCHIVE_LOCAL as the archive type.

Example Code

' Windows Media Encoder must be archiving to a file. See either
' the IWMEncFile object or the IWMEncFileArchiveStats object
' for a complete example of the archiving process.
Private Sub ArchivingState()
    Select Case Encoder.ArchiveState(WMENC_ARCHIVE_LOCAL)
        Case WMENC_ARCHIVE_RUNNING
          ' Process the case.
        Case WMENC_ARCHIVE_PAUSED
          ' Process the case.
        Case WMENC_ARCHIVE_STOPPED
..........' Process the case.
        Case Else
          ' None of the above.
    End Select
End Sub

See Also

  • IWMEncFile Object
  • IWMEncFileArchiveStats Object
  • WMEncoder.Archive
  • WMEncoder Object


WMEncoder.Attributes

The Attributes property retrieves a collection of user-defined name-value pairs.

Syntax

IWMEncAttributes = WMEncoder.Attributes

Parameters

This property takes no parameters.

Return Values

This property returns an IWMEncAttributes object containing a collection of attributes.

Remarks

Attributes are name-value pairs representing extra information about the output of the encoder or the encoding session. They are defined by the author and stored in an attributes collection. Both the name and the value are BSTR types.

Example Code

' Create a WMEncoder object.
Dim Encoder As WMENcoder
Set Encoder = New WMEncoder

' Retrieve an IWMEncAttributes object.
Dim Attr As IWMEncAttributes
Set Attr = Encoder.Attributes
Dim i As Integer
Dim strName As String
Dim strValue As String

' Add three custom attributes to the collection.
Attr.Add "Date created: ", "02/15/2000"
Attr.Add "Time created: ", "13:30:15"
Attr.Add "File content: ", "multimedia data"

' View the attributes in the collection.
For i = 0 To Attr.Count - 1
  strValue = Attr.Item(i, strName)
Next

' Remove an attribute by name.
Attr.Remove ("File content: ")

' Remove an attribute by index.
Attr.Remove (0)

' Remove any remaining attributes.
Attr.RemoveAll

See Also

  • IWMEncAttributes Object
  • WMEncoder Object


WMEncoder.AutoIndex

The AutoIndex property specifies and retrieves a Boolean value indicating whether the archive file will be indexed after the encoding process is complete.

Syntax

WMEncoder.AutoIndex = VARIANT_BOOL
VARIANT_BOOL = WMEncoder.AutoIndex

Parameters

This property takes no parameters.

Return Values

When getting the value, this property returns a VARIANT_BOOL indicating whether the encoded content will be automatically indexed after it is archived.

Example Code

' Create a WMEncoder object.
Dim Encoder As WMEncoder
Set Encoder = New WMEncoder
Dim bAutoIndex As Boolean

' Configure Windows Media Encoder to archive encoded content.
' For a complete example, see either the IWMEncFile object or the
' IWMEncFileArchiveStats object.

' Specify the AutoIndex property.
Encoder.AutoIndex = True

' Retrieve the Boolean value.
bAutoIndex = Encoder.AutoIndex

See Also

  • IWMEncFile Object
  • IWMEncFileArchiveStats Object
  • WMEncoder Object


WMEncoder.AutoStop

The AutoStop property specifies and retrieves a Boolean value that indicates whether the encoding process will be automatically stopped after source content from an audio/visual file has been completely encoded to a Windows Media file.

Syntax

WMEncoder.AutoStop = VARIANT_BOOL
VARIANT_BOOL = WMEncoder.AutoStop

Parameters

This property takes no parameters.

Return Values

When getting the value, this property returns a VARIANT_BOOL identifying whether the encoder engine automatically stops.

Remarks

The AutoStop property defaults to VARIANT_TRUE. The Boolean value can be changed while Windows Media Encoder is running.

Example Code

' Create a WMEncoder object.
Dim Encoder As WMEncoder
Set Encoder = New WMEncoder

Set Encoder = New WMEncoder
Dim bAutoStop As Boolean

' Configure Windows Media Encoder to archive encoded content.
' For a complete example, see either the IWMEncFile object or the
' IWMEncFileArchiveStats object.

' Set the property
Encoder.AutoStop = True
' Returning the property
bAutoStop = Encoder.AutoStop

See Also

  • IWMEncFile Object
  • IWMEncFileArchiveStats Object
  • WMEncoder Object


WMEncoder.Broadcast

The Broadcast property retrieves the port number and protocol for broadcasting encoded content.

Syntax

IWMEncBroadcast = WMEncoder.Broadcast

Parameters

This property takes no parameters.

Return Values

When getting the value, this property returns an IWMEncBroadcast object.

Remarks

Use this method to acquire a broadcast object so that you can specify and retrieve the port number and protocol used for transmitting encoded content. Currently, only HTTP can be used. The default port number is 80, but other ports can be used.

Example Code

' Create a WMEncoder object.
Dim Encoder As WMEncoder
Set Encoder = New WMEncoder

' Retrieve a WMEncBroadcast object from the WMEncoder object.
Dim Broadcast As IWMEncBroadcast
Dim PortNumber As Integer
Set Broadcast = Encoder.Broadcast

' Configure Windows Media Encoder to archive encoded content.
' For a complete example, see either the IWMEncFile object or the
' IWMEncFileArchiveStats object.

' Setting the property
Broadcast.PortNumber(WMENC_PROTOCOL_HTTP) = 2356

' Returning the property
PortNumber = Broadcast.PortNumber(WMENC_PROTOCOL_HTTP)

See Also

  • IWMEncBroadcast Object
  • IWMEncFile Object
  • IWMEncFileArchiveStats Object
  • WMEncoder Object


WMEncoder.DisplayInfo

The DisplayInfo property retrieves a description of the encoded content. Typically this includes author, copyright, rating and title information.

Syntax

IWMEncDisplayInfo = WMEncoder.DisplayInfo

Parameters

This property takes no parameters.

Return Values

When getting the value, this property returns an IWMEncDisplayInfo object containing string descriptions of the encoded content.

Remarks

Use the IWMEncDisplayInfo object to set or retrieve the name of the author, copyright data, a general content description, a rating and a title.

Example Code

' Create a WMEncoder object.
Dim Encoder As WMEncoder
Set Encoder = New WMEncoder

' Retrieve an IWMEncDisplayInfo object
Dim DispInfo As IWMEncDisplayInfo
Set DispInfo = Encoder.DisplayInfo

' Declare string variables.
Dim strAuthor As String
Dim strCopyright As String
Dim strDescription As String
Dim strRating As String
Dim strTitle As String

' Set the IWMEncDisplayInfo properties
DispInfo.Author = "Content author's name."
DispInfo.Copyright = "Copyright 2000. All rights reserved."
DispInfo.Description = "Description of the encoded content."
DispInfo.Rating = "Not applicable."
DispInfo.Title = "Title of the encoded content."

' Retrieve the IWMEncDisplayInfo properties
strAuthor = DispInfo.Author
strCopyright = DispInfo.Copyright
strDescription = DispInfo.Description
strRating = DispInfo.Rating
strTitle = DispInfo.Title

See Also

  • IWMEncDisplayInfo Object
  • WMEncoder Object


WMEncoder.EnableAutoArchive

The EnableAutoArchive property specifies and retrieves a Boolean value indicating whether the archiving process will start automatically when the encoder engine starts.

Syntax

WMEncoder.EnableAutoArchive = VARIANT_BOOL
VARIANT_BOOL = WMEncoder.EnableAutoArchive

Parameters

This property takes no parameters.

Return Values

When getting the value, this property returns a VARIANT_BOOL indicating whether archiving is automatic.

Remarks

Use the IWMEncSourceGroup.AutoArchive property to automatically control source group archiving. If both the EnableAutoArchive and AutoArchive properties. are set to True, archiving automatically starts when encoding starts.

Example Code

' Create a WMEncoder object. To handle the events raised by the
' WMEncoder object, use the WithEvents keyword.
Dim WithEvents Encoder As WMEncoder
Set Encoder = New WMEncoder

' Declare objects and variables.
Dim SrcGrpColl As IWMEncSourceGroupCollection
Dim SrcGrp As IWMEncSourceGroup
Dim AudSrc As IWMEncSource
Dim VidSrc As IWMEncVideoSource
Dim ProColl As IWMEncProfileCollection
Dim Pro As IWMEncProfile
Dim File As IWMEncFile
Dim i As Integer

' Create an IWMEncSourceGroupCollection object.
Set SrcGrpColl = Encoder.SourceGroupCollection

' Create an IWMEncSourceGroup object.
Set SrcGrp = SrcGrpColl.Add("SG_1")

' Create a video and an audio source object.
Set AudSrc = SrcGrp.AddSource(WMENC_AUDIO)
Set VidSrc = SrcGrp.AddSource(WMENC_VIDEO)

' Create an IWMEncFile object.
Set File = Encoder.File

' Specify the .avi source file.
AudSrc.SetInput "C:\file_name.avi"
VidSrc.SetInput "C:\file_name.avi"

' Specify the output Windows Media file.
File.LocalFileName = "C:\file_name.wmv"

' Loop through the collection of system profiles to set
' a specific profile into the source group object.
Set ProColl = Encoder.ProfileCollection
For i = 0 To ProColl.Count - 1
    Set Pro = ProColl.Item(i)
    If Pro.Name = "name of a system profile" Then
        SrcGrp.Profile = ProColl.Item(i)
        Exit For
    End If
Next

' Tell the encoder to start archiving when the encoder
' engine starts running.
Encoder.EnableAutoArchive = True

' Retrieve the Boolean value.
Dim bAutoArchive As Boolean
bAuroarchive = Encoder.EnableAutoArchive

' Initialize the encoder engine.
Encoder.PrepareToEncode True

' Start the encoder engine.
Encoder.Start

See Also

  • IWMEncSourceGroup.AutoArchive
  • IWMEncFile Object
  • IWMEncFileArchiveStats Object
  • WMEncoder Object


WMEncoder.ErrorState

The ErrorState property retrieves Windows Media Encoder run-time errors.

Syntax

Long = WMEncoder.ErrorState

Parameters

This property takes no parameters.

Return Values

When getting the value, this property returns a LONG containing the error value.

Remarks

Use this method to retrieve errors that occur during Windows Media Encoder operation. The OnError method in the _IWMEncoderEvents object also provides similar functionality. Use the WMEncoder.RunState property to determine if Windows Media Encoder is stopped or started.

Example Code

' Create a WMEncoder object.
Dim Encoder As WMEncoder
Set Encoder = New WMEncoder

' Load a predefined configuration
Encoder.Load ("C:\file_name.wme")

' Start the encoder engine
Encoder.Start

' Retrieve a runtime error
Dim lError As Long
lError = Encoder.ErrorState
If lError = 123456 Then
    ' Process the error.
End If

See Also

  • _IWMEncoderEvents Object
  • _IWMEncoderEvents.OnError
  • WMEncoder Object
  • WMEncoder.RunState


WMEncoder.File

The File property retrieves an IWMEncFile object that can be used to specify the name of an archive file.

Syntax

IWMEncFile = WMEncoder.File

Parameters

This property takes no parameters.

Return Values

When getting the value, this property returns an IWMEncFile object.

Remarks

This property is read-only. Use the IWMEncFile object to specify and retrieve the file name, directory and extension.

Example Code

' Create a WMEncoder object.
Dim Encoder As WMEncoder
Set Encoder = New WMEncoder

' Load a predefined configuration.
Encoder.Load ("C:\file_name.wme")

' Retrieve an IWMEncFile object and override the name
' of the archive file specified in the predefined
' configuration.
Dim File As IWMEncFile
Set File = Encoder.File
File.LocalFileName = "C:\file_name.wmv"

See Also

  • IWMEncFile Object
  • WMEncoder Object


WMEncoder.IndexerState

The IndexerState property retrieves the state of the indexing process.

Syntax

WMENC_INDEXER_STATE = WMEncoder.IndexerState

Parameters

This property takes no parameters.

Return Values

When getting the value, this property returns a member of a WMENC_INDEXER_STATE enumeration type that specifies the state of the indexing process. This must be one of the following values

Return code | Number | Description
WMENC_INDEXER_RUNNING | 1 | The indexing process has been started.
WMENC_INDEXER_STOPPED | 2 | The indexing process has been stopped.

Remarks

This property is read-only. A file index enables operations, such as fast forwarding, that must seek to specific time offsets in a stream. If you specify an archive file, Windows Media Encoder automatically indexes that file on a separate, low priority thread running in the background immediately after the archiving process stops. You can use this property in a timer control, or you can create an event sink and use the OnIndexerStateChange method in the _IWMEncoderEvents object.

Example Code

' Check to see if the indexer is running.
Dim iIndexState As WMENC_INDEXER_STATE
iIndexState = Encoder.IndexerState
If iIndexState = WMENC_INDEXER_RUNNING Then
    ' Stop the indexing process.
    Encoder.Indexer WMENC_INDEXER_STOP
End If

See Also

  • _IWMEncoderEvents Object
  • _IWMEncoderEvents.OnIndexerStateChange
  • WMEncoder Object


WMEncoder.Name

The Name property specifies and retrieves the unique name of a WMEncoder object for remote administration.

Syntax

WMEncoder.Name = BSTR
BSTR = WMEncoder.Name

Parameters

This property takes no parameters.

Return Values

When getting the value, this property returns a BSTR containing the name.

Remarks

Each instance of the encoder engine can be assigned a name to facilitate remote administration. The name must be unique. If you create a WMEncoder object with a duplicate name, a new name is assigned.

See Also

  • WMEncoder Object
  • Remote Administration Objects (Visual Basic)


WMEncoder.PrepareToEncode

The PrepareToEncode method prepares the encoder engine for starting.

Syntax

WMEncoder.PrepareToEncode bPrepare

Parameters

bPrepare

[in] VARIANT_BOOL indicating whether to initiate a Windows Media Encoder session.

Return Values

This property does not return a value.

Remarks

The WMEncoder.Start method calls PrepareToEncode before running Windows Media Encoder. If the bPrepare parameter is TRUE, a new encoding session is created for the defined configuration. If bPrepare is FALSE, all opened source streams are closed and the encoding session is ended.

You can use the PrepareToEncode method to verify that the encoder engine is ready before you call the Start method. For example, PrepareToEncode will indicate if the specified port is not available, or a device is not ready, and so on. You can also use this method to prepare the encoder engine before switching between source groups, thereby minimizing rendering delays for the end user.

Example Code

' Create a WMEncoder object
Dim Encoder As WMEncoder
Set Encoder = New WMEncoder

' Load a predefined configuration. Configuration files
' have a .wme extension.
Encoder.Load ("C:\file_name.wme")

' Initialize the encoding session.
Encoder.PrepareToEncode True

' Close any active source streams and end the
' encoding session.

Encoder.PrepareToEncode False

See Also

  • WMEncoder Object
  • WMEncoder.Start


WMEncoder.ProfileCollection

The ProfileCollection property retrieves the collection of profiles.

Syntax

IWMEncProfileCollection = WMEncoder.ProfileCollection

Parameters

This property takes no parameters.

Return Values

This property returns an IWMEncProfileCollection object.

Remarks

Use this method to acquire an IWMEncProfileCollection object. Use the IWMEncProfileCollection object to iterate through the profile collection and retrieve a specific profile. Use the IWMEncProfile object to retrieve the name and description of a profile.

Example Code

' Create a WMEncoder object.
Dim Encoder As WMEncoder
Set Encoder = New WMEncoder

' Declare objects and variables.
Dim ProColl As IWMEncProfileCollection
Dim Pro As IWMEncProfile
Dim i As Integer

' Loop through the collection of system profiles to set
' a specific profile into the source group object.
Set ProColl = Encoder.ProfileCollection
For i = 0 To ProColl.Count - 1
    Set Pro = ProColl.Item(i)
    If Pro.Name = "profile name" Then
        SrcGrp.Profile = ProColl.Item(i)
        Exit For
    End If
Next

See Also

  • IWMEncProfile Object
  • IWMEncProfileCollection Object
  • WMEncoder Object


WMEncoder.RecordingLevel

The RecordingLevel property specifies and retrieves the volume level of a specific audio source stream.

Syntax

WMEncoder.RecordingLevel( iIndex ) = Long
Long = WMEncoder.RecordingLevel( iIndex )

Parameters

iIndex

[in] SHORT containing the index of the audio stream.

Return Values

When getting the value, this property returns a LONG containing the volume level of the audio source specified by iIndex.

Remarks

You must set the iIndex parameter to zero because Windows Media Encoder does not currently support multiple audio streams. The volume level is scaled to the actual level supported by the audio card, and must be between 0 and 100 inclusive. A value of 0 is the minimum volume the audio card supports and 100 is the maximum.

Note You can use this method only for audio devices.

Example Code

' Create a WMEncoder object
Dim Encoder As WMEncoder
Set Encoder = New WMEncoder

' Declare objects and variables.
Dim SrcGrpColl As IWMEncSourceGroupCollection
Dim SrcGrp As IWMEncSourceGroup
Dim AudSrc As IWMEncSource

' Create an IWMEncSourceGroupCollection object.
Set SrcGrpColl = Encoder.SourceGroupCollection

' Create an IWMEncSourceGroup object.
Set SrcGrp = SrcGrpColl.Add("SG_1")

' Create a video and an audio source object.
Set AudSrc = SrcGrp.AddSource(WMENC_AUDIO)

' Specify the .avi source file.
AudSrc.SetInput "C:\filename.avi"

' Retrieve the initial recording level from the device.
Dim lAudioLevel As Long
lAudioLevel = Encoder.RecordingLevel(0)

' Set the recording volume level.
Encoder.RecordingLevel(0) = 50

See Also

  • IWMEncSource Object
  • IWMEncSourceGroup Object
  • IWMEncSourceGroupCollection Object
  • WMEncoder Object


WMEncoder.RecordingMute

The RecordingMute property specifies and retrieves a Boolean value indicating whether a specific audio stream is muted.

Syntax

WMEncoder.RecordingMute( iIndex ) = VARIANT_BOOL
VARIANT_BOOL = WMEncoder.RecordingMute( iIndex )

Parameters

iIndex

[in] SHORT containing the index of the audio stream.

Return Values

When getting the value, this property returns a VARIANT_BOOL.

If this property fails, it returns an error number.

Number | Meaning
0x80070057 | The index is not valid.

Remarks

You must set the iIndex parameter to zero because Windows Media Encoder does not currently support multiple audio streams.

Example Code

' Create a WMEncoder object
Dim Encoder As WMEncoder
Set Encoder = New WMEncoder

' Declare objects and variables.
Dim SrcGrpColl As IWMEncSourceGroupCollection
Dim SrcGrp As IWMEncSourceGroup
Dim AudSrc As IWMEncSource
Dim VidSrc As IWMEncVideoSource

' Create an IWMEncSourceGroupCollection object.
Set SrcGrpColl = Encoder.SourceGroupCollection

' Create an IWMEncSourceGroup object.
Set SrcGrp = SrcGrpColl.Add("SG_1")

' Create a video and an audio source object.
Set AudSrc = SrcGrp.AddSource(WMENC_AUDIO)
Set VidSrc = SrcGrp.AddSource(WMENC_VIDEO)

' Specify the .avi source file.
AudSrc.SetInput "C:\filename.avi"
VidSrc.SetInput "C:\filename.avi"

' Determine whether the audio stream is muted. If it is not
' muted, then mute it.
Dim bRecordMute As Boolean
bRecordMute = Encoder.RecordingMute(0)
If bRecordMute = False Then
    Encoder.RecordingMute(0) = True
End If

See Also

  • IWMEncSource Object
  • IWMEncSourceGroup Object
  • IWMEncSourceGroupCollection Object
  • WMEncoder Object


WMEncoder.RemoteAdmin

The RemoteAdmin property specifies and retrieves a Boolean value indicating whether Windows Media Encoder can be controlled over a network.

Syntax

WMEncoder.RemoteAdmin = VARIANT_BOOL
VARIANT_BOOL = WMEncoder.RemoteAdmin

Parameters

This property takes no parameters.

Return Values

When getting the value, this property returns a VARIANT_BOOL indicating whether the encoder engine can be remotely controlled.

Remarks

The Boolean value defaults to TRUE, indicating that the encoder engine supports remote administration.

See Also

  • Remote Administration Objects (Visual Basic)
  • WMEncoder Object


WMEncoder.RunState

The RunState property method retrieves a member of an enumeration type indicating whether the encoder is running.

Syntax

WMENC_ENCODER_STATE = WMEncoder.RunState

Parameters

This property takes no parameters.

Return Values

This property returns a member of a WMENC_ENCODER_STATE enumeration type indicating the current operating state of the encoder. This parameter must be one of the following values.

Value | Number | Meaning
WMENC_ENCODER_STARTING | 1 | Windows Media Encoder is starting.
WMENC_ENCODER_RUNNING | 2 | Windows Media Encoder is running.
WMENC_ENCODER_STOPPING | 4 | Windows Media Encoder is stopping.
WMENC_ENCODER_STOPPED | 5 | Windows Media Encoder has been stopped.

Remarks

This property is read-only. You can use this property in a timer control, or you can create an event sink and use the OnStateChange method in the _IWMEncoderEvents object.

Example Code

' Check to see if the encoder engine is running.
Dim iEncoderState As WMENC_ENCODER_STATE
iEncoderState = Encoder.RunState
If iIndexState = WMENC_ENCODER_RUNNING Then
    ' Stop the encoding process.
    Encoder.Stop
End If

See Also

  • _IWMEncoderEvents Object
  • _IWMEncoderEvents.OnStateChange
  • WMEncoder Object


WMEncoder.SourceGroupCollection

The SourceGroupCollection property retrieves the collection of source groups.

Syntax

IWMEncSourceGroupCollection = WMEncoder.SourceGroupCollection

Parameters

This property takes no parameters.

Return Values

This property returns an IWMEncSourceGroupCollection.

Remarks

This property is read-only. Use this method to acquire an IWMEncSourceGroupCollection object. Iterate through the collection to find the desired source group or create a group and add it to the collection.

Example Code

' Create a WMEncoder object.
Dim Encoder As WMEncoder
Set Encoder = New WMEncoder

' Declare objects and variables.
Dim SrcGrpColl As IWMEncSourceGroupCollection
Dim SrcGrp As IWMEncSourceGroup
Dim AudSrc As IWMEncSource
Dim VidSrc As IWMEncVideoSource

' Create an IWMEncSourceGroupCollection object.
Set SrcGrpColl = Encoder.SourceGroupCollection

' Create an IWMEncSourceGroup object.
Set SrcGrp = SrcGrpColl.Add("SG_1")

' Create a video and an audio source object.
Set AudSrc = SrcGrp.AddSource(WMENC_AUDIO)
Set VidSrc = SrcGrp.AddSource(WMENC_VIDEO)

' Specify the .avi source file.
AudSrc.SetInput "C:\filename.avi"
VidSrc.SetInput "C:\filename.avi"

See Also

  • IWMEncSource Object
  • IWMEncSourceGroup Object
  • IWMEncSourceGroupCollection Object
  • WMEncoder Object


WMEncoder.SourcePluginInfoManager

The SourcePluginInfoManager property retrieves a collection of objects that contain source plug-in information.

Syntax

IWMEncSourcePluginInfoManager = WMEncoder.SourcePluginInfoManager

Parameters

This property takes no parameters.

Return Values

When getting the value, this property returns an IWMEncSourcePluginInfoManager object.

Remarks

This property is read-only. See the IWMEncPluginInfo object to examine the available registry information.

Example Code

' Declarations
Dim Encoder As WMEncoder
Dim PluginIndex As Integer
Dim ResourceIndex As Integer
Dim Scheme As String
Dim Resource As String
Dim SrcPlugMgr As IWMEncSourcePluginInfoManager
Dim PlugInfo As IWMEncPluginInfo

' Create a WMEncoder object and retrieve an
' IWMEncSourcePluginInfoManager object from it
Set Encoder = New WMEncoder
Set SrcPlugMgr = Encoder.SourcePluginInfoManager

' Loop through the source plug-ins. Call the Item method on each
' plug-in to retrieve an IWMEncPluginInfo object. Use the
' SchemeType property to retrieve a string containing the scheme
' type of the plug-in. If the scheme type is "DEVICE" and if the
' plug-in supports resources, call the Item method to retrieve a
' string identifying the resource.
' To capture streams from an attached device, you must choose a
' specific device plug-in.
For PluginIndex = 0 To SrcPlugMgr.Count - 1
    Set PlugInfo = SrcPlugMgr.Item(PluginIndex)
    Scheme = PlugInfo.SchemeType
    If Scheme = "DEVICE" Then
        If PlugInfo.Resources = True Then
            For ResourceIndex = 0 To PlugInfo.Count - 1
                Resource = PlugInfo.Item(ResourceIndex)
            Next
        End If
    End If
Next

See Also

  • IWMEncPluginInfo Object
  • Plug-ins
  • WMEncoder Object


WMEncoder.Statistics

The Statistics property retrieves a statistics object that can be used to provide status information about the encoding session.

Syntax

IWMEncStatistics = WMEncoder.Statistics

Parameters

This property takes no parameters.

Return Values

When getting the value, this property returns an IWMEncStatistics object.

Remarks

This property is read-only.

Example Code

' Declare objects and variables.
Dim Statistics As IWMEncStatistics
Dim NetClient As IWMEncNetConnectionStats
Dim lClients As Long
Dim sAddr As String
Dim i As Integer

' Retrieve an IWMEncStatistics object and an IWMEncNetConnections
' object.
Set Statistics = Encoder.Statistics
Set NetClient = Statistics.NetConnectionStats

' Retrieve the number of clients connected.
lClients = NetClient.ClientCount

' Retrieve the IP address of each client.
For i = 1 To lClients
    sAddr = NetClient.ClientInfo(i, WMENC_PROTOCOL_HTTP)
Next

See Also

  • IWMEncNetConnectionStats Object
  • IWMEncStatistics Object
  • WMEncoder Object


WMEncoder.TransformPluginInfoManager

The TransformPluginInfoManager property retrieves a collection of objects that contain source plug-in information.

Syntax

IWMEncTransformPluginInfoManager = WMEncoder.TransformPluginInfoManager

Parameters

This property takes no parameters.

Return Values

When getting the value, this property returns an IWMEncTransformPluginInfoManager object.

Remarks

This property is read-only. See the IWMEncPluginInfo object to examine the available registry information.

Example Code

' Declarations
Dim Encoder As WMEncoder
Dim TransPlugMgr As IWMEncTransformPluginInfoManager
Dim PlugInfo As IWMEncPluginInfo

' Create a WMEncoder object and retrieve an
' IWMEncTransformPluginInfoManager from it
Set Encoder = New WMEncoder
Set TransPlugMgr = Encoder.TransformPluginInfoManager

See Also

  • IWMEncPluginInfo Object
  • IWMEncTransformPluginInfoManager Object
  • WMEncoder Object


WMEncoder.Archive

The Archive method starts, pauses, or stops the archiving process.

Syntax

WMEncoder.Archive enumArchiveType, enumArchiveOp

Parameters

enumArchiveType

[in] Member of a WMENC_ARCHIVE_TYPE enumeration type indicating where encoded content is stored. This parameter must be the following value.

Value | Number | Meaning
WMENC_ARCHIVE_LOCAL | 1 | Encoded content is saved on the computer performing the encoding or on the local network to which that computer is attached.

enumArchiveOp

[in] Member of a WMENC_ARCHIVE_OPERATION enumeration type indicating the archiving state. This parameter must be one of the following values.

Value | Number | Meaning
WMENC_ARCHIVE_START | 1 | Start archiving.
WMENC_ARCHIVE_STOP | 2 | Stop archiving.
WMENC_ARCHIVE_PAUSE | 3 | Pause archiving.

Return Values

If this method fails, it returns an error number.

Number | Meaning
0xC00D1B7F | This method cannot be called if the encoder engine is stopped.
0xC00D1B77 | You can only save encoded content to a local file.
0xC00D1B78 | You can only start, stop, or pause the archiving process.

Remarks

You can use the Archive method to override the WMEncoder.EnableAutoArchive and IWMEncSourceGroup.AutoArchive properties. If both of these are set to True, archiving automatically starts when encoding of the relevant source group starts.

Example Code

' Create a WMEncoder object.
Dim Encoder As WMEncoder
Set Encoder = New WMEncoder

' Load a predefined configuration from a file. The
' file name extension must be .wme.

Encoder.Load ("C:\filename.wme")

' Start the encoder engine.
Encoder.Start

' Begin the archiving process.
Encoder.Archive WMENC_ARCHIVE_LOCAL, WMENC_ARCHIVE_START

See Also

  • IWMEncSourceGroup.AutoArchive
  • WMEncoder.ArchiveState
  • WMEncoder.EnableAutoArchive
  • WMEncoder Object


WMEncoder.GenerateBroadcastInfo

The GenerateBroadcastInfo method configures the encoder engine so that you can easily create a multicast publishing point.

Syntax

WMEncoder.GenerateBroadcastInfo bstrFileName

Parameters

bstrFileName

[in] BSTR specifying the name of the Windows Media file that contains the configuration information.

Return Values

This method does not return a value.

Remarks

This GenerateBroadcastInfo method automatically generates a Windows Media file containing the current configuration but no multimedia content. You can use this file to set up a broadcast publishing point on the Windows Media server. At a minimum you must define both a profile and a source group. You can also specify attributes, an archive file, descriptive information and a broadcast port number.

See Also

  • WMEncoder Object


WMEncoder.GetAudioLevel

The GetAudioLevel method retrieves the minimum, average, and maximum volume for the left and right channels of an audio source stream.

Syntax

WMEncoder.AudioLevel iIndex, lDuration, dLMin, dLAvg, dLMax, dRMin, dRAvg

Parameters

units

[in] Member of a WMENC_AUDIOLEVEL_UNITS enumeration type indicating the type of units for the volume. This must be one of the following values.

Value | Description
WMENC_AUDIOLEVEL_DB | This is not implemented in the current release of Windows Media Encoder. Specifying this type returns E_NOTIMPL.
WMENC_AUDIOLEVEL_LINEAR | The volume units are expressed on a linear scale.

iIndex

[in] short containing the index of the source stream. In the current Windows Media Encoder you must specify zero. If you specify a nonzero index, the get_AudioLevel method returns an error code.

lDuration

[in, out] On input, a long containing the length of time, in milliseconds, for which you want to retrieve an average volume level. On output, this parameter contains the length of time for which volume information was retrieved. If you specify a duration that exceeds the duration of the stream, the stream duration is retrieved.

dLMin

[out] double containing the minimum volume, in decibels, in the left audio channel over the specified time period.

dLAvg

[out] double containing the average volume, in decibels, in the left audio channel over the specified time period.

dLMax

[out] double containing the maximum volume, in decibels, in the left audio channel over the specified time period.

dRMin

[out] double containing the minimum volume, in decibels, in the right audio channel over the specified time period.

dlRAvg

[out] double containing the average volume, in decibels, in the right audio channel over the specified time period.

Return Values

When getting the value, this property returns a double containing the maximum volume, in decibels, in the right audio channel over the specified time period.

If this property fails, it returns an error number.

Number | Meaning
0x80070057 | A parameter is not valid.

See Also

  • WMEncoder Object


WMEncoder.Indexer

The Indexer method cancels the indexing process before it is complete.

Syntax

WMEncoder.Indexer enumIndexerOp

Parameters

enumIndexerOp

[in] Member of a enumeration type that indicates whether the indexing process will be cancelled. This must be the following value.

Value | Number | Meaning
WMENC_INDEXER_STOP | 1 | Stops the indexing process.

Return Values

If this method fails, it returns an error number.

Number | Meaning
0x80070057 | You can only specify WMENC_INDEXER_STOP.

Remarks

Stopping the indexing process before completion may corrupt the Windows Media file, and is not recommended.

Example Code

' Check to see if the indexer is running.
Dim iIndexState As WMENC_INDEXER_STATE
iIndexState = Encoder.IndexerState
If iIndexState = WMENC_INDEXER_RUNNING Then
    ' Stop the indexing process.
    Encoder.Indexer WMENC_INDEXER_STOP
End If

See Also

  • WMEncoder.IndexerState
  • WMEncoder Object


WMEncoder.Load

The Load method loads an existing configuration from a file.

Syntax

WMEncoder.Load bstrFileName

Parameters

bstrFileName

[in] BSTR containing the file name.

Return Values

If this method fails, it returns an error number.

Number | Meaning
0x8007000E | Memory cannot be allocated.

Remarks

A configuration contains the data needed by the encoder engine. The file name extension for a configuration file is .wme. To save a configuration, use the WMEncoder.Save method.

Example Code

' Create a WMEncoder object.
Dim Encoder As WMencoder
Set Encoder = New WMEncoder

' Load a predefined configuration from a file. The
' file name extension must be .wme.

Encoder.Load ("C:\filename.wme")

' Start the encoder engine.
Encoder.Start

See Also

  • WMEncoder Object
  • WMEncoder.Save
  • WMEncoder.Start
  • WMEncoder.Stop


WMEncoder.Reset

The Reset method removes the current configuration settings.

Syntax

WMEncoder.Reset

Parameters

This method takes no parameters.

Return Values

If this method fails, it returns an error number.

Number | Meaning
0xC00D0011 | This method cannot be called if the encoder engine is running.

Remarks

This function reinitializes the configuration data members to the values that are set for a new Windows Media Encoder object.

See Also

  • WMEncoder Object


WMEncoder.Save

The Save method saves the current configuration to a file.

Syntax

WMEncoder.Save ( bstrFileName )

Parameters

This method takes no parameters.

Return Values

If this method fails, it returns an error number.

Number | Meaning
0x8007000E | Memory cannot be allocated.

Remarks

To save a configuration, use the WMEncoder.Load method. The file name extension for a configuration file is .wme.

Example Code

' Create a WMEncoder object.
Dim Encoder As WMEncoder
Set Encoder = New WMEncoder

' Load a predefined configuration from a file. The
' file name extension must be .wme.
Encoder.Load ("C:\filename.wme")

' Change the descriptive information for the
' encoded content.
Dim Descr As IWMEncDisplayInfo
Set Descr = Encoder.DisplayInfo

Descr.Author = "Author name"
Descr.Copyright = "Copyright information"
Descr.Title = "Content title"

' Save the changed configuration.
Encoder.Save ("C:\filename.wme")

' Start the encoder engine.
Encoder.Start

See Also

  • WMEncoder.File
  • WMEncoder.Load
  • WMEncoder Object
  • WMEncoder.Stop


WMEncoder.SendScript

The SendScript method sends script to Windows Media Encoder.

Syntax

WMEncoder.SendScript( iIndex, bstrType, bstrData )

Parameters

iIndex

[in] SHORT containing the index of the script to send.

bstrType

[in] BSTR containing the type of script to send.

bstrData

[in] BSTR containing the script content.

Return Values

This method does not return a value.

Remarks

Because Windows Media Encoder does not currently support multiple text streams, you must set the iIndex parameter to zero. To broadcast text, you must send a type/data string pair to the encoder. When Windows Media Player receives the "TEXT" type, it interprets the data string as captioned text and displays it in the caption window. When Windows Media Player receives a "URL" type, it interprets the data string as a URL and opens the URL in a browser.

Example Code

' Create a WMEncoder object
Dim Encoder As WMEncoder
Set Encoder = New WMEncoder

' Declare a source group object and a source group collection object.
' Get the source group collection object from the encoder object.
Dim SrcGrpColl As IWMEncSourceGroupCollection
Dim SrcGrp As IWMEncSourceGroup
Set SrcGrpColl = Encoder.SourceGroupCollection

' Add an empty source group to the source group collection.
Set SrcGrp = SrcGrpColl.Add("SG_1")

' Add video, audio, and script streams to the new source group.
Dim SrcAud As IWMEncSource
Dim SrcVid As IWMEncSource
Dim SrcScript As IWMEncSource
Set SrcVid = SrcGrp.AddSource(WMENC_VIDEO)
Set SrcAud = SrcGrp.AddSource(WMENC_AUDIO)
Set SrcScript = SrcGrp.AddSource(WMENC_SCRIPT)

' Specify the plug-in to use for capturing audio and video
' streams from the capture card.
SrcVid.SetInput "DEVICE://Default_Video_Device"
SrcAud.SetInput "DEVICE://Default_Audio_Device"

' Specify the script plug-in.
SrcScript.SetInput "UserScript://"

' Select a custom profile for the source group. The profile must be
' enabled for script streams. You can use either the Windows
' Media Format SDK or the Profile Manager to create the
' profile. Because this is a custom profile, you can
' associate it with a source group by specifying the path and
' name.
SrcGrp.Profile = "C:\Program Files\Windows Media Components\ _
Encoder\Profiles\profile_name.prx"

' Start the encoder
Encoder.Start

' Broadcast a text string. This is displayed in the Windows
' Media Player caption window.
Encoder.SendScript(0, "TEXT", "This is a test")

See Also

  • WMEncoder Object


WMEncoder.SetLocaleID

The SetLocaleID property specifies the national language used by Windows Media Encoder.

Syntax

WMEncoder.SetLocaleID lLocaleID

Parameters

lLocaleID

[in] LONG containing the language ID.

Return Values

This method does not return a value.

Remarks

For more information about locale IDs, see the Microsoft Developer Network page at the Microsoft Web site. Search for localeID, "Table for Language, Locale Names, and Correponding LCIDs (Three-Letter Abbreviations)", the MAKELANGID macro, or the MAKELCID macro.

Example Code

' Create a WMEncoder object.
Dim Encoder As WMencoder
Set Encoder = New WMEncoder

' Specify the locale ID for Canadian English.
Encoder.SetLocaleID &H1009

See Also

  • WMEncoder Object


WMEncoder.Start

The Start method starts Windows Media Encoder.

Syntax

WMEncoder.Start

Parameters

This method takes no parameters.

Return Values

This method does not return a value.

Remarks

The Start method calls WMEncoder.PrepareToEncode if you have not already done so. It is recommended that you call PrepareToEncode so that resources will be reserved and the configuration verified. This minimizes delay when starting the encoder engine.

See Also

  • WMEncoder.Load
  • WMEncoder Object
  • WMEncoder.PrepareToEncode
  • WMEncoder.Save
  • WMEncoder.Start


WMEncoder.Stop

The Stop method stops Windows Media Encoder.

Syntax

WMEncoder.Stop

Parameters

This method takes no parameters.

Return Values

This method does not return a value.

See Also

  • WMEncoder.Load
  • WMEncoder Object
  • WMEncoder.Save
  • WMEncoder.Start


WMEncoderApp Object

The WMEncoderApp object displays the primary Windows Media Encoder user interface and accesses the Windows Media Encoder engine. The WMEncoderApp object exposes the following properties and methods.

Property | Description
Encoder | Retrieves a Windows Media Encoder object.
Height | Specifies and retrieves the height of the UI, in pixels.
Left | Specifies and retrieves the offset of the UI, in pixels, from the left side of the screen.
Top | Specifies and retrieves the offset of the UI, in pixels, from the top of the screen.
UILock | Specifies and retrieves the lock state of the UI.
Visible | Specifies and retrieves the display state of the UI.
Width | Specifies and retrieves the width of the UI, in pixels.

Method | Description
GetProperty | Retrieves a property that identifies the display state of a UI panel, property page, or window.
SaveProperties | Saves changes to the UI properties.
SetProperty | Specifies a property that identifies the display state of a UI panel, property page, or window.

See Also

  • [Visual C++] IWMEncoderApp Interface
  • Objects (Visual Basic)


WMEncoderApp.Encoder

The Encoder property retrieves a Windows Media Encoder object.

Syntax

WMEncoder = WMEncoderApp.Encoder

Parameters

This property takes no parameters.

Return Values

This property returns a Windows Media Encoder object.

Remarks

This property is read-only. Use this method to acquire an WMEncoder object and operate Windows Media Encoder. This method is useful when applications must both run the engine and show the pre-defined user interface.

Example Code

' Create a WMEncoderApp object.
Dim EncoderApp As WMEncoderApp
Set EncoderApp = New WMEncoderApp

' Retrieve a WMEncoder object from the WMEncoderApp object.
Dim Encoder As WMEncoder
Set Encoder = EncoderApp.Encoder

See Also

  • WMEncoderApp Object


WMEncoderApp.Height

The Height property specifies and retrieves the height of the UI, in pixels.

Syntax

WMEncoderApp.Height = Long
Long = WMEncoderApp.Height

Parameters

This property takes no parameters.

Return Values

When getting the value, this property returns a LONG containing the height of the UI, in pixels.

Example Code

' Create a WMEncoderApp Object.
Dim EncoderApp As WMEncoderApp
Set EncoderApp = New WMEncoderApp

' Display the predefined user interface.
EncoderApp.Visible = True

' Retrieve the user interface properties.
Dim lHeight As Long
Dim lWidth As Long
Dim lTop As Long
Dim lLeft As Long
Dim bUILock As Boolean
Dim vSourceState As Variant

' Retrieve the height and width, in pixels.
lHeight = EncoderApp.Height
lWidth = EncoderApp.Width

' Retrieve the top offset of the user interface.
lTop = EncoderApp.Top
If lTop <> 0 Then
    lTop = 0
End If

'Retrieve the left offset of the user interface.
lLeft = EncoderApp.Left
If lLeft <> 0 Then
    lLeft = 0
End If

' Determine whether the user interface is locked.
bUILock = EncoderApp.UILock

' Display the sources panel.
EncoderApp.SetProperty WMENCAPP_PROP_USER, "View\Sources", True

' Verify that the sources panel is displayed.
vSourceState = EncoderApp.GetProperty(WMENCAPP_PROP_USER, "View\Sources")

EncoderApp.SaveProperties WMENCAPP_PROP_USER

See Also

  • WMEncoderApp Object


WMEncoderApp.Left

The Left property specifies and retrieves the offset of the UI, in pixels, from the left side of the screen.

Syntax

WMEncoderApp.Left = Long
Long = WMEncoderApp.Left

Parameters

This property takes no parameters.

Return Values

When getting the value, this property returns a LONG containing the offset of the UI, in pixels, from the left side of the screen.

Example Code

' Create a WMEncoderApp Object.
Dim EncoderApp As WMEncoderApp
Set EncoderApp = New WMEncoderApp

' Display the predefined user interface.
EncoderApp.Visible = True

' Retrieve the user interface properties.
Dim lHeight As Long
Dim lWidth As Long
Dim lTop As Long
Dim lLeft As Long
Dim bUILock As Boolean
Dim vSourceState As Variant

' Retrieve the height and width, in pixels.
lHeight = EncoderApp.Height
lWidth = EncoderApp.Width

' Retrieve the top offset of the user interface.
lTop = EncoderApp.Top
If lTop <> 0 Then
    lTop = 0
End If

'Retrieve the left offset of the user interface.
lLeft = EncoderApp.Left
If lLeft <> 0 Then
    lLeft = 0
End If

' Determine whether the user interface is locked.
bUILock = EncoderApp.UILock

' Display the sources panel.
EncoderApp.SetProperty WMENCAPP_PROP_USER, "View\Sources", True

' Verify that the sources panel is displayed.
vSourceState = EncoderApp.GetProperty(WMENCAPP_PROP_USER, "View\Sources")

EncoderApp.SaveProperties WMENCAPP_PROP_USER

See Also

  • WMEncoderApp Object


WMEncoderApp.Top

The Top property specifies and retrieves the offset of the UI, in pixels, from the top of the screen.

Syntax

WMEncoderApp.Top = Long
Long = WMEncoderApp.Top

Parameters

This property takes no parameters.

Return Values

When getting the value, this property returns a LONG containing the pixel offset for the top of the UI.

Example Code

' Create a WMEncoderApp Object.
Dim EncoderApp As WMEncoderApp
Set EncoderApp = New WMEncoderApp

' Display the predefined user interface.
EncoderApp.Visible = True

' Retrieve the user interface properties.
Dim lHeight As Long
Dim lWidth As Long
Dim lTop As Long
Dim lLeft As Long
Dim bUILock As Boolean
Dim vSourceState As Variant

' Retrieve the height and width, in pixels.
lHeight = EncoderApp.Height
lWidth = EncoderApp.Width

' Retrieve the top offset of the user interface.
lTop = EncoderApp.Top
If lTop <> 0 Then
    lTop = 0
End If

'Retrieve the left offset of the user interface.
lLeft = EncoderApp.Left
If lLeft <> 0 Then
    lLeft = 0
End If

' Determine whether the user interface is locked.
bUILock = EncoderApp.UILock

' Display the sources panel.
EncoderApp.SetProperty WMENCAPP_PROP_USER, "View\Sources", True

' Verify that the sources panel is displayed.
vSourceState = EncoderApp.GetProperty(WMENCAPP_PROP_USER, "View\Sources")

EncoderApp.SaveProperties WMENCAPP_PROP_USER

See Also

  • WMEncoderApp Object


WMEncoderApp.UILock

The UILock property specifies and retrieves the lock state of the UI.

Syntax

WMEncoderApp.UILock = VARIANT_BOOL
VARIANT_BOOL  = WMEncoderApp.UILock

Parameters

This property takes no parameters.

Return Values

When getting the value, this property returns a VARIANT_BOOL indicating the display state.

Remarks

If the UI is locked from the local computer running Windows Media Encoder, it cannot be unlocked from a remote computer.

Example Code

' Create a WMEncoderApp Object.
Dim EncoderApp As WMEncoderApp
Set EncoderApp = New WMEncoderApp

' Display the predefined user interface.
EncoderApp.Visible = True

' Retrieve the user interface properties.
Dim lHeight As Long
Dim lWidth As Long
Dim lTop As Long
Dim lLeft As Long
Dim bUILock As Boolean
Dim vSourceState As Variant

' Retrieve the height and width, in pixels.
lHeight = EncoderApp.Height
lWidth = EncoderApp.Width

' Retrieve the top offset of the user interface.
lTop = EncoderApp.Top
If lTop <> 0 Then
    lTop = 0
End If

'Retrieve the left offset of the user interface.
lLeft = EncoderApp.Left
If lLeft <> 0 Then
    lLeft = 0
End If

' Determine whether the user interface is locked.
bUILock = EncoderApp.UILock

' Display the sources panel.
EncoderApp.SetProperty WMENCAPP_PROP_USER, "View\Sources", True

' Verify that the sources panel is displayed.
vSourceState = EncoderApp.GetProperty(WMENCAPP_PROP_USER, "View\Sources")

EncoderApp.SaveProperties WMENCAPP_PROP_USER

See Also

  • WMEncoderApp Object


WMEncoderApp.Visible

The Visible property specifies and retrieves the display state of the UI.

Syntax

WMEncoderApp.Visible = VARIANT_BOOL
VARIANT_BOOL  = WMEncoderApp.Visible

Parameters

This property takes no parameters.

Return Values

When getting the value, this property returns a VARIANT_BOOL indicating whether the UI is enabled.

Remarks

You must make the UI visible before displaying any panels or windows.

Example Code

' Create a WMEncoderApp Object.
Dim EncoderApp As WMEncoderApp
Set EncoderApp = New WMEncoderApp

' Display the predefined user interface.
EncoderApp.Visible = True

' Retrieve the user interface properties.
Dim lHeight As Long
Dim lWidth As Long
Dim lTop As Long
Dim lLeft As Long
Dim bUILock As Boolean
Dim vSourceState As Variant

' Retrieve the height and width, in pixels.
lHeight = EncoderApp.Height
lWidth = EncoderApp.Width

' Retrieve the top offset of the user interface.
lTop = EncoderApp.Top
If lTop <> 0 Then
    lTop = 0
End If

'Retrieve the left offset of the user interface.
lLeft = EncoderApp.Left
If lLeft <> 0 Then
    lLeft = 0
End If

' Determine whether the user interface is locked.
bUILock = EncoderApp.UILock

' Display the sources panel.
EncoderApp.SetProperty WMENCAPP_PROP_USER, "View\Sources", True

' Verify that the sources panel is displayed.
vSourceState = EncoderApp.GetProperty(WMENCAPP_PROP_USER, "View\Sources")

EncoderApp.SaveProperties WMENCAPP_PROP_USER

See Also

  • WMEncoderApp Object


WMEncoderApp.Width

The Width property specifies and retrieves the width of the UI, in pixels.

Syntax

WMEncoderApp.Width = Long
Long = WMEncoderApp.Width

Parameters

This property takes no parameters.

Return Values

When getting the value, this property returns a LONG containing the width of the UI, in pixels.

Example Code

' Create a WMEncoderApp Object.
Dim EncoderApp As WMEncoderApp
Set EncoderApp = New WMEncoderApp

' Display the predefined user interface.
EncoderApp.Visible = True

' Retrieve the user interface properties.
Dim lHeight As Long
Dim lWidth As Long
Dim lTop As Long
Dim lLeft As Long
Dim bUILock As Boolean
Dim vSourceState As Variant

' Retrieve the height and width, in pixels.
lHeight = EncoderApp.Height
lWidth = EncoderApp.Width

' Retrieve the top offset of the user interface.
lTop = EncoderApp.Top
If lTop <> 0 Then
    lTop = 0
End If

'Retrieve the left offset of the user interface.
lLeft = EncoderApp.Left
If lLeft <> 0 Then
    lLeft = 0
End If

' Determine whether the user interface is locked.
bUILock = EncoderApp.UILock

' Display the sources panel.
EncoderApp.SetProperty WMENCAPP_PROP_USER, "View\Sources", True

' Verify that the sources panel is displayed.
vSourceState = EncoderApp.GetProperty(WMENCAPP_PROP_USER, "View\Sources")

EncoderApp.SaveProperties WMENCAPP_PROP_USER

See Also

  • WMEncoderApp Object


WMEncoderApp.GetProperty

The GetProperty method retrieves a property that identifies the display state of a UI panel, property page, or window.

Syntax

varProperty = WMEncoderApp.GetProperty(enumClass, bstrProperty)

Parameters

enumClass

[in] Member of a WMENCAPP_PROP_CLASS enumeration type identifying the property class. Currently, this must be the following value.

Value | Number | Meaning
WMENC_PROP_USER | 1 | Identifies the end user class.

bstrProperty

[in] BSTR containing the property.

Return Values

This method returns a VARIANT containing the property state.

If this method fails, it returns an error number.

Number | Meaning
0x80070057 | You must specify the property class as WMENC_PROP_USER.
0x8007000E | Memory cannot be allocated.

Remarks

Any change to the UI by an end user causes the property to change appropriately. The following table lists the properties that are currently defined for Windows Media Encoder.

Property | Description
View\Sources | Retrieves the display state of the Sources panel.
View\Audio | Retrieves the display state of the Audio panel.
View\Monitor | Retrieves the display state of the Monitor panel.
View\Control | Retrieves the display state of the Control panel.
View\Script | Retrieves the display state of the Annotation panel.
View\Archive | Retrieves the display state of the Archive panel.
View\Video1 | Retrieves the display state of the Video window.
View\MonitorPage | Retrieves the ID of a property page in the Monitor panel: 100 = General page. 300 = Display Information page. 600 = Connections page.
Video1\Zoom | Retrieves the zoom factor for the video window. For example, a value of 200 means that the zoom factor is 200%.
Video1\Display | Retrieves the display style of the video window: 0 = input. 1 = Output. 2 = Both. 3 = Next. 4 = Split.

Example Code

' Create a WMEncoderApp Object.
Dim EncoderApp As WMEncoderApp
Set EncoderApp = New WMEncoderApp

' Display the predefined user interface.
EncoderApp.Visible = True

' Retrieve the user interface properties.
Dim lHeight As Long
Dim lWidth As Long
Dim lTop As Long
Dim lLeft As Long
Dim bUILock As Boolean
Dim vSourceState As Variant

' Retrieve the height and width, in pixels.
lHeight = EncoderApp.Height
lWidth = EncoderApp.Width

' Retrieve the top offset of the user interface.
lTop = EncoderApp.Top
If lTop <> 0 Then
    lTop = 0
End If

'Retrieve the left offset of the user interface.
lLeft = EncoderApp.Left
If lLeft <> 0 Then
    lLeft = 0
End If

' Determine whether the user interface is locked.
bUILock = EncoderApp.UILock

' Display the sources panel.
EncoderApp.SetProperty WMENCAPP_PROP_USER, "View\Sources", True

' Verify that the sources panel is displayed.
vSourceState = EncoderApp.GetProperty(WMENCAPP_PROP_USER, "View\Sources")

EncoderApp.SaveProperties WMENCAPP_PROP_USER

See Also

  • WMEncoderApp Object
  • WMEncoderApp.SetProperty


WMEncoderApp.SaveProperties

The SaveProperties method saves changes to the UI properties.

Syntax

WMEncoderApp.SaveProperties enumClass

Parameters

enumClass

[in] Member of a WMENCAPP_PROP_CLASS enumeration type identifying the property class for which the properties will be saved. Currently, this must be the following value.

Value | Number | Meaning
WMENCAPP_PROP_USER | 1 | Identifies the end user class.

Return Values

If this method fails, it returns an error number.

Number | Meaning
0x80070057 | You must specify the property class as WMENCAPP_PROP_USER

Remarks

You must call this method because the Windows Media Encoder SDK does not automatically save changes to UI properties.

Example Code

' Create a WMEncoderApp Object.
Dim EncoderApp As WMEncoderApp
Set EncoderApp = New WMEncoderApp

' Display the predefined user interface.
EncoderApp.Visible = True

' Retrieve the user interface properties.
Dim lHeight As Long
Dim lWidth As Long
Dim lTop As Long
Dim lLeft As Long
Dim bUILock As Boolean
Dim vSourceState As Variant

' Retrieve the height and width, in pixels.
lHeight = EncoderApp.Height
lWidth = EncoderApp.Width

' Retrieve the top offset of the user interface.
lTop = EncoderApp.Top
If lTop <> 0 Then
    lTop = 0
End If

'Retrieve the left offset of the user interface.
lLeft = EncoderApp.Left
If lLeft <> 0 Then
    lLeft = 0
End If

' Determine whether the user interface is locked.
bUILock = EncoderApp.UILock

' Display the sources panel.
EncoderApp.SetProperty WMENCAPP_PROP_USER, "View\Sources", True

' Verify that the sources panel is displayed.
vSourceState = EncoderApp.GetProperty(WMENCAPP_PROP_USER, "View\Sources")

EncoderApp.SaveProperties WMENCAPP_PROP_USER

See Also

  • WMEncoderApp Object


WMEncoderApp.SetProperty

The SetProperty method specifies a property that identifies the display state of a UI panel, property page, or window.

Syntax

WMEncoderApp.SetProperty enumClass, bstrProperty, varValue

Parameters

enumClass

[in] Member of a WMENCAPP_PROP_CLASS enumeration type identifying the property class. Currently, this must be the following value.

Value | Number | Meaning
WMENCAPP_PROP_USER | 1 | Identifies the end user class.

bstrProperty

[in] BSTR containing the property.

varValue

[in] VARIANT containing the display state.

Return Values

If this method fails, it returns an error number.

Number | Meaning
0x80070057 | You must specify the property class as WMENCAPP_PROP_USER

Example Code

Remarks

Any change to the UI by an end user causes the property to change appropriately. The following table lists the properties that are currently defined for Windows Media Encoder.

Property | Variant | Description
View\Sources | Boolean | Specifies the display state of the Sources panel.
View\Audio | Boolean | Specifies the display state of the Audio panel.
View\Monitor | Boolean | Specifies the display state of the Monitor panel.
View\Control | Boolean | Specifies the display state of the Control panel.
View\Script | Boolean | Specifies the display state of the Annotation panel.
View\Archive | Boolean | Specifies the display state of the Archive panel.
View\Video1 | Boolean | Specifies the display state of the Video window.
View\MonitorPage | Integer | Specifies the property page in the Monitor panel. The varValue parameter can take the following values: 100 = General page. 300 = Display Information page. 600 = Connections page.
Video1\Zoom | Integer | Identifies the zoom factor for the video window. For example, use 200 to specify 200%.
Video1\Display | Integer | Identifies the display style of the video window: 0 = input. 1 = Output. 2 = Both. 3 = Next. 4 = Split.

Example Code

' Create a WMEncoderApp Object.
Dim EncoderApp As WMEncoderApp
Set EncoderApp = New WMEncoderApp

' Display the predefined user interface.
EncoderApp.Visible = True

' Retrieve the user interface properties.
Dim lHeight As Long
Dim lWidth As Long
Dim lTop As Long
Dim lLeft As Long
Dim bUILock As Boolean
Dim vSourceState As Variant

' Retrieve the height and width, in pixels.
lHeight = EncoderApp.Height
lWidth = EncoderApp.Width

' Retrieve the top offset of the user interface.
lTop = EncoderApp.Top
If lTop <> 0 Then
    lTop = 0
End If

'Retrieve the left offset of the user interface.
lLeft = EncoderApp.Left
If lLeft <> 0 Then
    lLeft = 0
End If

' Determine whether the user interface is locked.
bUILock = EncoderApp.UILock

' Display the sources panel.
EncoderApp.SetProperty WMENCAPP_PROP_USER, "View\Sources", True

' Verify that the sources panel is displayed.
vSourceState = EncoderApp.GetProperty(WMENCAPP_PROP_USER, "View\Sources")

EncoderApp.SaveProperties WMENCAPP_PROP_USER

See Also

  • WMEncoderApp.GetProperty
  • WMEncoderApp Object


Property Page Interfaces (C++)

You can use the MSPropShell ActiveX control to host property pages that enable end users to configure and monitor the encoder engine. By using the reusable property page objects that are included in the Windows Media Encoder SDK, the end user can specify multimedia sources, describe the encoded content, add attributes, designate a broadcast port number, choose a file for archiving, select a profile, monitor encoding statistics, and monitor the performance of the network connection. To view individual property pages, see the Configuring the Windows Media Encoder Application section of this document. You can use the following interfaces to manage the MSPropshell control.

Interface | Description
_IMSPropShellEvents Interface | Not implemented in this release.
IMSPropShell Interface | Manages property page objects.

See Also

  • Configuring the Windows Media Encoder Application
  • Programming Reference
  • The MSPropShell ActiveX Control


_IMSPropShellEvents Interface

The _IMSPropShellEvents interface is a callback interface to which the MSPropShell ActiveX control sends event notifications. Use this interface to determine if the end user has switched or is switching from one property page to another. In addition to the methods inherited from IDispatch, the _IMSPropShellEvents interface exposes the following methods.

Note The _IMSPropShellEvents interface is not implemented in this release.

Method | Description
OnPageChanged | Not implemented in this release.
OnPageChanging | Not implemented in this release.

See Also

  • [Visual Basic] _IMSPropShellEvents Object
  • IMSPropShell Interface
  • Property Page Interfaces (C++)


_IMSPropShellEvents::OnPageChanged

The OnPageChanged method is not implemented in this release.

Syntax

HRESULT OnPageChanged(
  long  Index
);

Parameters

Index

[in] long sent by the MSPropShell control, containing the index of the page the user has switched to.

See Also

  • _IMSPropShellEvents Interface
  • _IMSPropShellEvents::OnPageChanging


_IMSPropShellEvents::OnPageChanging

The OnPageChanging method is not implemented in this release.

Syntax

HRESULT OnPageChanging(
  long  Index,
  VARIANT_BOOL*  bAllow
);

Parameters

Index

[in] long sent by MSPropShell containing the index of the page that the end user has requested.

bAllow

[in, out] On input, a VARIANT_BOOL sent by MSPropShell to indicate whether the new page can be selected. On output, this parameter specifies whether the selected property page can be made active. This parameter defaults to VARIANT_TRUE.

See Also

  • _IMSPropShellEvents Interface
  • _IMSPropShellEvents::OnPageChanged
  • IMSPropShell Interface


IMSPropShell Interface

The IMSPropShell interface controls the property pages hosted by the MSPropShell ActiveX control. It can be used to add a property page object to the control and link the property page to Windows Media Encoder.

You must create a dialog box to host the MSPropShell ActiveX control. This is difficult to do without using either the Active Template Library (ATL) or the Microsoft Foundation Classes (MFC) library. The following example illustrates how to create a dialog class by using ATL.

// Your class must be derived from CAxDialogImpl, not CDialogImpl.
class CPropertiesDlg: public CAxDialogImpl< CPropertiesDlg >
{
public:
    enum{ IDD = IDD_PROPERTIES };

    BEGIN_MSG_MAP( CPropertiesDlg )
        MESSAGE_HANDLER( WM_INITDIALOG, OnInitDialog )
        COMMAND_ID_HANDLER(IDOK, OnOK)
        COMMAND_ID_HANDLER(IDCANCEL, OnCancel)
    END_MSG_MAP()

    LRESULT OnInitDialog(UINT /*uMsg*/,
                         WPARAM /*wParam*/,
                         LPARAM /*lParam*/,
                         BOOL& /*bHandled*/)
    {
        // Retrieve the MSPropShell object.
        GetDlgControl( IDC_MSPROPSHELL_CONTROL,
                       IID_IMSPropShell,
                      (void**)&m_spPropShell );

        // Specify a language for the property pages.
        m_spPropShell->put_LocaleID( GetMyUserLCID() );

        // Add a WMEncoder object to the property page shell.
        m_spPropShell->AddObject( GetMyEncoderObject() );

        // Create the property pages.
        m_spSources.CoCreateInstance(      CLSID_WMEncSwitchesPage );
        m_spDescription.CoCreateInstance(  CLSID_WMEncDescriptionPage );
        m_spAttributes.CoCreateInstance(   CLSID_WMEncAttributesPage );
        m_spEncoding.CoCreateInstance(     CLSID_WMEncEncodingPage );
        m_spBroadcast.CoCreateInstance(    CLSID_WMEncBroadcastPage );
        m_spFile.CoCreateInstance(         CLSID_WMEncFilePage );

        // Add the property pages to the property page shell.
        m_spPropShell->AddPage( m_spSources );
        m_spPropShell->AddPage( m_spDescription );
        m_spPropShell->AddPage( m_spAttributes );
        m_spPropShell->AddPage( m_spEncoding );
        m_spPropShell->AddPage( m_spBroadcast );
        m_spPropShell->AddPage( m_spFile );

        return( TRUE );
    }

    LRESULT OnOK(WORD /*wNotifyCode*/, WORD wID, HWND /*hWndCtl*/, BOOL& /*bHandled*/)
    {
        // Apply property page changes to the encoder engine.
        m_spPropShell->Apply();
        EndDialog( wID );
        return( 0 );
    }

    LRESULT OnCancel(WORD /*wNotifyCode*/, WORD wID, HWND /*hWndCtl*/, BOOL& /*bHandled*/)
    {
        EndDialog( wID );
        return( 0 );
    }

protected:

    // Property shell object
    CComPtr<IMSPropShell>   m_spPropShell;

    // Property page objects
    CComPtr<IUnknown> m_spSources;
    CComPtr<IUnknown> m_spDescription;
    CComPtr<IUnknown> m_spAttributes;
    CComPtr<IUnknown> m_spEncoding;
    CComPtr<IUnknown> m_spBroadcast;
    CComPtr<IUnknown> m_spFile;
};

In addition to the methods inherited from IDispatch, the IMSPropShell interface exposes the following methods.

Method | Description
AddObject | Adds a Windows Media Encoder object to the MSPropShell control.
AddPage | Adds a property page object to the MSPropShell control.
Apply | Sends property page changes to Windows Media Encoder.
get_ApplyIndex | Retrieves the index number of the property page being applied to the WMEncoder object.
get_AutoRefresh | Retrieves a Boolean value indicating whether the property pages are automatically refreshed when either a new property page or a WMEncoder object is attached to them.
get_InitNew | Retrieves a Boolean value indicating whether the property pages hosted by the MSPropShell control must be reinitialized to an empty state.
get_LocaleID | Retrieves the national language used in the property pages.
get_PageCount | Retrieves the number of property pages in the MSPropShell control.
get_PageHasHelp | Retrieves a Boolean value indicating whether Help is defined for a specific page.
get_PageIndex | Retrieves the index of the active property page.
get_PageTitle | Retrieves the title of a specific property page.
get_Style | Retrieves an enumeration member indicating whether the property pages are displayed with tabs.
get_TabWidth | Retrieves the width of the property page tabs.
GetPage | Retrieves a pointer to a specific property page.
put_AutoRefresh | Specifies a Boolean value indicating whether all property pages are automatically refreshed when either a new property page or WMEncoder object is attached to them.
put_InitNew | Specifies a Boolean value indicating whether the property pages hosted by the MSPropShell control must be reinitialized to an empty state.
put_LocaleID | Specifies the national language used in the property pages.
put_PageIndex | Specifies the active property page.
put_Style | Specifies whether the property pages are displayed with tabs.
put_TabWidth | Specifies the width of the property page tabs.
Refresh | Recreates all of the property pages in the MSPropShell control.
RemoveAllObjects | Removes all WMEncoder objects from the MSPropShell control.
RemoveAllPages | Removes all of the property pages from the MSPropShell control.
ShowPageHelp | Displays Help for a specific property page.

See Also

  • [Visual Basic] MSPropShell Object
  • _IMSPropShellEvents Interface
  • Property Page Interfaces (C++)


IMSPropShell::AddObject

The AddObject method adds a Windows Media Encoder object to the MSPropShell control.

Syntax

HRESULT AddObject(
  LPUNKNOWN  pUnknown
);

Parameters

pUnknown

[in] Pointer to the Windows Media Encoder being added.

Return Values

If the method succeeds, it returns S_OK. If it fails, it returns an HRESULT error code.

Return Code | Meaning
E_INVALIDARG | The pointer to Windows Media Encoder is NULL.
E_OUTOFMEMORY | Insufficient memory to add the object to the property page control.

Remarks

You must call the AddObject method before calling the IMSPropShell::AddPage method. If the IMSPropShell::get_AutoRefresh method returns VARIANT_TRUE, Windows Media Encoder is linked automatically to property pages as they are added.

Example Code

// Include libraries.

#include <windows.h>
#include "wmencode.h"
#include "mspropshell.h"

// Declare variables.

    HRESULT hr;
    IWMEncoder* pEncoder;
    IMSPropShell* pMSPShell;
    IUnknown *pPgSources;
    IUnknown *pPgDesc;
    IUnknown *pPgAttr;
    IUnknown *pPgProfile;
    IUnknown *pPgOutput;

// Initialize the COM library and retrieve a pointer
// to an IWMEncoder interface.

    hr = CoInitialize(NULL);
    hr = CoCreateInstance(CLSID_WMEncoder,
                          NULL,
                          CLSCTX_INPROC_SERVER,
                          IID_IWMEncoder,
                          (void**) &pEncoder);

// Create the property page shell.

    hr = CoCreateInstance(CLSID_MSPropShell,
                          NULL,
                          CLSCTX_INPROC_SERVER,
                          IID_IMSPropShell,
                          (void**) &pMSPShell);

// Create the Sources property page.

    hr = CoCreateInstance(CLSID_WMEncSourcesPage,
                          NULL,
                          CLSCTX_INPROC_SERVER,
                          IID_IUnknown,
                          (void**) &pPgSources);

// Create the Description property page.

    hr = CoCreateInstance(CLSID_WMEncDisplayInfoPage,
                          NULL,
                          CLSCTX_INPROC_SERVER,
                          IID_IUnknown,
                          (void**) &pPgDesc);

// Create the Attributes property page.

    hr = CoCreateInstance(CLSID_WMEncAttributesPage,
                          NULL,
                          CLSCTX_INPROC_SERVER,
                          IID_IUnknown,
                          (void**) &pPgAttr);

// Create the Profile property page.

    hr = CoCreateInstance(CLSID_WMEncProfilePage,
                          NULL,
                          CLSCTX_INPROC_SERVER,
                          IID_IUnknown,
                          (void**) &pPgProfile);

// Create the Output property page.

    hr = CoCreateInstance(CLSID_WMEncOutputPage,
                          NULL,
                          CLSCTX_INPROC_SERVER,
                          IID_IUnknown,
                          (void**) &pPgOutput);

// Add Windows Media Encoder to the property page shell.
// You must add the encoder before adding the property pages.

    hr = pMSPShell->AddObject((IUnknown*) pEncoder);

// Add the property pages to the property page shell.

    hr = pMSPShell->AddPage(pPgSources);
    hr = pMSPShell->AddPage(pPgDesc);
    hr = pMSPShell->AddPage(pPgAttr);
    hr = pMSPShell->AddPage(pPgProfile);
    hr = pMSPShell->AddPage(pPgOutput);

See Also

  • IMSPropShell::AddPage
  • IMSPropShell::get_AutoRefresh
  • IMSPropShell Interface


IMSPropShell::AddPage

The AddPage method adds a property page object to the MSPropShell control.

Syntax

HRESULT AddPage(
  LPUNKNOWN  pUnknown
);

Parameters

pUnknown

[in] Pointer to the property page being added.

Return Values

If the method succeeds, it returns S_OK. If it fails, it returns an HRESULT error code.

Return code | Meaning
E_INVALIDARG | The pointer to the property page is NULL.
E_OUTOFMEMORY | Insufficient memory to add the property page to the MSPropShell control.
E_NOINTERFACE | The property page doesn't support IPropertyPage.

Remarks

You must call the IMSPropShell::AddObject method before the AddPage method. Pages appear on the screen in the order in which they are added. To move a page to a new position, you must remove all of the existing pages with the IMSPropShell::RemoveAllPages method and reorder the pages by calling AddPage multiple times in the correct sequence.

Example Code

// Include libraries.

#include <windows.h>
#include "wmencode.h"
#include "mspropshell.h"

// Declare variables.

    HRESULT hr;
    IWMEncoder* pEncoder;
    IMSPropShell* pMSPShell;
    IUnknown *pPgSources;
    IUnknown *pPgDesc;
    IUnknown *pPgAttr;
    IUnknown *pPgProfile;
    IUnknown *pPgOutput;

// Initialize the COM library and retrieve a pointer
// to an IWMEncoder interface.

    hr = CoInitialize(NULL);
    hr = CoCreateInstance(CLSID_WMEncoder,
                          NULL,
                          CLSCTX_INPROC_SERVER,
                          IID_IWMEncoder,
                          (void**) &pEncoder);

// Create the property page shell.

    hr = CoCreateInstance(CLSID_MSPropShell,
                          NULL,
                          CLSCTX_INPROC_SERVER,
                          IID_IMSPropShell,
                          (void**) &pMSPShell);

// Create the Sources property page.

    hr = CoCreateInstance(CLSID_WMEncSourcesPage,
                          NULL,
                          CLSCTX_INPROC_SERVER,
                          IID_IUnknown,
                          (void**) &pPgSources);

// Create the Description property page.

    hr = CoCreateInstance(CLSID_WMEncDisplayInfoPage,
                          NULL,
                          CLSCTX_INPROC_SERVER,
                          IID_IUnknown,
                          (void**) &pPgDesc);

// Create the Attributes property page.

    hr = CoCreateInstance(CLSID_WMEncAttributesPage,
                          NULL,
                          CLSCTX_INPROC_SERVER,
                          IID_IUnknown,
                          (void**) &pPgAttr);

// Create the Profile property page.

    hr = CoCreateInstance(CLSID_WMEncProfilePage,
                          NULL,
                          CLSCTX_INPROC_SERVER,
                          IID_IUnknown,
                          (void**) &pPgProfile);

// Create the Output property page.

    hr = CoCreateInstance(CLSID_WMEncOutputPage,
                          NULL,
                          CLSCTX_INPROC_SERVER,
                          IID_IUnknown,
                          (void**) &pPgOutput);

// Add Windows Media Encoder to the property page shell.
// You must add the encoder before adding the property pages.

    hr = pMSPShell->AddObject((IUnknown*) pEncoder);

// Add the property pages to the property page shell.

    hr = pMSPShell->AddPage(pPgSources);
    hr = pMSPShell->AddPage(pPgDesc);
    hr = pMSPShell->AddPage(pPgAttr);
    hr = pMSPShell->AddPage(pPgProfile);
    hr = pMSPShell->AddPage(pPgOutput);

See Also

  • IMSPropShell::AddObject
  • IMSPropShell::GetPage
  • IMSPropShell Interface
  • IMSPropShell::RemoveAllPages


IMSPropShell::Apply

The Apply method sends property page changes to Windows Media Encoder.

Syntax

HRESULT Apply();

Parameters

This method takes no parameters.

Return Values

If the method succeeds, it returns S_OK. If it fails, it returns an HRESULT error code.

Return code | Meaning
ERROR_INVALID_DATA | An error message has been displayed indicating that the end user has entered invalid data.
E_INVALIDARG | The pointer to the property page is NULL.
E_OUTOFMEMORY | Insufficient memory to add the property page to the MSPropShell control.
E_NOINTERFACE | The property page doesn't support IPropertyPage.

Remarks

Call the Apply method whenever the end user clicks the Apply button. The pages are applied to the encoder engine sequentially, starting with the first page.

Example Code

// Include libraries.

#include <windows.h>
#include "wmencode.h"
#include "mspropshell.h"

// Declare variables.

    HRESULT hr;
    IWMEncoder* pEncoder;
    IMSPropShell* pMSPShell;
    IUnknown *pPgSources;
    IUnknown *pPgDesc;
    IUnknown *pPgAttr;
    IUnknown *pPgProfile;
    IUnknown *pPgOutput;

// Initialize the COM library and retrieve a pointer
// to an IWMEncoder interface.

    hr = CoInitialize(NULL);
    hr = CoCreateInstance(CLSID_WMEncoder,
                          NULL,
                          CLSCTX_INPROC_SERVER,
                          IID_IWMEncoder,
                          (void**) &pEncoder);

// Create the property page shell.

    hr = CoCreateInstance(CLSID_MSPropShell,
                          NULL,
                          CLSCTX_INPROC_SERVER,
                          IID_IMSPropShell,
                          (void**) &pMSPShell);

// Create the Sources property page.

    hr = CoCreateInstance(CLSID_WMEncSourcesPage,
                          NULL,
                          CLSCTX_INPROC_SERVER,
                          IID_IUnknown,
                          (void**) &pPgSources);

// Create the Description property page.

    hr = CoCreateInstance(CLSID_WMEncDisplayInfoPage,
                          NULL,
                          CLSCTX_INPROC_SERVER,
                          IID_IUnknown,
                          (void**) &pPgDesc);

// Create the Attributes property page.

    hr = CoCreateInstance(CLSID_WMEncAttributesPage,
                          NULL,
                          CLSCTX_INPROC_SERVER,
                          IID_IUnknown,
                          (void**) &pPgAttr);

// Create the Profile property page.

    hr = CoCreateInstance(CLSID_WMEncProfilePage,
                          NULL,
                          CLSCTX_INPROC_SERVER,
                          IID_IUnknown,
                          (void**) &pPgProfile);

// Create the Output property page.

    hr = CoCreateInstance(CLSID_WMEncOutputPage,
                          NULL,
                          CLSCTX_INPROC_SERVER,
                          IID_IUnknown,
                          (void**) &pPgOutput);

// Add Windows Media Encoder to the property page shell.
// You must add the encoder before adding the property pages.

    hr = pMSPShell->AddObject((IUnknown*) pEncoder);

// Add the property pages to the property page shell.

    hr = pMSPShell->AddPage(pPgSources);
    hr = pMSPShell->AddPage(pPgDesc);
    hr = pMSPShell->AddPage(pPgAttr);
    hr = pMSPShell->AddPage(pPgProfile);
    hr = pMSPShell->AddPage(pPgOutput);

// When the end user has finished using the property pages to
// configure the encoder engine and has clicked the Apply button,
// apply the configuration programatically .

    hr = pMSPShell->Apply();

// Reinitialize the property pages to prepare them for a
// new configuration.

    hr = pMSPShell->put_InitNew(VARIANT_TRUE);

See Also

  • IMSPropShell Interface


IMSPropShell::get_ApplyIndex

The get_ApplyIndex method retrieves the index number of the property page being applied to the WMEncoder object.

Syntax

HRESULT get_ApplyIndex(
  long*  pVal
);

Parameters

pVal

[out] Pointer to a long containing the index.

Return Values

If the method succeeds, it returns S_OK. If it fails, it returns an HRESULT error code.

Return code | Meaning
E_POINTER | The pointer to the index is NULL.

Remarks

The get_ApplyIndex method was designed for Microsoft internal use only.

See Also

  • IMSPropShell Interface
  • IWMEncoder Interface


IMSPropShell::get_AutoRefresh

The get_AutoRefresh method retrieves a Boolean value indicating whether the property pages are refreshed automatically when either a new property page or a WMEncoder object is attached to them.

Syntax

HRESULT get_AutoRefresh(
  VARIANT_BOOL*  pVal
);

Parameters

pVal

[out] Pointer to a VARIANT_BOOL indicating whether the property pages are refreshed automatically.

Return Values

If the method succeeds, it returns S_OK. If it fails, it returns an HRESULT error code.

Return code | Meaning
E_POINTER | The pointer to the Boolean value is NULL.

Remarks

By default, this property returns VARIANT_TRUE. You can attach WMEncoder objects to property pages by calling either the IMSPropShell::Refresh method or by setting the AutoRefresh property to VARIANT_TRUE and calling IMSPropShell::AddObject. You can attach new property pages to existing property pages by calling either the Refresh method or by setting the AutoRefresh property to VARIANT_TRUE and calling IMSPropShell::AddPage. Use IMSPropShell::put_AutoRefresh to set the value.

Example Code

// Include libraries.

#include <windows.h>
#include "wmencode.h"
#include "mspropshell.h"

// Declare variables.

    HRESULT hr;
    IWMEncoder* pEncoder;
    IMSPropShell* pMSPShell;
    IUnknown *pPgSources;
    IUnknown *pPgDesc;
    IUnknown *pPgAttr;
    IUnknown *pPgProfile;
    IUnknown *pPgOutput;

// Initialize the COM library and retrieve a pointer
// to an IWMEncoder interface.

    hr = CoInitialize(NULL);
    hr = CoCreateInstance(CLSID_WMEncoder,
                          NULL,
                          CLSCTX_INPROC_SERVER,
                          IID_IWMEncoder,
                          (void**) &pEncoder);

// Create the property page shell.

    hr = CoCreateInstance(CLSID_MSPropShell,
                          NULL,
                          CLSCTX_INPROC_SERVER,
                          IID_IMSPropShell,
                          (void**) &pMSPShell);

// Create the Sources property page.

    hr = CoCreateInstance(CLSID_WMEncSourcesPage,
                          NULL,
                          CLSCTX_INPROC_SERVER,
                          IID_IUnknown,
                          (void**) &pPgSources);

// Create the Description property page.

    hr = CoCreateInstance(CLSID_WMEncDisplayInfoPage,
                          NULL,
                          CLSCTX_INPROC_SERVER,
                          IID_IUnknown,
                          (void**) &pPgDesc);

// Create the Attributes property page.

    hr = CoCreateInstance(CLSID_WMEncAttributesPage,
                          NULL,
                          CLSCTX_INPROC_SERVER,
                          IID_IUnknown,
                          (void**) &pPgAttr);

// Create the Profile property page.

    hr = CoCreateInstance(CLSID_WMEncProfilePage,
                          NULL,
                          CLSCTX_INPROC_SERVER,
                          IID_IUnknown,
                          (void**) &pPgProfile);

// Create the Output property page.

    hr = CoCreateInstance(CLSID_WMEncOutputPage,
                          NULL,
                          CLSCTX_INPROC_SERVER,
                          IID_IUnknown,
                          (void**) &pPgOutput);

// Add Windows Media Encoder to the property page shell.
// You must add the encoder before adding the property pages.

    hr = pMSPShell->AddObject((IUnknown*) pEncoder);

// Add the property pages to the property page shell.

    hr = pMSPShell->AddPage(pPgSources);
    hr = pMSPShell->AddPage(pPgDesc);
    hr = pMSPShell->AddPage(pPgAttr);
    hr = pMSPShell->AddPage(pPgProfile);
    hr = pMSPShell->AddPage(pPgOutput);

// Reorder the pages. Call the RemoveAllPages method to remove all
// property pages from the MSPropShell control.

    hr = pMSPShell->RemoveAllPages();

// Set the AutoRefresh property to False so that the MSPropShell
// control is not refreshed when each new page is added.

    hr = pMSPShell->put_AutoRefresh(VARIANT_FALSE);

// Add the property pages in the desired order.

    hr = pMSPShell->AddPage(pPgOutput);
    hr = pMSPShell->AddPage(pPgAttr);
    hr = pMSPShell->AddPage(pPgProfile);
    hr = pMSPShell->AddPage(pPgSources);
    hr = pMSPShell->AddPage(pPgDesc);

// Refresh the MSPropShell ActiveX control.

    hr = pMSPShell->Refresh();

See Also

  • IMSPropShell::AddObject
  • IMSPropShell::AddPage
  • IMSPropShell Interface
  • IMSPropShell::put_AutoRefresh
  • IMSPropShell::Refresh
  • IWMEncoder Interface


IMSPropShell::get_InitNew

The get_InitNew method retrieves a Boolean value indicating whether the property pages hosted by the MSPropShell control must be reinitialized to an empty state.

Syntax

HRESULT get_InitNew(
  VARIANT_BOOL*  pVal
);

Parameters

pVal

[out] Pointer to the VARIANT_BOOL indicating whether the property pages must be reinitialized.

Return Values

If the method succeeds, it returns S_OK. If it fails, it returns an HRESULT error code.

Return code | Meaning
E_POINTER | The pointer to the Boolean value is NULL.

Remarks

Property pages usually display the configuration of the WMEncoder object that is attached to them. However, you can set the InitNew property to VARIANT_TRUE to ignore the current configuration and display empty pages. Use the IMSPropShell::put_InitNew method to specify the Boolean value.

Example Code

// Include libraries.

#include <windows.h>
#include "wmencode.h"
#include "mspropshell.h"

// Declare variables.

    HRESULT hr;
    IWMEncoder* pEncoder;
    IMSPropShell* pMSPShell;
    IUnknown *pPgSources;
    IUnknown *pPgDesc;
    IUnknown *pPgAttr;
    IUnknown *pPgProfile;
    IUnknown *pPgOutput;

// Initialize the COM library and retrieve a pointer
// to an IWMEncoder interface.

    hr = CoInitialize(NULL);
    hr = CoCreateInstance(CLSID_WMEncoder,
                          NULL,
                          CLSCTX_INPROC_SERVER,
                          IID_IWMEncoder,
                          (void**) &pEncoder);

// Create the property page shell.

    hr = CoCreateInstance(CLSID_MSPropShell,
                          NULL,
                          CLSCTX_INPROC_SERVER,
                          IID_IMSPropShell,
                          (void**) &pMSPShell);

// Create the Sources property page.

    hr = CoCreateInstance(CLSID_WMEncSourcesPage,
                          NULL,
                          CLSCTX_INPROC_SERVER,
                          IID_IUnknown,
                          (void**) &pPgSources);

// Create the Description property page.

    hr = CoCreateInstance(CLSID_WMEncDisplayInfoPage,
                          NULL,
                          CLSCTX_INPROC_SERVER,
                          IID_IUnknown,
                          (void**) &pPgDesc);

// Create the Attributes property page.

    hr = CoCreateInstance(CLSID_WMEncAttributesPage,
                          NULL,
                          CLSCTX_INPROC_SERVER,
                          IID_IUnknown,
                          (void**) &pPgAttr);

// Create the Profile property page.

    hr = CoCreateInstance(CLSID_WMEncProfilePage,
                          NULL,
                          CLSCTX_INPROC_SERVER,
                          IID_IUnknown,
                          (void**) &pPgProfile);

// Create the Output property page.

    hr = CoCreateInstance(CLSID_WMEncOutputPage,
                          NULL,
                          CLSCTX_INPROC_SERVER,
                          IID_IUnknown,
                          (void**) &pPgOutput);

// Add Windows Media Encoder to the property page shell.
// You must add the encoder before adding the property pages.

    hr = pMSPShell->AddObject((IUnknown*) pEncoder);

// Add the property pages to the property page shell.

    hr = pMSPShell->AddPage(pPgSources);
    hr = pMSPShell->AddPage(pPgDesc);
    hr = pMSPShell->AddPage(pPgAttr);
    hr = pMSPShell->AddPage(pPgProfile);
    hr = pMSPShell->AddPage(pPgOutput);

// When the end user has finished using the property pages to
// configure the encoder engine and has clicked the Apply button,
// apply the configuration programatically .

    hr = pMSPShell->Apply();

// Reinitialize the property pages to prepare them for a
// new configuration.

    hr = pMSPShell->put_InitNew(VARIANT_TRUE);

See Also

  • IMSPropShell Interface
  • IMSPropShell::put_InitNew
  • IWMEncAttributes Interface
  • IWMEncBroadcast Interface
  • IWMEncDisplayInfo Interface
  • IWMEncoder Interface
  • IWMEncFile Interface
  • IWMEncSourceGroupCollection Interface


IMSPropShell::get_LocaleID

The get_LocaleID method retrieves the national language used in the property pages.

Syntax

HRESULT get_LocaleID(
  long*  pVal
);

Parameters

pVal

[out] Pointer to a long containing the language identifier.

Return Values

If the method succeeds, it returns S_OK. If it fails, it returns an HRESULT error code.

Return code | Meaning
E_POINTER | The pointer to the locale ID is NULL.

Remarks

For more information about locale IDs, see the Microsoft Developer Network page at the Microsoft Web site. Search for localeID, "Table for Language, Locale Names, and Correponding LCIDs (Three-Letter Abbreviations)", the MAKELANGID macro, or the MAKELCID macro.

Use the IMSPropShell::put_LocaleID method to specify the locale ID.

Example Code

// Include libraries.

#include <windows.h>
#include "wmencode.h"
#include "mspropshell.h"

// Declare variables.

    HRESULT hr;
    IWMEncoder* pEncoder;
    IMSPropShell* pMSPShell;
    IUnknown *pPgSources;
    IUnknown *pPgDesc;
    IUnknown *pPgAttr;
    IUnknown *pPgProfile;
    IUnknown *pPgOutput;
    long lLocID;

// Initialize the COM library and retrieve a pointer
// to an IWMEncoder interface.

    hr = CoInitialize(NULL);
    hr = CoCreateInstance(CLSID_WMEncoder,
                          NULL,
                          CLSCTX_INPROC_SERVER,
                          IID_IWMEncoder,
                          (void**) &pEncoder);

// Create the property page shell.

    hr = CoCreateInstance(CLSID_MSPropShell,
                          NULL,
                          CLSCTX_INPROC_SERVER,
                          IID_IMSPropShell,
                          (void**) &pMSPShell);

// Create the Sources property page.

    hr = CoCreateInstance(CLSID_WMEncSourcesPage,
                          NULL,
                          CLSCTX_INPROC_SERVER,
                          IID_IUnknown,
                          (void**) &pPgSources);

// Create the Description property page.

    hr = CoCreateInstance(CLSID_WMEncDisplayInfoPage,
                          NULL,
                          CLSCTX_INPROC_SERVER,
                          IID_IUnknown,
                          (void**) &pPgDesc);

// Create the Attributes property page.

    hr = CoCreateInstance(CLSID_WMEncAttributesPage,
                          NULL,
                          CLSCTX_INPROC_SERVER,
                          IID_IUnknown,
                          (void**) &pPgAttr);

// Create the Profile property page.

    hr = CoCreateInstance(CLSID_WMEncProfilePage,
                          NULL,
                          CLSCTX_INPROC_SERVER,
                          IID_IUnknown,
                          (void**) &pPgProfile);

// Create the Output property page.

    hr = CoCreateInstance(CLSID_WMEncOutputPage,
                          NULL,
                          CLSCTX_INPROC_SERVER,
                          IID_IUnknown,
                          (void**) &pPgOutput);

// Add Windows Media Encoder to the property page shell.
// You must add the encoder before adding the property pages.

    hr = pMSPShell->AddObject((IUnknown*) pEncoder);

// Add the property pages to the property page shell.

    hr = pMSPShell->AddPage(pPgSources);
    hr = pMSPShell->AddPage(pPgDesc);
    hr = pMSPShell->AddPage(pPgAttr);
    hr = pMSPShell->AddPage(pPgProfile);
    hr = pMSPShell->AddPage(pPgOutput);

// Retrieve the language locale ID.

    hr = pMSPShell->get_LocaleID(&lLocID);

See Also

  • IMSPropShell Interface
  • IMSPropShell::put_LocaleID


IMSPropShell::get_PageCount

The get_PageCount method retrieves the number of property pages in the MSPropShell control.

Syntax

HRESULT get_PageCount(
  long*  pVal
);

Parameters

pVal

[out] Pointer to a long containing the number of pages.

Return Values

If the method succeeds, it returns S_OK. If it fails, it returns an HRESULT error code.

Return code | Meaning
E_POINTER | The pointer to the page count is NULL.

Example Code

// Include libraries.

#include <windows.h>
#include "wmencode.h"
#include "mspropshell.h"

// Declare variables.

    HRESULT hr;
    IWMEncoder* pEncoder;
    IMSPropShell* pMSPShell;
    IUnknown *pPgSources;
    IUnknown *pPgDesc;
    IUnknown *pPgAttr;
    IUnknown *pPgProfile;
    IUnknown *pPgOutput;
    long lPageCount;

// Initialize the COM library and retrieve a pointer
// to an IWMEncoder interface.

    hr = CoInitialize(NULL);
    hr = CoCreateInstance(CLSID_WMEncoder,
                          NULL,
                          CLSCTX_INPROC_SERVER,
                          IID_IWMEncoder,
                          (void**) &pEncoder);

// Create the property page shell.

    hr = CoCreateInstance(CLSID_MSPropShell,
                          NULL,
                          CLSCTX_INPROC_SERVER,
                          IID_IMSPropShell,
                          (void**) &pMSPShell);

// Create the Sources property page.

    hr = CoCreateInstance(CLSID_WMEncSourcesPage,
                          NULL,
                          CLSCTX_INPROC_SERVER,
                          IID_IUnknown,
                          (void**) &pPgSources);

// Create the Description property page.

    hr = CoCreateInstance(CLSID_WMEncDisplayInfoPage,
                          NULL,
                          CLSCTX_INPROC_SERVER,
                          IID_IUnknown,
                          (void**) &pPgDesc);

// Create the Attributes property page.

    hr = CoCreateInstance(CLSID_WMEncAttributesPage,
                          NULL,
                          CLSCTX_INPROC_SERVER,
                          IID_IUnknown,
                          (void**) &pPgAttr);

// Create the Profile property page.

    hr = CoCreateInstance(CLSID_WMEncProfilePage,
                          NULL,
                          CLSCTX_INPROC_SERVER,
                          IID_IUnknown,
                          (void**) &pPgProfile);

// Create the Output property page.

    hr = CoCreateInstance(CLSID_WMEncOutputPage,
                          NULL,
                          CLSCTX_INPROC_SERVER,
                          IID_IUnknown,
                          (void**) &pPgOutput);

// Add Windows Media Encoder to the property page shell.
// You must add the encoder before adding the property pages.

    hr = pMSPShell->AddObject((IUnknown*) pEncoder);

// Add the property pages to the property page shell.

    hr = pMSPShell->AddPage(pPgSources);
    hr = pMSPShell->AddPage(pPgDesc);
    hr = pMSPShell->AddPage(pPgAttr);
    hr = pMSPShell->AddPage(pPgProfile);
    hr = pMSPShell->AddPage(pPgOutput);

// Retrieve the number of pages in the MSPropShell control.

    hr = pMSPShell->get_PageCount(&lPageCount);

See Also

  • IMSPropShell Interface


IMSPropShell::get_PageHasHelp

The get_PageHasHelp method retrieves a Boolean value indicating whether Help is defined for a specific page.

Syntax

HRESULT get_PageHasHelp(
  long  Index,
  VARIANT_BOOL*  pVal
);

Parameters

Index

[in] long containing the index of a specific property page.

pVal

[out] Pointer to a VARIANT_BOOL indicating whether Help is defined.

Return Values

If the method succeeds, it returns S_OK. If it fails, it returns an HRESULT error code.

Return code | Meaning
E_INVALIDARG | The index cannot be negative or greater than the number of property pages.
E_POINTER | The pointer is NULL.

Remarks

You can use the get_PageHasHelp method to identify when a Help button should be enabled or disabled.

Example Code

// Include libraries.

#include <windows.h>
#include <atlbase.h>
#include "wmencode.h"
#include "mspropshell.h"

// Declare variables.

    HRESULT hr;
    IWMEncoder* pEncoder;
    IMSPropShell* pMSPShell;
    IUnknown *pPgSources;
    IUnknown *pPgDesc;
    IUnknown *pPgAttr;
    IUnknown *pPgProfile;
    IUnknown *pPgOutput;
    long lPageIndex;
    VARIANT_BOOL bHelp;

// Initialize the COM library and retrieve a pointer
// to an IWMEncoder interface.

    hr = CoInitialize(NULL);
    hr = CoCreateInstance(CLSID_WMEncoder,
                          NULL,
                          CLSCTX_INPROC_SERVER,
                          IID_IWMEncoder,
                          (void**) &pEncoder);

// Create the property page shell.

    hr = CoCreateInstance(CLSID_MSPropShell,
                          NULL,
                          CLSCTX_INPROC_SERVER,
                          IID_IMSPropShell,
                          (void**) &pMSPShell);

// Create the Sources property page.

    hr = CoCreateInstance(CLSID_WMEncSourcesPage,
                          NULL,
                          CLSCTX_INPROC_SERVER,
                          IID_IUnknown,
                          (void**) &pPgSources);

// Create the Description property page.

    hr = CoCreateInstance(CLSID_WMEncDisplayInfoPage,
                          NULL,
                          CLSCTX_INPROC_SERVER,
                          IID_IUnknown,
                          (void**) &pPgDesc);

// Create the Attributes property page.

    hr = CoCreateInstance(CLSID_WMEncAttributesPage,
                          NULL,
                          CLSCTX_INPROC_SERVER,
                          IID_IUnknown,
                          (void**) &pPgAttr);

// Create the Profile property page.

    hr = CoCreateInstance(CLSID_WMEncProfilePage,
                          NULL,
                          CLSCTX_INPROC_SERVER,
                          IID_IUnknown,
                          (void**) &pPgProfile);

// Create the Output property page.

    hr = CoCreateInstance(CLSID_WMEncOutputPage,
                          NULL,
                          CLSCTX_INPROC_SERVER,
                          IID_IUnknown,
                          (void**) &pPgOutput);

// Add Windows Media Encoder to the property page shell.
// You must add the encoder before adding the property pages.

    hr = pMSPShell->AddObject((IUnknown*) pEncoder);

// Add the property pages to the property page shell.

    hr = pMSPShell->AddPage(pPgSources);
    hr = pMSPShell->AddPage(pPgDesc);
    hr = pMSPShell->AddPage(pPgAttr);
    hr = pMSPShell->AddPage(pPgProfile);
    hr = pMSPShell->AddPage(pPgOutput);

// Retrieve the index of the active property page.

    hr = pMSPShell->get_PageIndex(&lPageIndex);

// Determine whether the active page has Help.

    hr = pMSPShell->get_PageHasHelp(lPageIndex, &bHelp);

// Display the Help for that page.

    if (bHelp == VARIANT_TRUE)
    {
        hr = pMSPShell->ShowPageHelp (lPageIndex);
    }

See Also

  • IMSPropShell Interface


IMSPropShell::get_PageIndex

The get_PageIndex method retrieves the index of the active property page.

Syntax

HRESULT get_PageIndex(
  long*  pVal
);

Parameters

pVal

[out] Pointer to a long containing the index of the active page.

Return Values

If the method succeeds, it returns S_OK. If it fails, it returns an HRESULT error code.

Return code | Meaning
E_POINTER | The pointer to the active page is NULL.

Remarks

Use IMSPropShell::put_PageIndex to change the active page.

Example Code

// Include libraries.

#include <windows.h>
#include <atlbase.h>
#include "wmencode.h"
#include "mspropshell.h"

// Declare variables.

    HRESULT hr;
    IWMEncoder* pEncoder;
    IMSPropShell* pMSPShell;
    IUnknown *pPgSources;
    IUnknown *pPgDesc;
    IUnknown *pPgAttr;
    IUnknown *pPgProfile;
    IUnknown *pPgOutput;
    long lPageIndex;
    VARIANT_BOOL bHelp;

// Initialize the COM library and retrieve a pointer
// to an IWMEncoder interface.

    hr = CoInitialize(NULL);
    hr = CoCreateInstance(CLSID_WMEncoder,
                          NULL,
                          CLSCTX_INPROC_SERVER,
                          IID_IWMEncoder,
                          (void**) &pEncoder);

// Create the property page shell.

    hr = CoCreateInstance(CLSID_MSPropShell,
                          NULL,
                          CLSCTX_INPROC_SERVER,
                          IID_IMSPropShell,
                          (void**) &pMSPShell);

// Create the Sources property page.

    hr = CoCreateInstance(CLSID_WMEncSourcesPage,
                          NULL,
                          CLSCTX_INPROC_SERVER,
                          IID_IUnknown,
                          (void**) &pPgSources);

// Create the Description property page.

    hr = CoCreateInstance(CLSID_WMEncDisplayInfoPage,
                          NULL,
                          CLSCTX_INPROC_SERVER,
                          IID_IUnknown,
                          (void**) &pPgDesc);

// Create the Attributes property page.

    hr = CoCreateInstance(CLSID_WMEncAttributesPage,
                          NULL,
                          CLSCTX_INPROC_SERVER,
                          IID_IUnknown,
                          (void**) &pPgAttr);

// Create the Profile property page.

    hr = CoCreateInstance(CLSID_WMEncProfilePage,
                          NULL,
                          CLSCTX_INPROC_SERVER,
                          IID_IUnknown,
                          (void**) &pPgProfile);

// Create the Output property page.

    hr = CoCreateInstance(CLSID_WMEncOutputPage,
                          NULL,
                          CLSCTX_INPROC_SERVER,
                          IID_IUnknown,
                          (void**) &pPgOutput);

// Add Windows Media Encoder to the property page shell.
// You must add the encoder before adding the property pages.

    hr = pMSPShell->AddObject((IUnknown*) pEncoder);

// Add the property pages to the property page shell.

    hr = pMSPShell->AddPage(pPgSources);
    hr = pMSPShell->AddPage(pPgDesc);
    hr = pMSPShell->AddPage(pPgAttr);
    hr = pMSPShell->AddPage(pPgProfile);
    hr = pMSPShell->AddPage(pPgOutput);

// Retrieve the index of the active property page.

    hr = pMSPShell->get_PageIndex(&lPageIndex);

// Determine whether the active page has Help.

    hr = pMSPShell->get_PageHasHelp(lPageIndex, &bHelp);

// Display the Help for that page.

    if (bHelp == VARIANT_TRUE)
    {
        hr = pMSPShell->ShowPageHelp (lPageIndex);
    }

See Also

  • IMSPropShell Interface
  • IMSPropShell::put_PageIndex


IMSPropShell::get_PageTitle

The get_PageTitle method retrieves the title of a specific property page.

Syntax

HRESULT get_PageTitle(
  long  Index,
  BSTR*  pbstrTitle
);

Parameters

Index

[in] long containing the index of the property page.

pbstrTitle

[out] Pointer to a BSTR containing the title.

Return Values

If the method succeeds, it returns S_OK. If it fails, it returns an HRESULT error code.

Return code | Meaning
E_INVALIDARG | The index cannot be negative or greater than the number of property pages.
E_POINTER | The pointer is NULL.

Remarks

The title is the string displayed on the property page tab.

Example Code

// Include libraries.

#include <windows.h>
#include <atlbase.h>
#include "wmencode.h"
#include "mspropshell.h"

// Declare variables.

    HRESULT hr;
    IWMEncoder* pEncoder;
    IMSPropShell* pMSPShell;
    IUnknown *pPgSources;
    IUnknown *pPgDesc;
    IUnknown *pPgAttr;
    IUnknown *pPgProfile;
    IUnknown *pPgOutput;
    long lPageIndex;
    CComBSTR bstrTitle;

// Initialize the COM library and retrieve a pointer
// to an IWMEncoder interface.

    hr = CoInitialize(NULL);
    hr = CoCreateInstance(CLSID_WMEncoder,
                          NULL,
                          CLSCTX_INPROC_SERVER,
                          IID_IWMEncoder,
                          (void**) &pEncoder);

// Create the property page shell.

    hr = CoCreateInstance(CLSID_MSPropShell,
                          NULL,
                          CLSCTX_INPROC_SERVER,
                          IID_IMSPropShell,
                          (void**) &pMSPShell);

// Create the Sources property page.

    hr = CoCreateInstance(CLSID_WMEncSourcesPage,
                          NULL,
                          CLSCTX_INPROC_SERVER,
                          IID_IUnknown,
                          (void**) &pPgSources);

// Create the Description property page.

    hr = CoCreateInstance(CLSID_WMEncDisplayInfoPage,
                          NULL,
                          CLSCTX_INPROC_SERVER,
                          IID_IUnknown,
                          (void**) &pPgDesc);

// Create the Attributes property page.

    hr = CoCreateInstance(CLSID_WMEncAttributesPage,
                          NULL,
                          CLSCTX_INPROC_SERVER,
                          IID_IUnknown,
                          (void**) &pPgAttr);

// Create the Profile property page.

    hr = CoCreateInstance(CLSID_WMEncProfilePage,
                          NULL,
                          CLSCTX_INPROC_SERVER,
                          IID_IUnknown,
                          (void**) &pPgProfile);

// Create the Output property page.

    hr = CoCreateInstance(CLSID_WMEncOutputPage,
                          NULL,
                          CLSCTX_INPROC_SERVER,
                          IID_IUnknown,
                          (void**) &pPgOutput);

// Add Windows Media Encoder to the property page shell.
// You must add the encoder before adding the property pages.

    hr = pMSPShell->AddObject((IUnknown*) pEncoder);

// Add the property pages to the property page shell.

    hr = pMSPShell->AddPage(pPgSources);
    hr = pMSPShell->AddPage(pPgDesc);
    hr = pMSPShell->AddPage(pPgAttr);
    hr = pMSPShell->AddPage(pPgProfile);
    hr = pMSPShell->AddPage(pPgOutput);

// Retrieve the title of the third property page.
// The index is zero-based.

    lPageIndex = 2;
    hr = pMSPShell->get_PageTitle(lPageIndex, &bstrTitle);

See Also

  • IMSPropShell Interface


IMSPropShell::get_Style

The get_Style method retrieves an enumeration type member indicating whether the property pages are displayed with tabs.

Syntax

HRESULT get_Style(
  PSSTYLE*  pVal
);

Parameters

pVal

[out] Pointer to a PSSTYLE enumeration-type member indicating whether the property pages are displayed with tabs. This must be one of the following values.

Value | Description
pssNoTabs | The property pages are displayed without tabs. This is preferred for displaying pages in a wizard.
pssTabsTop | Tabs are displayed on the top edge of the property pages.
pssTabsBottom | Tabs are displayed on the bottom edge of the property pages.

Return Values

If the method succeeds, it returns S_OK. If it fails, it returns an HRESULT error code.

Return code | Meaning
E_POINTER | The pointer to the page style is NULL.

Remarks

Pages can be displayed either with or without tabs. The former is preferred for a standard user interface, and the latter for a wizard. If tabs are omitted, you must provide a way of moving through the pages. For instance, Back and Next buttons can be implemented. Use IMSPropShell::put_Style to set the property page style.

Example Code

// Include libraries.

#include <windows.h>
#include "wmencode.h"
#include "mspropshell.h"

// Declare variables.

    HRESULT hr;
    IWMEncoder* pEncoder;
    IMSPropShell* pMSPShell;
    IUnknown *pPgSources;
    IUnknown *pPgDesc;
    IUnknown *pPgAttr;
    IUnknown *pPgProfile;
    IUnknown *pPgOutput;
    PSSTYLE enumPSStyle;
    short iTabWidth;

// Initialize the COM library and retrieve a pointer
// to an IWMEncoder interface.

    hr = CoInitialize(NULL);
    hr = CoCreateInstance(CLSID_WMEncoder,
                          NULL,
                          CLSCTX_INPROC_SERVER,
                          IID_IWMEncoder,
                          (void**) &pEncoder);

// Create the property page shell.

    hr = CoCreateInstance(CLSID_MSPropShell,
                          NULL,
                          CLSCTX_INPROC_SERVER,
                          IID_IMSPropShell,
                          (void**) &pMSPShell);

// Create the Sources property page.

    hr = CoCreateInstance(CLSID_WMEncSourcesPage,
                          NULL,
                          CLSCTX_INPROC_SERVER,
                          IID_IUnknown,
                          (void**) &pPgSources);

// Create the Description property page.

    hr = CoCreateInstance(CLSID_WMEncDisplayInfoPage,
                          NULL,
                          CLSCTX_INPROC_SERVER,
                          IID_IUnknown,
                          (void**) &pPgDesc);

// Create the Attributes property page.

    hr = CoCreateInstance(CLSID_WMEncAttributesPage,
                          NULL,
                          CLSCTX_INPROC_SERVER,
                          IID_IUnknown,
                          (void**) &pPgAttr);

// Create the Profile property page.

    hr = CoCreateInstance(CLSID_WMEncProfilePage,
                          NULL,
                          CLSCTX_INPROC_SERVER,
                          IID_IUnknown,
                          (void**) &pPgProfile);

// Create the Output property page.

    hr = CoCreateInstance(CLSID_WMEncOutputPage,
                          NULL,
                          CLSCTX_INPROC_SERVER,
                          IID_IUnknown,
                          (void**) &pPgOutput);

// Add Windows Media Encoder to the property page shell.
// You must add the encoder before adding the property pages.

    hr = pMSPShell->AddObject((IUnknown*) pEncoder);

// Add the property pages to the property page shell.

    hr = pMSPShell->AddPage(pPgSources);
    hr = pMSPShell->AddPage(pPgDesc);
    hr = pMSPShell->AddPage(pPgAttr);
    hr = pMSPShell->AddPage(pPgProfile);
    hr = pMSPShell->AddPage(pPgOutput);

// Determine whether the property pages are displayed
// with tabs, and whether the tabs are on the top or the
// bottom of each property page.

    hr = pMSPShell->get_Style(&enumPSStyle);

// Determine the width of the property page tabs.

    if (enumPSStyle != pssNoTabs)
    {
        hr = pMSPShell->get_TabWidth(&iTabWidth);
    }

See Also

  • IMSPropShell Interface
  • IMSPropShell::put_Style


IMSPropShell::get_TabWidth

The get_TabWidth method retrieves the width of the property page tabs.

Syntax

HRESULT get_TabWidth(
  short*  pVal
);

Parameters

pVal

[out] Pointer to a short containing the width, in pixels.

Return Values

If the method succeeds, it returns S_OK. If it fails, it returns an HRESULT error code.

Return code | Meaning
E_POINTER | The pointer to the width is NULL.

Remarks

If the get_TabWidth method returns zero, the width of each tab equals the length of the embedded text. If the get_TabWidth method returns a positive number, the width of each tab, in pixels, is equal to the absolute value of that number. If the get_TabWidth method returns a negative number, the width of each tab is equal to the width of the longest embedded string in all of the tabs plus the absolute value of the number. Check the IMSPropShell::get_Style method to determine whether property pages are displayed with tabs. Use the IMSPropShell::put_TabWidth method to specify the tab width.

Example Code

// Include libraries.

#include <windows.h>
#include "wmencode.h"
#include "mspropshell.h"

// Declare variables.

    HRESULT hr;
    IWMEncoder* pEncoder;
    IMSPropShell* pMSPShell;
    IUnknown *pPgSources;
    IUnknown *pPgDesc;
    IUnknown *pPgAttr;
    IUnknown *pPgProfile;
    IUnknown *pPgOutput;
    PSSTYLE enumPSStyle;
    short iTabWidth;

// Initialize the COM library and retrieve a pointer
// to an IWMEncoder interface.

    hr = CoInitialize(NULL);
    hr = CoCreateInstance(CLSID_WMEncoder,
                          NULL,
                          CLSCTX_INPROC_SERVER,
                          IID_IWMEncoder,
                          (void**) &pEncoder);

// Create the property page shell.

    hr = CoCreateInstance(CLSID_MSPropShell,
                          NULL,
                          CLSCTX_INPROC_SERVER,
                          IID_IMSPropShell,
                          (void**) &pMSPShell);

// Create the Sources property page.

    hr = CoCreateInstance(CLSID_WMEncSourcesPage,
                          NULL,
                          CLSCTX_INPROC_SERVER,
                          IID_IUnknown,
                          (void**) &pPgSources);

// Create the Description property page.

    hr = CoCreateInstance(CLSID_WMEncDisplayInfoPage,
                          NULL,
                          CLSCTX_INPROC_SERVER,
                          IID_IUnknown,
                          (void**) &pPgDesc);

// Create the Attributes property page.

    hr = CoCreateInstance(CLSID_WMEncAttributesPage,
                          NULL,
                          CLSCTX_INPROC_SERVER,
                          IID_IUnknown,
                          (void**) &pPgAttr);

// Create the Profile property page.

    hr = CoCreateInstance(CLSID_WMEncProfilePage,
                          NULL,
                          CLSCTX_INPROC_SERVER,
                          IID_IUnknown,
                          (void**) &pPgProfile);

// Create the Output property page.

    hr = CoCreateInstance(CLSID_WMEncOutputPage,
                          NULL,
                          CLSCTX_INPROC_SERVER,
                          IID_IUnknown,
                          (void**) &pPgOutput);

// Add Windows Media Encoder to the property page shell.
// You must add the encoder before adding the property pages.

    hr = pMSPShell->AddObject((IUnknown*) pEncoder);

// Add the property pages to the property page shell.

    hr = pMSPShell->AddPage(pPgSources);
    hr = pMSPShell->AddPage(pPgDesc);
    hr = pMSPShell->AddPage(pPgAttr);
    hr = pMSPShell->AddPage(pPgProfile);
    hr = pMSPShell->AddPage(pPgOutput);

// Determine whether the property pages are displayed
// with tabs, and whether the tabs are on the top or the
// bottom of each property page.

    hr = pMSPShell->get_Style(&enumPSStyle);

// Determine the width of the property page tabs.

    if (enumPSStyle != pssNoTabs)
    {
        hr = pMSPShell->get_TabWidth(&iTabWidth);
    }

// Set the width of each tab equal to the length, in
// pixels, of the longest embedded string plus the
// absolute value of the specified integer.

    if (iTabWidth == 0)
    {
        iTabWidth = -5;
        hr = pMSPShell->put_TabWidth(iTabWidth);
    }

See Also

  • IMSPropShell::get_Style
  • IMSPropShell Interface
  • IMSPropShell::put_TabWidth


IMSPropShell::GetPage

The GetPage method retrieves a pointer to a specific property page.

Syntax

HRESULT GetPage(
  long  Index,
  LPUNKNOWN*  ppUnknown
);

Parameters

Index

[in] long containing the index of the property page.

ppUnknown

[out] Pointer to the property page specified by Index.

Return Values

If the method succeeds, it returns S_OK. If it fails, it returns an HRESULT error code.

Return code | Meaning
E_INVALIDARG | The index cannot be negative or greater than the number of property pages.
E_POINTER | The pointer to the property page is NULL.

Remarks

You can use the GetPage method to retrieve a pointer to the IUnknown interface of a property page. This enables you to enumerate the property pages and communicate between them.

See Also

  • IMSPropShell::AddPage
  • IMSPropShell Interface


IMSPropShell::put_AutoRefresh

The put_AutoRefresh method specifies a Boolean value indicating whether the property pages are automatically refreshed when either a new property page or a WMEncoder object is attached to them.

Syntax

HRESULT put_AutoRefresh(
  VARIANT_BOOL  newVal
);

Parameters

newVal

[in] VARIANT_BOOL indicating whether property pages are automatically refreshed.

Return Values

If the method succeeds, it returns S_OK. If it fails, it returns E_FAIL.

Remarks

By default, this property returns VARIANT_TRUE. You can attach WMEncoder objects to property pages by calling either the IMSPropShell::Refresh method or by setting the AutoRefresh property to VARIANT_TRUE and calling IMSPropShell::AddObject. You can attach new property pages to existing property pages by calling either the Refresh method or by setting the AutoRefresh property to VARIANT_TRUE and calling IMSPropShell::AddPage. To retrieve the current value of this property, use IMSPropShell::get_AutoRefresh.

Example Code

// Include libraries.

#include <windows.h>
#include "wmencode.h"
#include "mspropshell.h"

// Declare variables.

    HRESULT hr;
    IWMEncoder* pEncoder;
    IMSPropShell* pMSPShell;
    IUnknown *pPgSources;
    IUnknown *pPgDesc;
    IUnknown *pPgAttr;
    IUnknown *pPgProfile;
    IUnknown *pPgOutput;

// Initialize the COM library and retrieve a pointer
// to an IWMEncoder interface.

    hr = CoInitialize(NULL);
    hr = CoCreateInstance(CLSID_WMEncoder,
                          NULL,
                          CLSCTX_INPROC_SERVER,
                          IID_IWMEncoder,
                          (void**) &pEncoder);

// Create the property page shell.

    hr = CoCreateInstance(CLSID_MSPropShell,
                          NULL,
                          CLSCTX_INPROC_SERVER,
                          IID_IMSPropShell,
                          (void**) &pMSPShell);

// Create the Sources property page.

    hr = CoCreateInstance(CLSID_WMEncSourcesPage,
                          NULL,
                          CLSCTX_INPROC_SERVER,
                          IID_IUnknown,
                          (void**) &pPgSources);

// Create the Description property page.

    hr = CoCreateInstance(CLSID_WMEncDisplayInfoPage,
                          NULL,
                          CLSCTX_INPROC_SERVER,
                          IID_IUnknown,
                          (void**) &pPgDesc);

// Create the Attributes property page.

    hr = CoCreateInstance(CLSID_WMEncAttributesPage,
                          NULL,
                          CLSCTX_INPROC_SERVER,
                          IID_IUnknown,
                          (void**) &pPgAttr);

// Create the Profile property page.

    hr = CoCreateInstance(CLSID_WMEncProfilePage,
                          NULL,
                          CLSCTX_INPROC_SERVER,
                          IID_IUnknown,
                          (void**) &pPgProfile);

// Create the Output property page.

    hr = CoCreateInstance(CLSID_WMEncOutputPage,
                          NULL,
                          CLSCTX_INPROC_SERVER,
                          IID_IUnknown,
                          (void**) &pPgOutput);

// Add Windows Media Encoder to the property page shell.
// You must add the encoder before adding the property pages.

    hr = pMSPShell->AddObject((IUnknown*) pEncoder);

// Add the property pages to the property page shell.

    hr = pMSPShell->AddPage(pPgSources);
    hr = pMSPShell->AddPage(pPgDesc);
    hr = pMSPShell->AddPage(pPgAttr);
    hr = pMSPShell->AddPage(pPgProfile);
    hr = pMSPShell->AddPage(pPgOutput);

// Reorder the pages. Call the RemoveAllPages method to remove all
// property pages from the MSPropShell control.

    hr = pMSPShell->RemoveAllPages();

// Set the AutoRefresh property to False so that
// MSPropShell is not refreshed when each new page is added.

    hr = pMSPShell->put_AutoRefresh(VARIANT_FALSE);

// Add the property pages in the desired order.

    hr = pMSPShell->AddPage(pPgOutput);
    hr = pMSPShell->AddPage(pPgAttr);
    hr = pMSPShell->AddPage(pPgProfile);
    hr = pMSPShell->AddPage(pPgSources);
    hr = pMSPShell->AddPage(pPgDesc);

// Refresh the MSPropShell ActiveX control.

    hr = pMSPShell->Refresh();

See Also

  • IMSPropShell::get_AutoRefresh
  • IMSPropShell Interface
  • IWMEncoder Interface


IMSPropShell::put_InitNew

The put_InitNew method specifies a Boolean value indicating whether the property pages hosted by the MSPropShell control must be reinitialized to an empty state.

Syntax

HRESULT put_InitNew(
  VARIANT_BOOL  newVal
);

Parameters

newVal

[in] VARIANT_BOOL indicating whether the property pages must be reset.

Return Values

If the method succeeds, it returns S_OK. If it fails, it returns E_FAIL.

Remarks

Property pages usually display the configuration of the WMEncoder object attached to them. However, you can set the InitNew property to VARIANT_TRUE to ignore the current configuration and display empty pages. Use the IMSPropShell::get_InitNew method to retrieve the Boolean value.

Example Code

// Include libraries.

#include <windows.h>
#include "wmencode.h"
#include "mspropshell.h"

// Declare variables.

    HRESULT hr;
    IWMEncoder* pEncoder;
    IMSPropShell* pMSPShell;
    IUnknown *pPgSources;
    IUnknown *pPgDesc;
    IUnknown *pPgAttr;
    IUnknown *pPgProfile;
    IUnknown *pPgOutput;

// Initialize the COM library and retrieve a pointer
// to an IWMEncoder interface.

    hr = CoInitialize(NULL);
    hr = CoCreateInstance(CLSID_WMEncoder,
                          NULL,
                          CLSCTX_INPROC_SERVER,
                          IID_IWMEncoder,
                          (void**) &pEncoder);

// Create the property page shell.

    hr = CoCreateInstance(CLSID_MSPropShell,
                          NULL,
                          CLSCTX_INPROC_SERVER,
                          IID_IMSPropShell,
                          (void**) &pMSPShell);

// Create the Sources property page.

    hr = CoCreateInstance(CLSID_WMEncSourcesPage,
                          NULL,
                          CLSCTX_INPROC_SERVER,
                          IID_IUnknown,
                          (void**) &pPgSources);

// Create the Description property page.

    hr = CoCreateInstance(CLSID_WMEncDisplayInfoPage,
                          NULL,
                          CLSCTX_INPROC_SERVER,
                          IID_IUnknown,
                          (void**) &pPgDesc);

// Create the Attributes property page.

    hr = CoCreateInstance(CLSID_WMEncAttributesPage,
                          NULL,
                          CLSCTX_INPROC_SERVER,
                          IID_IUnknown,
                          (void**) &pPgAttr);

// Create the Profile property page.

    hr = CoCreateInstance(CLSID_WMEncProfilePage,
                          NULL,
                          CLSCTX_INPROC_SERVER,
                          IID_IUnknown,
                          (void**) &pPgProfile);

// Create the Output property page.

    hr = CoCreateInstance(CLSID_WMEncOutputPage,
                          NULL,
                          CLSCTX_INPROC_SERVER,
                          IID_IUnknown,
                          (void**) &pPgOutput);

// Add Windows Media Encoder to the property page shell.
// You must add the encoder before adding the property pages.

    hr = pMSPShell->AddObject((IUnknown*) pEncoder);

// Add the property pages to the property page shell.

    hr = pMSPShell->AddPage(pPgSources);
    hr = pMSPShell->AddPage(pPgDesc);
    hr = pMSPShell->AddPage(pPgAttr);
    hr = pMSPShell->AddPage(pPgProfile);
    hr = pMSPShell->AddPage(pPgOutput);

// When the end user has finished using the property pages to
// configure the encoder engine and has clicked the Apply button,
// apply the configuration programatically.

    hr = pMSPShell->Apply();

// Reinitialize the property pages to prepare them for a
// new configuration.

    hr = pMSPShell->put_InitNew(VARIANT_TRUE);

See Also

  • IMSPropShell::get_InitNew
  • IMSPropShell Interface
  • IWMEncAttributes Interface
  • IWMEncBroadcast Interface
  • IWMEncDisplayInfo Interface
  • IWMEncoder Interface
  • IWMEncFile Interface
  • IWMEncSourceGroupCollection Interface


IMSPropShell::put_LocaleID

The put_LocaleID method specifies the national language used in the property pages.

Syntax

HRESULT put_LocaleID(
  long  newVal
);

Parameters

newVal

[in] long containing the locale ID.

Return Values

If the method succeeds, it returns S_OK. If it fails, it returns E_FAIL.

Remarks

For more information about locale IDs, see the Microsoft Developer Network page at the Microsoft Web site. Search for localeID, "Table for Language, Locale Names, and Correponding LCIDs (Three-Letter Abbreviations)", the MAKELANGID macro, or the MAKELCID macro.

Use the IMSPropShell::get_LocaleID method to determine the current value of the locale ID.

Example Code

// Include libraries.

#include <windows.h>
#include "wmencode.h"
#include "mspropshell.h"

// Declare variables.

    HRESULT hr;
    IWMEncoder* pEncoder;
    IMSPropShell* pMSPShell;
    IUnknown *pPgSources;
    IUnknown *pPgDesc;
    IUnknown *pPgAttr;
    IUnknown *pPgProfile;
    IUnknown *pPgOutput;
    long lLocID;

// Initialize the COM library and retrieve a pointer
// to an IWMEncoder interface.

    hr = CoInitialize(NULL);
    hr = CoCreateInstance(CLSID_WMEncoder,
                          NULL,
                          CLSCTX_INPROC_SERVER,
                          IID_IWMEncoder,
                          (void**) &pEncoder);

// Create the property page shell.

    hr = CoCreateInstance(CLSID_MSPropShell,
                          NULL,
                          CLSCTX_INPROC_SERVER,
                          IID_IMSPropShell,
                          (void**) &pMSPShell);

// Create the Sources property page.

    hr = CoCreateInstance(CLSID_WMEncSourcesPage,
                          NULL,
                          CLSCTX_INPROC_SERVER,
                          IID_IUnknown,
                          (void**) &pPgSources);

// Create the Description property page.

    hr = CoCreateInstance(CLSID_WMEncDisplayInfoPage,
                          NULL,
                          CLSCTX_INPROC_SERVER,
                          IID_IUnknown,
                          (void**) &pPgDesc);

// Create the Attributes property page.

    hr = CoCreateInstance(CLSID_WMEncAttributesPage,
                          NULL,
                          CLSCTX_INPROC_SERVER,
                          IID_IUnknown,
                          (void**) &pPgAttr);

// Create the Profile property page.

    hr = CoCreateInstance(CLSID_WMEncProfilePage,
                          NULL,
                          CLSCTX_INPROC_SERVER,
                          IID_IUnknown,
                          (void**) &pPgProfile);

// Create the Output property page.

    hr = CoCreateInstance(CLSID_WMEncOutputPage,
                          NULL,
                          CLSCTX_INPROC_SERVER,
                          IID_IUnknown,
                          (void**) &pPgOutput);

// Add Windows Media Encoder to the property page shell.
// You must add the encoder before adding the property pages.

    hr = pMSPShell->AddObject((IUnknown*) pEncoder);

// Add the property pages to the property page shell.

    hr = pMSPShell->AddPage(pPgSources);
    hr = pMSPShell->AddPage(pPgDesc);
    hr = pMSPShell->AddPage(pPgAttr);
    hr = pMSPShell->AddPage(pPgProfile);
    hr = pMSPShell->AddPage(pPgOutput);

// Retrieve the language locale ID.

    hr = pMSPShell->get_LocaleID(&lLocID);

See Also

  • IMSPropShell::get_LocaleID
  • IMSPropShell Interface


IMSPropShell::put_PageIndex

The put_PageIndex method specifies the active property page.

Syntax

HRESULT put_PageIndex(
  long  newVal
);

Parameters

newVal

[in] long containing the index number of the property page to make active.

Return Values

If the method succeeds, it returns S_OK. If it fails, it returns an HRESULT error code.

Return code | Meaning
E_INVALIDARG | The index cannot be either negative or greater than the number of property pages.

Remarks

Use IMSPropShell::get_PageIndex to retrieve the index of the active page.

Example Code

// Include libraries.

#include <windows.h>
#include <atlbase.h>
#include "wmencode.h"
#include "mspropshell.h"

// Declare variables.

    HRESULT hr;
    IWMEncoder* pEncoder;
    IMSPropShell* pMSPShell;
    IUnknown *pPgSources;
    IUnknown *pPgDesc;
    IUnknown *pPgAttr;
    IUnknown *pPgProfile;
    IUnknown *pPgOutput;
    long lPageIndex;
    VARIANT_BOOL bHelp;

// Initialize the COM library and retrieve a pointer
// to an IWMEncoder interface.

    hr = CoInitialize(NULL);
    hr = CoCreateInstance(CLSID_WMEncoder,
                          NULL,
                          CLSCTX_INPROC_SERVER,
                          IID_IWMEncoder,
                          (void**) &pEncoder);

// Create the property page shell.

    hr = CoCreateInstance(CLSID_MSPropShell,
                          NULL,
                          CLSCTX_INPROC_SERVER,
                          IID_IMSPropShell,
                          (void**) &pMSPShell);

// Create the Sources property page.

    hr = CoCreateInstance(CLSID_WMEncSourcesPage,
                          NULL,
                          CLSCTX_INPROC_SERVER,
                          IID_IUnknown,
                          (void**) &pPgSources);

// Create the Description property page.

    hr = CoCreateInstance(CLSID_WMEncDisplayInfoPage,
                          NULL,
                          CLSCTX_INPROC_SERVER,
                          IID_IUnknown,
                          (void**) &pPgDesc);

// Create the Attributes property page.

    hr = CoCreateInstance(CLSID_WMEncAttributesPage,
                          NULL,
                          CLSCTX_INPROC_SERVER,
                          IID_IUnknown,
                          (void**) &pPgAttr);

// Create the Profile property page.

    hr = CoCreateInstance(CLSID_WMEncProfilePage,
                          NULL,
                          CLSCTX_INPROC_SERVER,
                          IID_IUnknown,
                          (void**) &pPgProfile);

// Create the Output property page.

    hr = CoCreateInstance(CLSID_WMEncOutputPage,
                          NULL,
                          CLSCTX_INPROC_SERVER,
                          IID_IUnknown,
                          (void**) &pPgOutput);

// Add Windows Media Encoder to the property page shell.
// You must add the encoder before adding the property pages.

    hr = pMSPShell->AddObject((IUnknown*) pEncoder);

// Add the property pages to the property page shell.

    hr = pMSPShell->AddPage(pPgSources);
    hr = pMSPShell->AddPage(pPgDesc);
    hr = pMSPShell->AddPage(pPgAttr);
    hr = pMSPShell->AddPage(pPgProfile);
    hr = pMSPShell->AddPage(pPgOutput);

// Retrieve the index of the active property page.

    hr = pMSPShell->get_PageIndex(&lPageIndex);

// Determine whether the active page has Help.

    hr = pMSPShell->get_PageHasHelp(lPageIndex, &bHelp);

// Display the Help for that page.

    if (bHelp == VARIANT_TRUE)
    {
        hr = pMSPShell->ShowPageHelp (lPageIndex);
    }

See Also

  • IMSPropShell::get_PageIndex
  • IMSPropShell Interface


IMSPropShell::put_Style

The put_Style method specifies whether the property pages are displayed with tabs.

Syntax

HRESULT put_Style(
  PSSTYLE  newVal
);

Parameters

newVal

[in] Member of a PSSTYLE enumeration type indicating whether the property pages are displayed with tabs. This must be one of the following values.

Value | Description
PssTabbed | The property pages are displayed with tabs.
PssWizard | The property pages are displayed without tabs. This is preferred for displaying pages in a wizard.

Return Values

If the method succeeds, it returns S_OK. If it fails, it returns E_FAIL.

Remarks

Pages can be displayed either with or without tabs. The former is preferred for a standard user interface, and the latter for a wizard. If tabs are omitted, you must provide a way of moving through the pages. For instance, Back and Next buttons can be implemented. Use IMSPropShell::get_Style to retrieve the property page style.

Example Code

// Include libraries.

#include <windows.h>
#include "wmencode.h"
#include "mspropshell.h"

// Declare variables.

    HRESULT hr;
    IWMEncoder* pEncoder;
    IMSPropShell* pMSPShell;
    IUnknown *pPgSources;
    IUnknown *pPgDesc;
    IUnknown *pPgAttr;
    IUnknown *pPgProfile;
    IUnknown *pPgOutput;
    PSSTYLE enumPSStyle;
    short iTabWidth;

// Initialize the COM library and retrieve a pointer
// to an IWMEncoder interface.

    hr = CoInitialize(NULL);
    hr = CoCreateInstance(CLSID_WMEncoder,
                          NULL,
                          CLSCTX_INPROC_SERVER,
                          IID_IWMEncoder,
                          (void**) &pEncoder);

// Create the property page shell.

    hr = CoCreateInstance(CLSID_MSPropShell,
                          NULL,
                          CLSCTX_INPROC_SERVER,
                          IID_IMSPropShell,
                          (void**) &pMSPShell);

// Create the Sources property page.

    hr = CoCreateInstance(CLSID_WMEncSourcesPage,
                          NULL,
                          CLSCTX_INPROC_SERVER,
                          IID_IUnknown,
                          (void**) &pPgSources);

// Create the Description property page.

    hr = CoCreateInstance(CLSID_WMEncDisplayInfoPage,
                          NULL,
                          CLSCTX_INPROC_SERVER,
                          IID_IUnknown,
                          (void**) &pPgDesc);

// Create the Attributes property page.

    hr = CoCreateInstance(CLSID_WMEncAttributesPage,
                          NULL,
                          CLSCTX_INPROC_SERVER,
                          IID_IUnknown,
                          (void**) &pPgAttr);

// Create the Profile property page.

    hr = CoCreateInstance(CLSID_WMEncProfilePage,
                          NULL,
                          CLSCTX_INPROC_SERVER,
                          IID_IUnknown,
                          (void**) &pPgProfile);

// Create the Output property page.

    hr = CoCreateInstance(CLSID_WMEncOutputPage,
                          NULL,
                          CLSCTX_INPROC_SERVER,
                          IID_IUnknown,
                          (void**) &pPgOutput);

// Add Windows Media Encoder to the property page shell.
// You must add the encoder before adding the property pages.

    hr = pMSPShell->AddObject((IUnknown*) pEncoder);

// Add the property pages to the property page shell.

    hr = pMSPShell->AddPage(pPgSources);
    hr = pMSPShell->AddPage(pPgDesc);
    hr = pMSPShell->AddPage(pPgAttr);
    hr = pMSPShell->AddPage(pPgProfile);
    hr = pMSPShell->AddPage(pPgOutput);

// Determine whether the property pages are displayed
// with tabs, and whether the tabs are on the top or the
// bottom of each property page.

    hr = pMSPShell->get_Style(&enumPSStyle);

// Determine the width of the property page tabs.

    if (enumPSStyle != pssNoTabs)
    {
        hr = pMSPShell->get_TabWidth(&iTabWidth);
    }

See Also

  • IMSPropShell::get_Style
  • IMSPropShell Interface


IMSPropShell::put_TabWidth

The put_TabWidth method specifies the width of the property page tabs.

Syntax

HRESULT put_TabWidth(
  short  newVal
);

Parameters

newVal

[in] short containing the tab width, in pixels.

Return Values

If the method succeeds, it returns S_OK. If it fails, it returns E_FAIL.

Remarks

If you specify zero, the width of each tab equals the length of the embedded text. If you specify a positive number, the width of each tab, in pixels, is equal to the absolute value of that number. If you specify a negative number, the width of each tab is equal to the width of the longest embedded string in all of the tabs plus the absolute value of the number. Check the IMSPropShell::get_Style method to determine whether property pages are displayed with tabs. Use the IMSPropShell::get_TabWidth method to retrieve the tab width.

Example Code

// Include libraries.

#include <windows.h>
#include "wmencode.h"
#include "mspropshell.h"

// Declare variables.

    HRESULT hr;
    IWMEncoder* pEncoder;
    IMSPropShell* pMSPShell;
    IUnknown *pPgSources;
    IUnknown *pPgDesc;
    IUnknown *pPgAttr;
    IUnknown *pPgProfile;
    IUnknown *pPgOutput;
    PSSTYLE enumPSStyle;
    short iTabWidth;

// Initialize the COM library and retrieve a pointer
// to an IWMEncoder interface.

    hr = CoInitialize(NULL);
    hr = CoCreateInstance(CLSID_WMEncoder,
                          NULL,
                          CLSCTX_INPROC_SERVER,
                          IID_IWMEncoder,
                          (void**) &pEncoder);

// Create the property page shell.

    hr = CoCreateInstance(CLSID_MSPropShell,
                          NULL,
                          CLSCTX_INPROC_SERVER,
                          IID_IMSPropShell,
                          (void**) &pMSPShell);

// Create the Sources property page.

    hr = CoCreateInstance(CLSID_WMEncSourcesPage,
                          NULL,
                          CLSCTX_INPROC_SERVER,
                          IID_IUnknown,
                          (void**) &pPgSources);

// Create the Description property page.

    hr = CoCreateInstance(CLSID_WMEncDisplayInfoPage,
                          NULL,
                          CLSCTX_INPROC_SERVER,
                          IID_IUnknown,
                          (void**) &pPgDesc);

// Create the Attributes property page.

    hr = CoCreateInstance(CLSID_WMEncAttributesPage,
                          NULL,
                          CLSCTX_INPROC_SERVER,
                          IID_IUnknown,
                          (void**) &pPgAttr);

// Create the Profile property page.

    hr = CoCreateInstance(CLSID_WMEncProfilePage,
                          NULL,
                          CLSCTX_INPROC_SERVER,
                          IID_IUnknown,
                          (void**) &pPgProfile);

// Create the Output property page.

    hr = CoCreateInstance(CLSID_WMEncOutputPage,
                          NULL,
                          CLSCTX_INPROC_SERVER,
                          IID_IUnknown,
                          (void**) &pPgOutput);

// Add Windows Media Encoder to the property page shell.
// You must add the encoder before adding the property pages.

    hr = pMSPShell->AddObject((IUnknown*) pEncoder);

// Add the property pages to the property page shell.

    hr = pMSPShell->AddPage(pPgSources);
    hr = pMSPShell->AddPage(pPgDesc);
    hr = pMSPShell->AddPage(pPgAttr);
    hr = pMSPShell->AddPage(pPgProfile);
    hr = pMSPShell->AddPage(pPgOutput);

// Determine whether the property pages are displayed
// with tabs, and whether the tabs are on the top or the
// bottom of each property page.

    hr = pMSPShell->get_Style(&enumPSStyle);

// Determine the width of the property page tabs.

    if (enumPSStyle != pssNoTabs)
    {
        hr = pMSPShell->get_TabWidth(&iTabWidth);
    }

// Set the width of each tab equal to the length, in
// pixels, of the longest embedded string plus the
// absolute value of the specified integer.

    if (iTabWidth == 0)
    {
        iTabWidth = -5;
        hr = pMSPShell->put_TabWidth(iTabWidth);
    }

See Also

  • IMSPropShell::get_TabWidth
  • IMSPropShell Interface


IMSPropShell::Refresh

The Refresh method recreates all of the property pages in the MSPropShell control.

Syntax

HRESULT Refresh();

Parameters

This method takes no parameters.

Return Values

If the method succeeds, it returns S_OK. If it fails, it returns an HRESULT error code.

Return code | Meaning
E_OUTOFMEMORY | Insufficient memory to recreate the property pages.

Remarks

The Refresh method destroys all of the property pages and recreates them. If you add a new WMEncoder object, call Refresh to rebuild the property pages. Alternatively, set the IMSPropShell::put_AutoRefresh property to VARIANT_TRUE to control this automatically.

Example Code

// Include libraries.

#include <windows.h>
#include "wmencode.h"
#include "mspropshell.h"

// Declare variables.

    HRESULT hr;
    IWMEncoder* pEncoder;
    IMSPropShell* pMSPShell;
    IUnknown *pPgSources;
    IUnknown *pPgDesc;
    IUnknown *pPgAttr;
    IUnknown *pPgProfile;
    IUnknown *pPgOutput;

// Initialize the COM library and retrieve a pointer
// to an IWMEncoder interface.

    hr = CoInitialize(NULL);
    hr = CoCreateInstance(CLSID_WMEncoder,
                          NULL,
                          CLSCTX_INPROC_SERVER,
                          IID_IWMEncoder,
                          (void**) &pEncoder);

// Create the property page shell.

    hr = CoCreateInstance(CLSID_MSPropShell,
                          NULL,
                          CLSCTX_INPROC_SERVER,
                          IID_IMSPropShell,
                          (void**) &pMSPShell);

// Create the Sources property page.

    hr = CoCreateInstance(CLSID_WMEncSourcesPage,
                          NULL,
                          CLSCTX_INPROC_SERVER,
                          IID_IUnknown,
                          (void**) &pPgSources);

// Create the Description property page.

    hr = CoCreateInstance(CLSID_WMEncDisplayInfoPage,
                          NULL,
                          CLSCTX_INPROC_SERVER,
                          IID_IUnknown,
                          (void**) &pPgDesc);

// Create the Attributes property page.

    hr = CoCreateInstance(CLSID_WMEncAttributesPage,
                          NULL,
                          CLSCTX_INPROC_SERVER,
                          IID_IUnknown,
                          (void**) &pPgAttr);

// Create the Profile property page.

    hr = CoCreateInstance(CLSID_WMEncProfilePage,
                          NULL,
                          CLSCTX_INPROC_SERVER,
                          IID_IUnknown,
                          (void**) &pPgProfile);

// Create the Output property page.

    hr = CoCreateInstance(CLSID_WMEncOutputPage,
                          NULL,
                          CLSCTX_INPROC_SERVER,
                          IID_IUnknown,
                          (void**) &pPgOutput);

// Add Windows Media Encoder to the property page shell.
// You must add the encoder before adding the property pages.

    hr = pMSPShell->AddObject((IUnknown*) pEncoder);

// Add the property pages to the property page shell.

    hr = pMSPShell->AddPage(pPgSources);
    hr = pMSPShell->AddPage(pPgDesc);
    hr = pMSPShell->AddPage(pPgAttr);
    hr = pMSPShell->AddPage(pPgProfile);
    hr = pMSPShell->AddPage(pPgOutput);

// Reorder the pages. Call the RemoveAllPages method to remove all
// property pages from the MSPropShell control.

    hr = pMSPShell->RemoveAllPages();

// Set the AutoRefresh property to False so that
// MSPropShell is not refreshed when each new page is added.

    hr = pMSPShell->put_AutoRefresh(VARIANT_FALSE);

// Add the property pages in the desired order.

    hr = pMSPShell->AddPage(pPgOutput);
    hr = pMSPShell->AddPage(pPgAttr);
    hr = pMSPShell->AddPage(pPgProfile);
    hr = pMSPShell->AddPage(pPgSources);
    hr = pMSPShell->AddPage(pPgDesc);

// Refresh the MSPropShell ActiveX control.

    hr = pMSPShell->Refresh();

See Also

  • IMSPropShell Interface
  • IMSPropShell::put_AutoRefresh
  • IWMEncoder Interface


IMSPropShell::RemoveAllObjects

The RemoveAllObjects method removes all WMEncoder objects from the MSPropShell control.

Syntax

HRESULT RemoveAllObjects();

Parameters

This method takes no parameters.

Return Values

If the method succeeds, it returns S_OK. If it fails, it returns E_FAIL.

Remarks

To delete a single WMEncoder object, you must remove all instances and use IMSPropShell::AddObject to add back only those you want to retain. Before calling AddObject, set IMSPropShell::put_AutoRefresh to VARIANT_FALSE and afterward, if you want, reset it to VARIANT_TRUE.

See Also

  • IMSPropShell::AddObject
  • IMSPropShell Interface
  • IMSPropShell::put_AutoRefresh
  • IWMEncoder Interface


IMSPropShell::RemoveAllPages

The RemoveAllPages method removes all of the property pages from the MSPropShell control.

Syntax

HRESULT RemoveAllPages();

Parameters

This method takes no parameters.

Return Values

If the method succeeds, it returns S_OK. If it fails, it returns E_FAIL.

Remarks

Use this method to delete or reorder property pages. When all of the pages have been deleted, reorder them by calling IMSPropShell::AddPage multiple times in the correct sequence. To avoid automatically refreshing after every page is added, set IMSPropShell::put_AutoRefresh to VARIANT_FALSE.

Example Code

// Include libraries.

#include <windows.h>
#include "wmencode.h"
#include "mspropshell.h"

// Declare variables.

    HRESULT hr;
    IWMEncoder* pEncoder;
    IMSPropShell* pMSPShell;
    IUnknown *pPgSources;
    IUnknown *pPgDesc;
    IUnknown *pPgAttr;
    IUnknown *pPgProfile;
    IUnknown *pPgOutput;

// Initialize the COM library and retrieve a pointer
// to an IWMEncoder interface.

    hr = CoInitialize(NULL);
    hr = CoCreateInstance(CLSID_WMEncoder,
                          NULL,
                          CLSCTX_INPROC_SERVER,
                          IID_IWMEncoder,
                          (void**) &pEncoder);

// Create the property page shell.

    hr = CoCreateInstance(CLSID_MSPropShell,
                          NULL,
                          CLSCTX_INPROC_SERVER,
                          IID_IMSPropShell,
                          (void**) &pMSPShell);

// Create the Sources property page.

    hr = CoCreateInstance(CLSID_WMEncSourcesPage,
                          NULL,
                          CLSCTX_INPROC_SERVER,
                          IID_IUnknown,
                          (void**) &pPgSources);

// Create the Description property page.

    hr = CoCreateInstance(CLSID_WMEncDisplayInfoPage,
                          NULL,
                          CLSCTX_INPROC_SERVER,
                          IID_IUnknown,
                          (void**) &pPgDesc);

// Create the Attributes property page.

    hr = CoCreateInstance(CLSID_WMEncAttributesPage,
                          NULL,
                          CLSCTX_INPROC_SERVER,
                          IID_IUnknown,
                          (void**) &pPgAttr);

// Create the Profile property page.

    hr = CoCreateInstance(CLSID_WMEncProfilePage,
                          NULL,
                          CLSCTX_INPROC_SERVER,
                          IID_IUnknown,
                          (void**) &pPgProfile);

// Create the Output property page.

    hr = CoCreateInstance(CLSID_WMEncOutputPage,
                          NULL,
                          CLSCTX_INPROC_SERVER,
                          IID_IUnknown,
                          (void**) &pPgOutput);

// Add Windows Media Encoder to the property page shell.
// You must add the encoder before adding the property pages.

    hr = pMSPShell->AddObject((IUnknown*) pEncoder);

// Add the property pages to the property page shell.

    hr = pMSPShell->AddPage(pPgSources);
    hr = pMSPShell->AddPage(pPgDesc);
    hr = pMSPShell->AddPage(pPgAttr);
    hr = pMSPShell->AddPage(pPgProfile);
    hr = pMSPShell->AddPage(pPgOutput);

// Reorder the pages. Call the RemoveAllPages method to remove all
// property pages from the MSPropShell control.

    hr = pMSPShell->RemoveAllPages();

// Set the AutoRefresh property to False so that
// MSPropShell is not refreshed when each new page is added.

    hr = pMSPShell->put_AutoRefresh(VARIANT_FALSE);

// Add the property pages in the desired order.

    hr = pMSPShell->AddPage(pPgOutput);
    hr = pMSPShell->AddPage(pPgAttr);
    hr = pMSPShell->AddPage(pPgProfile);
    hr = pMSPShell->AddPage(pPgSources);
    hr = pMSPShell->AddPage(pPgDesc);

// Refresh the MSPropShell ActiveX control.

    hr = pMSPShell->Refresh();

See Also

  • IMSPropShell::AddPage
  • IMSPropShell Interface
  • IMSPropShell::put_AutoRefresh


IMSPropShell::ShowPageHelp

The ShowPageHelp method displays the Help for a specific page.

Syntax

HRESULT ShowPageHelp(
  long  Index
);

Parameters

Index

[in] long containing the index of the property page.

Return Values

If the method succeeds, it returns S_OK. If it fails, it returns E_FAIL.

Example Code

// Include libraries.

#include <windows.h>
#include <atlbase.h>
#include "wmencode.h"
#include "mspropshell.h"

// Declare variables.

    HRESULT hr;
    IWMEncoder* pEncoder;
    IMSPropShell* pMSPShell;
    IUnknown *pPgSources;
    IUnknown *pPgDesc;
    IUnknown *pPgAttr;
    IUnknown *pPgProfile;
    IUnknown *pPgOutput;
    long lPageIndex;
    VARIANT_BOOL bHelp;

// Initialize the COM library and retrieve a pointer
// to an IWMEncoder interface.

    hr = CoInitialize(NULL);
    hr = CoCreateInstance(CLSID_WMEncoder,
                          NULL,
                          CLSCTX_INPROC_SERVER,
                          IID_IWMEncoder,
                          (void**) &pEncoder);

// Create the property page shell.

    hr = CoCreateInstance(CLSID_MSPropShell,
                          NULL,
                          CLSCTX_INPROC_SERVER,
                          IID_IMSPropShell,
                          (void**) &pMSPShell);

// Create the Sources property page.

    hr = CoCreateInstance(CLSID_WMEncSourcesPage,
                          NULL,
                          CLSCTX_INPROC_SERVER,
                          IID_IUnknown,
                          (void**) &pPgSources);

// Create the Description property page.

    hr = CoCreateInstance(CLSID_WMEncDisplayInfoPage,
                          NULL,
                          CLSCTX_INPROC_SERVER,
                          IID_IUnknown,
                          (void**) &pPgDesc);

// Create the Attributes property page.

    hr = CoCreateInstance(CLSID_WMEncAttributesPage,
                          NULL,
                          CLSCTX_INPROC_SERVER,
                          IID_IUnknown,
                          (void**) &pPgAttr);

// Create the Profile property page.

    hr = CoCreateInstance(CLSID_WMEncProfilePage,
                          NULL,
                          CLSCTX_INPROC_SERVER,
                          IID_IUnknown,
                          (void**) &pPgProfile);

// Create the Output property page.

    hr = CoCreateInstance(CLSID_WMEncOutputPage,
                          NULL,
                          CLSCTX_INPROC_SERVER,
                          IID_IUnknown,
                          (void**) &pPgOutput);

// Add Windows Media Encoder to the property page shell.
// You must add the encoder before adding the property pages.

    hr = pMSPShell->AddObject((IUnknown*) pEncoder);

// Add the property pages to the property page shell.

    hr = pMSPShell->AddPage(pPgSources);
    hr = pMSPShell->AddPage(pPgDesc);
    hr = pMSPShell->AddPage(pPgAttr);
    hr = pMSPShell->AddPage(pPgProfile);
    hr = pMSPShell->AddPage(pPgOutput);

// Retrieve the index of the active property page.

    hr = pMSPShell->get_PageIndex(&lPageIndex);

// Determine whether the active page has Help.

    hr = pMSPShell->get_PageHasHelp(lPageIndex, &bHelp);

// Display the Help for that page.

    if (bHelp == VARIANT_TRUE)
    {
        hr = pMSPShell->ShowPageHelp (lPageIndex);
    }

See Also

  • IMSPropShell Interface


Property Page Objects (Visual Basic)

You can use the MSPropShell ActiveX control to host property pages that enable end users to configure and monitor the encoder engine. By using the reusable property page objects that are included in the Windows Media Encoder SDK, the end user can specify multimedia sources, describe the encoded content, add attributes, designate a broadcast port number, choose a file for archiving, select a profile, monitor encoding statistics, and monitor the performance of the network connection. To view individual property pages, see the Configuring the Windows Media Encoder Application section of this document. You can use the following objects to manage the MSPropshell control.

Object | Description
_IMSPropShellEvents Object | Not implemented in this release.
MSPropShell Object | Manages property page objects.

See Also

  • Configuring the Windows Media Encoder Application
  • Programming Reference
  • The MSPropShell ActiveX Control


_IMSPropShellEvents Object

The _IMSPropShellEvents object is a callback object to which the MSPropShell ActiveX control sends event notifications. Use this object to determine if the end user has switched or is switching from one property page to another. The events are fired by the MSPropShell object. The _IMSPropShellEvents object exposes the following methods.

Note The _IMSPropShellEvents object is not implemented in this release.

Method | Description
OnPageChanged | Specifies that the user has switched from one property page to another.
OnPageChanging | Specifies that the user has clicked another property page but that the new page has not yet become active.

See Also

  • [Visual C++] _IMSPropShellEvents Interface
  • MSPropShell Object
  • Property Page Objects (Visual Basic)


_IMSPropShellEvents.OnPageChanged

The OnPageChanged method is not implemented in this release.

Syntax

_IMSPropShellEvents.OnPageChanged Index

Parameters

Index

[in] Long sent by the MSPropShell control, containing the index of the page the user has switched to.

Return Values

This method does not return a value.

See Also

  • _IMSPropShellEvents Object
  • _IMSPropShellEvents.OnPageChanging


_IMSPropShellEvents.OnPageChanging

The OnPageChanging method is not implemented in this release.

Syntax

_IMSPropShellEvents.OnPageChanging Index, bAllow

Parameters

Index

[in] Long sent by the MSPropShell control containing the index of the page that the user has requested.

bAllow

[in, out] On input, a VARIANT_BOOL sent by MSPropShell to indicate whether the new page can be selected. On output, this parameter specifies whether the selected property page can be made active. This parameter defaults to TRUE.

Return Values

This method does not return a value.

See Also

  • _IMSPropShellEvents Object
  • _IMSPropShellEvents.OnPageChanged


MSPropShell Object

The MSPropShell object controls the property pages hosted by the MSPropShell ActiveX control. It can be used to add a property page object to the control and link the property page to Windows Media Encoder. The MSPropShell object exposes the following properties and methods.

Property | Description
ApplyIndex | Retrieves the index number of the property page being applied to the WMEncoder object.
AutoRefresh | Specifies and retrieves a Boolean value indicating whether the property pages are automatically refreshed when either a new property page or a WMEncoder object is attached to them.
InitNew | Specifies and retrieves a Boolean value indicating whether the property pages hosted by the MSPropShell control must be reinitialized.
LocaleID | Specifies and retrieves the national language used in the property pages.
PageCount | Retrieves the number of property pages in the MSPropShell control.
PageHasHelp | Retrieves a Boolean value indicating whether Help is defined for a specific page.
PageIndex | Specifies and retrieves the index of the currently active property page.
PageTitle | Retrieves the title of a specific property page.
Style | Specifies and retrieves an enumeration member indicating whether the property pages are displayed with tabs.
TabWidth | Specifies and retrieves the width of the property page tabs.

Method | Description
AddObject | Adds a Windows Media Encoder object to the MSPropShell control.
AddPage | Adds a property page object to the MSPropShell control.
Apply | Sends property page changes to Windows Media Encoder.
GetPage | Retrieves a specific property page.
Refresh | Recreates all of the property pages in the MSPropShell control.
RemoveAllObjects | Removes all WMEncoder objects from the MSPropShell control.
RemoveAllPages | Removes all of the property pages from the MSPropShell control.
ShowPageHelp | Displays Help for a specific property page.

See Also

  • [Visual C++] IMSPropShell Interface
  • _IMSPropShellEvents Object
  • Property Page Objects (Visual Basic)


MSPropShell.ApplyIndex

The ApplyIndex property retrieves the index number of the property page being applied to the WMEncoder object.

Syntax

Long = MSPropShell.ApplyIndex

Parameters

This property takes no parameters.

Return Values

When getting the value, this property returns a Long containing the index

Remarks

The ApplyIndex property was designed for Microsoft internal use only.

See Also

  • MSPropShell.Apply
  • MSPropShell Object


MSPropShell.AutoRefresh

The AutoRefresh property specifies and retrieves a Boolean value indicating whether the property pages are automatically refreshed when either a new property page or a WMEncoder object is attached to them.

Syntax

MSPropShell.AutoRefresh = VARIANT_BOOL
VARIANT_BOOL = MSPropShell.AutoRefresh

Parameters

This property takes no parameters.

Return Values

When getting the value, this property returns a VARIANT_BOOL indicating whether the property pages will be automatically refreshed.

Remarks

By default, this property returns True. You can attach WMEncoder objects to property pages by calling either the MSPropShell.Refresh method or by setting the AutoRefresh property to True and calling MSPropShell.AddObject. You can attach new property pages to existing property pages by calling either the Refresh method or by setting the AutoRefresh property to True and calling MSPropShell.AddPage.

Example Code

' Create a WMEncoder object.
Dim Encoder As WMEncoder
Set Encoder = New WMEncoder

' Create the encoder property pages.
Dim PpgSources As New WMEncSourcesPage
Dim PpgDesc As New WMEncDisplayInfoPage
Dim PpgAttr As New WMEncAttributesPage
Dim PpgProf As New WMEncProfilePage
Dim PpgOut As New WMEncOutputPage

' Add Windows Media Encoder to the property page shell.
' You must add the encoder before adding the property pages.
PropPageShell.AddObject Encoder

' Add the property pages to the property page shell. To create an
' MSPropShell ActiveX control, on the Project menu, click Components,
' and then in the Components dialog box, select Microsoft PropShell
' Control 1.0. In the following example, the ActiveX control is
' named PropPageShell.
PropPageShell.AddPage PpgSources
PropPageShell.AddPage PpgDesc
PropPageShell.AddPage PpgAttr
PropPageShell.AddPage PpgProf
PropPageShell.AddPage PpgOut

' Reorder the pages. Call RemoveAllPages to remove all
' property pages from the MSPropShell control.
PropPageShell.RemoveAllPages

' Set the AutoRefresh property to False so that the
' MSPropShell control is not refreshed when each new page is added.
PropPageShell.AutoRefresh = False

' Add the property pages in the desired order.
PropPageShell.AddPage PpgOut
PropPageShell.AddPage PpgAttr
PropPageShell.AddPage PpgProf
PropPageShell.AddPage PpgSources
PropPageShell.AddPage PpgDesc

' Refresh the MSPropShell ActiveX control.
PropPageShell.Refresh

See Also

  • MSPropShell.AddObject
  • MSPropShell.AddPage
  • MSPropShell Object
  • WMEncoder Object


MSPropShell.InitNew

The InitNew property specifies and retrieves a Boolean value indicating whether the property pages hosted by the MSPropShell control must be reinitialized to an empty state.

Syntax

MSPropShell.InitNew = VARIANT_BOOL
VARIANT_BOOL = MSPropShell.InitNew

Parameters

This property takes no parameters.

Return Values

When getting the value, this property returns a VARIANT_BOOL indicating whether the property pages must be reinitialized.

Remarks

The InitNew property defaults to False. Property pages usually display the configuration of the WMEncoder object attached to them. However, you can set the InitNew property to True to ignore the current configuration and display empty pages.

Example Code

' Create a WMEncoder object.
Dim Encoder As WMEncoder
Set Encoder = New WMEncoder

' Create the encoder property pages.
Dim PpgSources As New WMEncSourcesPage
Dim PpgDesc As New WMEncDisplayInfoPage
Dim PpgAttr As New WMEncAttributesPage
Dim PpgProfile As New WMEncProfilePage
Dim PpgOutput As New WMEncOutputPage

' Add Windows Media Encoder to the property page shell.
' You must add the encoder before adding the property pages.
PropPageShell.AddObject Encoder

' Add the property pages to the property page shell. To create an
' MSPropShell ActiveX control, on the Project menu, click Components,
' and then in the Components dialog box, select Microsoft PropShell
' Control 1.0. In the following example, the ActiveX control is
 ' named PropPageShell.
PropPageShell.AddPage PpgSources
PropPageShell.AddPage PpgDesc
PropPageShell.AddPage PpgAttr
PropPageShell.AddPage PpgProfile
PropPageShell.AddPage PpgOutput

' When the end user has finished using the property pages to
' configure the encoder engine and has clicked the Apply button,
' apply the configuration programatically.
PropPageShell.Apply

' Reinitialize the property pages to prepare them for a new configuration.
PropPageShell.InitNew = True

See Also

  • MSPropShell Object
  • IWMEncAttributes Object
  • IWMEncBroadcast Object
  • IWMEncDisplayInfo Object
  • IWMEncFile Object
  • IWMEncSourceGroupCollection Object
  • WMEncoder Object


MSPropShell.LocaleID

The LocaleID property sets and retrieves the national language used in the property pages.

Syntax

MSPropShell.LocaleID = Long
Long = MSPropShell.LocaleID

Parameters

This property takes no parameters.

Return Values

When getting the value, this property returns a Long containing the language identifier.

Remarks

For more information about locale IDs, see the Microsoft Developer Network page at the Microsoft Web site. Search for localeID, "Table for Language, Locale Names, and Correponding LCIDs (Three-Letter Abbreviations)", the MAKELANGID macro, or the MAKELCID macro. The following example code demonstrates how to retrieve the locale ID and convert it into a string containing the equivalent hexadecimal value.

Example Code

' Create a WMEncoder object.
Dim Encoder As WMEncoder
Set Encoder = New WMEncoder

' Create the encoder property pages.
Dim PpgSources As New WMEncSourcesPage
Dim PpgDesc As New WMEncDisplayInfoPage
Dim PpgAttr As New WMEncAttributesPage
Dim PpgProf As New WMEncProfilePage
Dim PpgOut As New WMEncOutputPage

' Add Windows Media Encoder to the property page shell.
' You must add the encoder before adding the property pages.
PropPageShell.AddObject Encoder

' Add the property pages to the property page shell. To create an
' MSPropShell ActiveX control, on the Project menu, click Components,
' and then in the Components dialog box, select Microsoft PropShell
' Control 1.0. In the following example, the ActiveX control is
' named PropPageShell
PropPageShell.AddPage PpgSources
PropPageShell.AddPage PpgDesc
PropPageShell.AddPage PpgAttr
PropPageShell.AddPage PpgProf
PropPageShell.AddPage PpgOut

' Retrieve the language locale ID.
Dim lLocID As Long
lLocID = PropPageShell.LocaleID

' Convert the long to a string containing the hexadecimal.
' equivalent.
Dim sHexLocID As String
sHexLocID = Hex(lLocID)

See Also

  • 56MSPropShell Object


MSPropShell.PageCount

The PageCount property retrieves the number of property pages in the MSPropShell control.

Syntax

Long = MSPropShell.PageCount

Parameters

This property takes no parameters.

Return Values

When getting the value, this property returns a Long containing the number of pages.

Remarks

This property is read-only.

Example Code

' Create a WMEncoder object.
Dim Encoder As WMEncoder
Set Encoder = New WMEncoder

' Create the encoder property pages.
Dim PpgSources As New WMEncSourcesPage
Dim PpgDesc As New WMEncDisplayInfoPage
Dim PpgAttr As New WMEncAttributesPage
Dim PpgProf As New WMEncProfilePage
Dim PpgOut As New WMEncOutputPage

' Add Windows Media Encoder to the property page shell.
' You must add the encoder before adding the property pages.
PropPageShell.AddObject Encoder

' Add the property pages to the property page shell. To create an
' MSPropShell ActiveX control, on the Project menu, click Components,
' and then in the Components dialog box, select Microsoft PropShell
' Control 1.0. In the following example, the ActiveX control is named PropPageShell.

PropPageShell.AddPage PpgSources
PropPageShell.AddPage PpgDesc
PropPageShell.AddPage PpgAttr
PropPageShell.AddPage PpgProf
PropPageShell.AddPage PpgOut

' Retrieve the number of pages in the MSPropShell control.

Dim lPageCount As Long
lPageCount = PropPageShell.PageCount

See Also

  • MSPropShell Object


MSPropShell.PageHasHelp

The PageHasHelp property retrieves a Boolean value indicating whether Help is defined for a specific page.

Syntax

VARIANT_BOOL = MSPropShell.PageHasHelp( Index )

Parameters

Index

[in] Long containing the index of a specific property page.

Return Values

When getting the value, this property returns a VARIANT_BOOL indicating whether Help is defined.

Remarks

This property is read-only. You can use the PageHasHelp method to identify when a Help button should be enabled or disabled.

Example Code

' Create a WMEncoder object.
Dim Encoder As WMEncoder
Set Encoder = New WMEncoder

' Create the encoder property pages.
Dim PpgSources As New WMEncSourcesPage
Dim PpgDesc As New WMEncDisplayInfoPage
Dim PpgAttr As New WMEncAttributesPage
Dim PpgProf As New WMEncProfilePage
Dim PpgOut As New WMEncOutputPage

' Add Windows Media Encoder to the property page shell.
' You must add the encoder before adding the property pages.
PropPageShell.AddObject Encoder

' Add the property pages to the property page shell. To create an
' MSPropShell ActiveX control, on the Project menu, click Components,
' and then in the Components dialog box, select Microsoft PropShell
' Control 1.0. In the following example, the ActiveX control is named PropPageShell.
PropPageShell.AddPage PpgSources
PropPageShell.AddPage PpgDesc
PropPageShell.AddPage PpgAttr
PropPageShell.AddPage PpgProf
PropPageShell.AddPage PpgOut

' Retrieve the index of the active property page.
Dim lPageIndex As Long
lPageIndex = PropPageShell.PageIndex

' Determine whether the active page has Help.
Dim bHelp As Boolean
bHelp = PropPageShell.PageHasHelp(lPageIndex)

' Display the Help for that page.
If bHelp = True Then
     PropPageShell.ShowPageHelp (lPageIndex)
End If

See Also

  • MSPropShell Object


MSPropShell.PageIndex

The PageIndex property specifies and retrieves the index of the currently active property page.

Syntax

MSPropShell.PageIndex = Long
Long = MSPropShell.PageIndex

Parameters

This property takes no parameters.

Return Values

When getting the value, this property returns a Long containing the index of the active page.

Remarks

Use this property to either return the index of the active page or to make a specific page active.

Example Code

' Create a WMEncoder object.
Dim Encoder As WMEncoder
Set Encoder = New WMEncoder

' Create the encoder property pages.
Dim PpgSources As New WMEncSourcesPage
Dim PpgDesc As New WMEncDisplayInfoPage
Dim PpgAttr As New WMEncAttributesPage
Dim PpgProf As New WMEncProfilePage
Dim PpgOut As New WMEncOutputPage

' Add Windows Media Encoder to the property page shell.
' You must add the encoder before adding the property pages.
PropPageShell.AddObject Encoder

' Add the property pages to the property page shell. To create an
' MSPropShell ActiveX control, on the Project menu, click Components,
' and then in the Components dialog box, select Microsoft PropShell
' Control 1.0. In the following example, the ActiveX control is named PropPageShell.
PropPageShell.AddPage PpgSources
PropPageShell.AddPage PpgDesc
PropPageShell.AddPage PpgAttr
PropPageShell.AddPage PpgProf
PropPageShell.AddPage PpgOut

' Retrieve the index of the active property page.
Dim lPageIndex As Long
lPageIndex = PropPageShell.PageIndex

' Determine whether the active page has Help.
Dim bHelp As Boolean
bHelp = PropPageShell.PageHasHelp(lPageIndex)

' Display the Help for that page.
If bHelp = True Then
     PropPageShell.ShowPageHelp (lPageIndex)
End If

See Also

  • MSPropShell Object


MSPropShell.PageTitle

The PageTitle property retrieves the title of a specific property page.

Syntax

BSTR = MSPropShell.PageTitle( Index )

Parameters

Index

[in] Long containing the index of the property page.

Return Values

When getting the value, this property returns a BSTR containing the title.

Remarks

This property is read-only. The title is the string displayed on the property page tab.

Example Code

' Create a WMEncoder object.
Dim Encoder As WMEncoder
Set Encoder = New WMEncoder

' Create the encoder property pages.
Dim PpgSources As New WMEncSourcesPage
Dim PpgDesc As New WMEncDisplayInfoPage
Dim PpgAttr As New WMEncAttributesPage
Dim PpgProf As New WMEncProfilePage
Dim PpgOut As New WMEncOutputPage

' Add Windows Media Encoder to the property page shell.
' You must add the encoder before adding the property pages.
PropPageShell.AddObject Encoder

' Add the property pages to the property page shell. To create an
' MSPropShell ActiveX control, on the Project menu, click Components,
' and then in the Components dialog box, select Microsoft PropShell
' Control 1.0. In the following example, the ActiveX control is named PropPageShell.
PropPageShell.AddPage PpgSources
PropPageShell.AddPage PpgDesc
PropPageShell.AddPage PpgAttr
PropPageShell.AddPage PpgProf
PropPageShell.AddPage PpgOut

' Retrieve the title of the third property page.
' The index is zero-based.

Dim lIndex As Long
Dim sTitle As String

lIndex = 2
sTitle = PropPageShell.PageTitle(lIndex)

See Also

  • MSPropShell Object


MSPropShell.Style

The Style property specifies and retrieves an enumeration member indicating whether the property pages are displayed with tabs.

Syntax

MSPropShell.Style = PSSTYLE
PSSTYLE = MSPropShell.Style

Parameters

This property takes no parameters.

Return Values

When getting the value, this property returns a member of the PSSTYLE enumeration type indicating whether the property pages are displayed with tabs. This must be one of the following values.

Value | Number | Description
pssNoTabs | 0 | The property pages are displayed without tabs. This is preferred for displaying pages in a wizard.
pssTabsTop | 1 | Tabs are displayed on the top edge of the property pages.
pssTabsBottom | 2 | Tabs are displayed on the bottom edge of the property pages.

Remarks

Pages can be displayed either with or without tabs. The former is preferred for a standard user interface, and the latter for a wizard. If tabs are omitted, you must provide a way of moving through the pages. For instance, Back and Next buttons can be implemented.

Example Code

' Create a WMEncoder object.
Dim Encoder As WMEncoder
Set Encoder = New WMEncoder

' Create the encoder property pages.
Dim PpgSources As New WMEncSourcesPage
Dim PpgDesc As New WMEncDisplayInfoPage
Dim PpgAttr As New WMEncAttributesPage
Dim PpgProf As New WMEncProfilePage
Dim PpgOut As New WMEncOutputPage

' Add Windows Media Encoder to the property page shell.
' You must add the encoder before adding the property pages.
PropPageShell.AddObject Encoder

' Add the property pages to the property page shell. To create an
' MSPropShell ActiveX control, on the Project menu, click Components,
' and then in the Components dialog box, select Microsoft PropShell
' Control 1.0. In the following example, the ActiveX control is named PropPageShell.
PropPageShell.AddPage PpgSources
PropPageShell.AddPage PpgDesc
PropPageShell.AddPage PpgAttr
PropPageShell.AddPage PpgProf
PropPageShell.AddPage PpgOut

' Determine whether the property pages are displayed
' with tabs, and whether the tabs are on the top or the
' bottom of each property page.
Dim enumPSStyle As PSSTYLE
enumPSStyle = PropPageShell.Style

' Determine the width of the property page tabs.
Dim iTabWidth As Integer
If enumPSStyle <> pssNoTabs Then
    iTabWidth = PropPageShell.TabWidth
End If

See Also

  • MSPropShell Object


MSPropShell.TabWidth

The TabWidth property specifies and retrieves the width of the property page tabs.

Syntax

MSPropShell.TabWidth = Integer
Integer = MSPropShell.TabWidth

Parameters

This property takes no parameters.

Return Values

When getting the value, this property returns an Integer containing the width of the tabs, in pixels.

Remarks

If the TabWidth property returns zero, the width of each tab equals the length of the embedded text. If the TabWidth property returns a positive number, the width of each tab, in pixels, is equal to the absolute value of that number. If the TabWidth property returns a negative number, the width of each tab is equal to the width of the longest embedded string in all of the tabs plus the absolute value of the number. Check the MSPropShell.Style property to determine whether property pages are displayed with tabs.

Example Code

' Create a WMEncoder object.
Dim Encoder As WMEncoder
Set Encoder = New WMEncoder

' Create the encoder property pages.
Dim PpgSources As New WMEncSourcesPage
Dim PpgDesc As New WMEncDisplayInfoPage
Dim PpgAttr As New WMEncAttributesPage
Dim PpgProf As New WMEncProfilePage
Dim PpgOut As New WMEncOutputPage

' Add Windows Media Encoder to the property page shell.
' You must add the encoder before adding the property pages.
PropPageShell.AddObject Encoder

' Add the property pages to the property page shell. To create an
' MSPropShell ActiveX control, on the Project menu, click Components,
' and then in the Components dialog box, select Microsoft PropShell
' Control 1.0. In the following example, the ActiveX control is named
' PropPageShell.
PropPageShell.AddPage PpgSources
PropPageShell.AddPage PpgDesc
PropPageShell.AddPage PpgAttr
PropPageShell.AddPage PpgProf
PropPageShell.AddPage PpgOut

' Determine whether the property pages are displayed
' with tabs, and whether the tabs are on the top or the
' bottom of each property page.
Dim enumPSStyle As PSSTYLE
enumPSStyle = PropPageShell.Style

' Determine the width of the property page tabs.
Dim iTabWidth As Integer
If enumPSStyle <> pssNoTabs Then
    iTabWidth = PropPageShell.TabWidth
End If

' Set the width of each tab equal to the length, in
' pixels, of the longest embedded string plus the
' absolute value of the specified integer.
If iTabWidth = 0 Then
    iTabWidth = -5
    PropPageShell.TabWidth = iTabWidth
End If

See Also

  • MSPropShell Object
  • MSPropShell.Style


MSPropShell.AddObject

The AddObject method adds a Windows Media Encoder object to the MSPropShell control.

Syntax

MSPropShell.AddObject WMEncoder

Parameters

pUnknown

[in] Windows Media Encoder being added.

Return Values

This method does not return a value.

Remarks

You must call the AddObject method before calling the MSPropShell.AddPage method. If the MSPropShell.AutoRefresh property is True, the Windows Media Encoder is automatically linked to property pages as they are added.

Example Code

' Create a WMEncoder object.
Dim Encoder As WMEncoder
Set Encoder = New WMEncoder

' Create the encoder property pages.
Dim PpgSources As New WMEncSourcesPage
Dim PpgDesc As New WMEncDisplayInfoPage
Dim PpgAttr As New WMEncAttributesPage
Dim PpgProf As New WMEncProfilePage
Dim PpgOut As New WMEncOutputPage

' Add Windows Media Encoder to the property page shell.
' You must add the encoder before adding the property pages.
PropPageShell.AddObject Encoder

' Add the property pages to the property page shell. To create an
' MSPropShell ActiveX control, on the Project menu, click Components,
' and then in the Components dialog box, select Microsoft PropShell
' Control 1.0. In the following example, the ActiveX control is named
' PropPageShell.
PropPageShell.AddPage PpgSources
PropPageShell.AddPage PpgDesc
PropPageShell.AddPage PpgAttr
PropPageShell.AddPage PpgProf
PropPageShell.AddPage PpgOut

See Also

  • MSPropShell.AddPage
  • MSPropShell.AutoRefresh
  • MSPropShell Object


MSPropShell.AddPage

The AddPage method adds a property page object to the MSPropShell control.

Syntax

MSPropShell.AddPage WMEncPage

Parameters

pUnknown

[in] Property page being added.

Return Values

This method does not return a value.

Remarks

You must call the MSPropShell.AddObject method before the AddPage method. Pages appear on the screen in the order in which they are added. To move a page to a new position, you must remove all of the existing pages with the MSPropShell.RemoveAllPages method and reorder the pages by calling AddPage multiple times in the correct sequence.

Example Code

' Create a WMEncoder object.
Dim Encoder As WMEncoder
Set Encoder = New WMEncoder

' Create the encoder property pages.
Dim PpgSources As New WMEncSourcesPage
Dim PpgDesc As New WMEncDisplayInfoPage
Dim PpgAttr As New WMEncAttributesPage
Dim PpgProf As New WMEncProfilePage
Dim PpgOut As New WMEncOutputPage

' Add Windows Media Encoder to the property page shell.
' You must add the encoder before adding the property pages.
PropPageShell.AddObject Encoder

' Add the property pages to the property page shell. To create an
' MSPropShell ActiveX control, on the Project menu, click Components,
' and then in the Components dialog box, select Microsoft PropShell
' Control 1.0. In the following example, the ActiveX control is named
' PropPageShell.
PropPageShell.AddPage PpgSources
PropPageShell.AddPage PpgDesc
PropPageShell.AddPage PpgAttr
PropPageShell.AddPage PpgProf
PropPageShell.AddPage PpgOut

See Also

  • MSPropShell.AddObject
  • MSPropShell.GetPage
  • MSPropShell Object
  • MSPropShell.RemoveAllPages


MSPropShell.Apply

The Apply method sends property page changes to Windows Media Encoder.

Syntax

MSPropShell.Apply

Parameters

This method takes no parameters.

Return Values

This method does not return a value.

Remarks

Call the Apply method whenever the end user clicks the Apply button. The pages are applied to the encoder engine sequentially, starting with the first page.

Example Code

' Create a WMEncoder object.
Dim Encoder As WMEncoder
Set Encoder = New WMEncoder

' Create the encoder property pages.
Dim PpgSources As New WMEncSourcesPage
Dim PpgDesc As New WMEncDisplayInfoPage
Dim PpgAttr As New WMEncAttributesPage
Dim PpgProfile As New WMEncProfilePage
Dim PpgOutput As New WMEncOutputPage

' Add Windows Media Encoder to the property page shell.
' You must add the encoder before adding the property pages.
PropPageShell.AddObject Encoder

' Add the property pages to the property page shell. To create an
' MSPropShell ActiveX control, on the Project menu, click Components,
' and then in the Components dialog box, select Microsoft PropShell
' Control 1.0. In the following example, the ActiveX control is named
' PropPageShell.
PropPageShell.AddPage PpgSources
PropPageShell.AddPage PpgDesc
PropPageShell.AddPage PpgAttr
PropPageShell.AddPage PpgProfile
PropPageShell.AddPage PpgOutput

' When the end user has finished using the property pages to
' configure the encoder engine and has clicked the Apply button,
' apply the configuration programatically.
PropPageShell.Apply

' Reinitialize the property pages to prepare them for
' a new configuration.
PropPageShell.InitNew = True

See Also

  • MSPropShell Object


MSPropShell.GetPage

The GetPage method retrieves a specific property page.

Syntax

LPUNKNOWN = MSPropShell.GetPage( Index )

Parameters

Index

[in] Long containing the index of the property page.

Return Values

This method returns the property page specified by Index.

Remarks

You can use the GetPage method to retrieve a pointer to the IUnknown interface of a property page. This enables you to enumerate the property pages and communicate between them.

See Also

  • MSPropShell.AddPage
  • MSPropShell Object


MSPropShell.Refresh

The Refresh method recreates all of the property pages in the MSPropShell control.

Syntax

MSPropShell.Refresh

Parameters

This method takes no parameters.

Return Values

This method does not return a value.

Remarks

The Refresh method destroys all of the property pages and recreates them. If you add a new WMEncoder object, call Refresh to rebuild the property pages. Alternatively, set the MSPropShell.AutoRefresh property to True to control this automatically.

Example Code

' Create a WMEncoder object.
Dim Encoder As WMEncoder
Set Encoder = New WMEncoder

' Create the encoder property pages.
Dim PpgSources As New WMEncSourcesPage
Dim PpgDesc As New WMEncDisplayInfoPage
Dim PpgAttr As New WMEncAttributesPage
Dim PpgProfile As New WMEncProfilePage
Dim PpgOutput As New WMEncOutputPage

' Add Windows Media Encoder to the property page shell.
' You must add the encoder before adding the property pages.
PropPageShell.AddObject Encoder

' Add the Sources property page to the property page shell. To create an
' MSPropShell ActiveX control, on the Project menu, click Components,
' and then in the Components dialog box, select Microsoft PropShell
' Control 1.0. In the following example, the ActiveX control is named
' PropPageShell.
PropPageShell.AddPage PpgSources

' Set the AutoRefresh property to False.
PropPageShell.AutoRefresh = False

' Add the other property pages to the MSPropShell ActiveX
' control.
PropPageShell.AddPage PpgProfile
PropPageShell.AddPage PpgOutput

' Refresh the MSPropShell ActiveX control.
PropPageShell.Refresh

See Also

  • MSPropShell.AutoRefresh
  • MSPropShell Object


MSPropShell.RemoveAllObjects

The RemoveAllObjects method removes all WMEncoder objects from the MSPropShell control.

Syntax

MSPropShell.RemoveAllObjects

Parameters

This method takes no parameters.

Return Values

This method does not return a value.

Remarks

To delete a single WMEncoder object, you must remove all instances and use MSPropShell.AddObject to add back only those you want to retain. Before calling AddObject, set MSPropShell.AutoRefresh to FALSE and afterward, if you want, reset it to TRUE.

See Also

  • MSPropShell.AddObject
  • MSPropShell.AutoRefresh
  • MSPropShell Object


MSPropShell.RemoveAllPages

The RemoveAllPages method removes all of the property pages from the MSPropShell control.

Syntax

MSPropShell.RemoveAllPages

Parameters

This method takes no parameters.

Return Values

This method does not return a value.

Remarks

Use this method to delete or reorder property pages. When all of the pages have been deleted, reorder them by calling MSPropShell.AddPage multiple times in the correct sequence. To avoid automatically refreshing after every page is added, set MSPropShell.AutoRefresh to FALSE.

Example Code

' Create a WMEncoder object.
Dim Encoder As WMEncoder
Set Encoder = New WMEncoder

' Create the encoder property pages.
Dim PpgSources As New WMEncSourcesPage
Dim PpgDesc As New WMEncDisplayInfoPage
Dim PpgAttr As New WMEncAttributesPage
Dim PpgProf As New WMEncProfilePage
Dim PpgOut As New WMEncOutputPage

' Add Windows Media Encoder to the property page shell.
' You must add the encoder before adding the property pages.
PropPageShell.AddObject Encoder

' Add the property pages to the property page shell. To create an
' MSPropShell ActiveX control, on the Project menu, click Components,
' and then in the Components dialog box, select Microsoft PropShell
' Control 1.0. In the following example, the ActiveX control is named
' PropPageShell.
PropPageShell.AddPage PpgSources
PropPageShell.AddPage PpgDesc
PropPageShell.AddPage PpgAttr
PropPageShell.AddPage PpgProf
PropPageShell.AddPage PpgOut

' Reorder the pages. Call RemoveAllPages to remove all
' property pages from the MSPropShell control.
PropPageShell.RemoveAllPages

' Set the AutoRefresh property to False so that the
' MSPropShell control is not refreshed when each new page is added.
PropPageShell.AutoRefresh = False

' Add the property pages in the desired order.
PropPageShell.AddPage PpgOut
PropPageShell.AddPage PpgAttr
PropPageShell.AddPage PpgProf
PropPageShell.AddPage PpgSources
PropPageShell.AddPage PpgDesc

' Refresh the MSPropShell ActiveX control.
PropPageShell.Refresh

See Also

  • MSPropShell.AddPage
  • MSPropShell.AutoRefresh
  • MSPropShell Object


MSPropShell.ShowPageHelp

The ShowPageHelp method displays Help for a specific page.

Syntax

MSPropShell.ShowPageHelp Index

Parameters

Index

[in] Long containing the index of the property page.

Return Values

This method does not return a value.

Example Code

' Create a WMEncoder object.
Dim Encoder As WMEncoder
Set Encoder = New WMEncoder

' Create the encoder property pages.
Dim PpgSources As New WMEncSourcesPage
Dim PpgDesc As New WMEncDisplayInfoPage
Dim PpgAttr As New WMEncAttributesPage
Dim PpgProf As New WMEncProfilePage
Dim PpgOut As New WMEncOutputPage

' Add Windows Media Encoder to the property page shell.
' You must add the encoder before adding the property pages.
PropPageShell.AddObject Encoder

' Add the property pages to the property page shell. To create an
' MSPropShell ActiveX control, on the Project menu, click Components,
' and then in the Components dialog box, select Microsoft PropShell
' Control 1.0. In the following example, the ActiveX control is named
' PropPageShell.
PropPageShell.AddPage PpgSources
PropPageShell.AddPage PpgDesc
PropPageShell.AddPage PpgAttr
PropPageShell.AddPage PpgProf
PropPageShell.AddPage PpgOut

' Retrieve the index of the active property page.
Dim lPageIndex As Long
lPageIndex = PropPageShell.PageIndex

' Determine whether the active page has Help.
Dim bHelp As Boolean
bHelp = PropPageShell.PageHasHelp(lPageIndex)

' Display the Help for that page.
If bHelp = True Then
     PropPageShell.ShowPageHelp (lPageIndex)
End If

See Also

  • MSPropShell Object


Remote Administration Interfaces (C++)

You can use the following interfaces to develop applications that enable an administrator to control multiple instances of Windows Media Encoder running on remote computers. Windows Media Encoder must be installed on the remote computer, and you must use the DCOMCnfg utility to set the access, launch, and configuration permissions for both Windows Media Encoder and Windows Media Encoder Agent. To create WMEncoderApp objects, the WMEncoderAgent object must be running on the remote computer. You can start the WMEncoderAgent object either manually or programmatically.

Interface | Description
IWMEncAgentLocator Interface | Creates a WMEncoderAgent object on a remote computer to facilitate a remote connection for developers using scripting languages.
IWMEncoderAgent Interface | Enumerates running encoder engines and creates WMEncoderApp objects.
IWMEncoderNamesCollection Interface | Contains a collection of string names that identify running instances of Windows Media Encoder.

See Also

  • [Visual Basic] Remote Administration Objects (Visual Basic)
  • Programming Reference


IWMEncAgentLocator Interface

The IWMEncAgentLocator interface creates a WMEncoderAgent object on a remote computer. If you are using a scripting language to administer Windows Media Encoder over a network, you must use IWMEncAgentLocator. Scripting languages cannot create objects on remote computers.

In addition to the methods inherited from IDispatch, the IWMEncAgentLocator interface exposes the following method.

Method | Description
GetAgent | Creates a WMEncoderAgent object on a remote computer.

See Also

  • [Visual Basic] WMEncAgentLocator Object
  • Remote Administration Interfaces (C++)
  • IWMEncoderAgent Interface


IWMEncAgentLocator::GetAgent

The GetAgent method creates a WMEncoderAgent object on a remote computer.

Syntax

HRESULT GetAgent(
  BSTR  bstrMachineName,
  IDispatch**  ppDisp
);

Parameters

bstrMachineName

[in] BSTR containing the name of the remote computer.

ppDisp

[out] Pointer to an IDispatch pointer to a WMEncoderAgent object.

Return Values

If the method succeeds, it returns S_OK. If it fails, it returns E_FAIL.

Remarks

The name that you use for the remote computer depends on the network transport used, but universal naming convention (UNC) names such as Remote1, Domain Name System (DNS) names such as Remote1.com, and IP addresses such as 194.222.147.74 are valid.

See Also

  • IWMEncAgentLocator Interface
  • IWMEncoderAgent Interface


IWMEncoderAgent Interface

You can use the IWMEncoderAgent interface to create WMEncoderApp objects on remote computers, and retrieve pointers to the running encoder engines.

The IWMEncoderAgent interface enumerates running instances of Windows Media Encoder and creates encoder engines upon request. Each encoder engine puts a unique string name into an internal table. The IWMEncoderAgent interface retrieves the table and enumerates the running encoder engines, passing the string names to the IWMEncoderNamesCollection interface.

In addition to the methods inherited from IDispatch, the IWMEncoderAgent interface exposes the following methods.

Method | Description
CreateEncoder | Creates a WMEncoderApp object on a remote computer.
get_EncoderNamesCollection | Retrieves a pointer to an IWMEncoderNamesCollection interface that contains the names of the WMEncoder objects running on remote computers.
GetEncoder | Retrieves a pointer to a WMEncoder object running on a remote computer.
Register | Registers Windows Media Encoder. This method is used internally.
UnRegister | Removes Windows Media Encoder from the registry. This method is used internally.

See Also

  • [Visual Basic] IWMEncoderAgent Object
  • IWMEncoderNamesCollection Interface
  • Remote Administration Interfaces (C++)


IWMEncoderAgent::CreateEncoder

The CreateEncoder method creates an instance of Windows Media Encoder.

Syntax

HRESULT CreateEncoder(
  BSTR  bstrEncoderName,
  VARIANT  varEncoderProgId
  IDispatch**  ppDispEncoder
);

Parameters

bstrEncoderName

[in] BSTR containing the name of the new encoder engine. The name that you use for the remote computer depends on the network transport used, but universal naming convention (UNC) names such as Remote1, Domain Name System (DNS) names such as Remote1.com, and IP addresses such as 194.222.147.74 are valid.

varEncoderProgId

[in] VARIANT containing the ProgID of the new encoder engine. This is an optional argument. If you specify VT_ERROR instead of a ProgID, the Windows Media Encoder application is used. ProgIDs are strings in the form company.component[.version].

ppDispEncoder

[out] Pointer to the IDispatch pointer of the WMEncoder object.

Return Values

If the method succeeds, it returns S_OK. If it fails, it returns E_FAIL.

Example Code

#ifndef _WIN32_WINNT
#define _WIN32_WINNT 0x0400
#endif

// Include libraries.

#include <windows.h>
#include <atlbase.h>
#include <objbase.h>
#include "wmencode.h"
#include "localagent.h"

// Declare variables.

    HRESULT hr;
    IWMEncoder* pEncoder = NULL;
    IWMEncoderApp* pEncoderApp = NULL;
    IWMEncoderAgent* pAgent = NULL;
    IDispatch* pDispEncNames = NULL;
    IDispatch* pDispEnc = NULL;
    IDispatch* pDispEncApp = NULL;
    IWMEncoderNamesCollection* pEncNames = NULL;

    long lCount;
    int i;

// Create a COSERVERINFO structure containing information
// about the computer on which to create the IWMEncoderAgent
// object.

    COSERVERINFO cs;
    ZeroMemory(&cs,sizeof(cs));
    cs.pwszName = L"name of remote computer";
    cs.pAuthInfo = NULL;

// Create a MULTI_QI structure to hold an IUnknown pointer
// to a IWMEncoderAgent object.

    MULTI_QI mqi;
    ZeroMemory(&mqi,sizeof(mqi));
    mqi.pIID = &IID_IWMEncoderAgent;
    mqi.pItf = pAgent;
    mqi.hr = 0;

// Initialize the COM library and retrieve a pointer
// to an IWMEncoderAgent interface on the remote computer.

    hr = CoInitialize(NULL);
    hr = CoCreateInstanceEx(CLSID_WMEncoderAgent,
                            NULL,
                            CLSCTX_SERVER,
                            &cs,
                            1,
                            &mqi);

    hr = mqi.pItf->QueryInterface(IID_IWMEncoderAgent,
                                  (void**) &pAgent);

// Create a WMEncoderApp object on the remote computer.

    CComVariant var;
    var = L"WMEnc.WMEncoderApp";
    CComBSTR    bstrEncoderName;
    bstrEncoderName = L"WMEncoder_1";

    // Instead of a ProgID, you can also set the vt member
    // of the Variant structure to VT_ERROR to create a
    // WMEncoderApp object.

    hr = pAgent->CreateEncoder(bstrEncoderName,var,&pDispEncApp);

    // Call QueryInterface() to retrieve an IWMEncoderApp pointer.

    hr = pDispEncApp->QueryInterface(IID_IWMEncoderApp,
                                     (void**) &pEncoderApp);

// Retrieve an IDispatch pointer to an IWMEncoderNamesCollection
// interface.

    hr = pAgent->get_EncoderNamesCollection(&pDispEncNames);

// Call QueryInterface() to retrieve an IWMEncoderNamesCollection
// interface.

    hr = pDispEncNames->QueryInterface(
                           IID_IWMEncoderNamesCollection,
                           (void**) &pEncNames);

// Retrieve the number of WMEncoder objects created on the
// remote computer. For simplicity, this example created only
// one WMEncoder object.

    hr = pEncNames->get_Count(&lCount);

    for (i=0; i<lCount; i++)
    {
        pDispEnc = NULL;
        CComBSTR bstrName;

        // Retrieve the name of each WMEncoder object.
        hr = pEncNames->Item(i, &bstrName);

        // Retrieve the IDispatch pointer to each
        // WMEncoder object.
        hr = pAgent->GetEncoder(bstrName, &pDispEnc);

        // Retrieve each IWMEncoder pointer.
        hr = pDispEnc->QueryInterface(IID_IWMEncoder,
                                          (void**) &pEncoder);

     }

See Also

  • IWMEncoderAgent Interface


IWMEncoderAgent::get_EncoderNamesCollection

The get_EncoderNamesCollection method a pointer to an IWMEncoderNamesCollection interface that contains the names of the WMEncoder objects running on remote computers.

Syntax

HRESULT get_EncoderNamesCollection(
  IDispatch**  pVal
);

Parameters

pVal

[out] Pointer to an IDispatch pointer to the IWMEncoderNamesCollection interface.

Return Values

If the method succeeds, it returns S_OK. If it fails, it returns an HRESULT error code.

Return code | Meaning
E_POINTER | The pointer to the name collection is NULL.

Example Code

#ifndef _WIN32_WINNT
#define _WIN32_WINNT 0x0400
#endif

// Include libraries.

#include <windows.h>
#include <atlbase.h>
#include <objbase.h>
#include "wmencode.h"
#include "localagent.h"

// Declare variables.

    HRESULT hr;
    IWMEncoder* pEncoder = NULL;
    IWMEncoderApp* pEncoderApp = NULL;
    IWMEncoderAgent* pAgent = NULL;
    IDispatch* pDispEncNames = NULL;
    IDispatch* pDispEnc = NULL;
    IDispatch* pDispEncApp = NULL;
    IWMEncoderNamesCollection* pEncNames = NULL;

    long lCount;
    int i;

// Create a COSERVERINFO structure containing information
// about the computer on which to create the IWMEncoderAgent
// object.

    COSERVERINFO cs;
    ZeroMemory(&cs,sizeof(cs));
    cs.pwszName = L"name of remote computer";
    cs.pAuthInfo = NULL;

// Create a MULTI_QI structure to hold an IUnknown pointer
// to a IWMEncoderAgent object.

    MULTI_QI mqi;
    ZeroMemory(&mqi,sizeof(mqi));
    mqi.pIID = &IID_IWMEncoderAgent;
    mqi.pItf = pAgent;
    mqi.hr = 0;

// Initialize the COM library and retrieve a pointer
// to an IWMEncoderAgent interface on the remote computer.

    hr = CoInitialize(NULL);
    hr = CoCreateInstanceEx(CLSID_WMEncoderAgent,
                            NULL,
                            CLSCTX_SERVER,
                            &cs,
                            1,
                            &mqi);

    hr = mqi.pItf->QueryInterface(IID_IWMEncoderAgent,
                                  (void**) &pAgent);

// Create a WMEncoderApp object on the remote computer.

    CComVariant var;
    var = L"WMEnc.WMEncoderApp";
    CComBSTR    bstrEncoderName;
    bstrEncoderName = L"WMEncoder_1";

    // Instead of a ProgID, you can also set the vt member
    // of the Variant structure to VT_ERROR to create a
    // WMEncoderApp object.

    hr = pAgent->CreateEncoder(bstrEncoderName,var,&pDispEncApp);

    // Call QueryInterface() to retrieve an IWMEncoderApp pointer.

    hr = pDispEncApp->QueryInterface(IID_IWMEncoderApp,
                                     (void**) &pEncoderApp);

// Retrieve an IDispatch pointer to an IWMEncoderNamesCollection
// interface.

    hr = pAgent->get_EncoderNamesCollection(&pDispEncNames);

// Call QueryInterface() to retrieve an IWMEncoderNamesCollection
// interface.

    hr = pDispEncNames->QueryInterface(
                           IID_IWMEncoderNamesCollection,
                           (void**) &pEncNames);

// Retrieve the number of WMEncoder objects created on the
// remote computer. For simplicity, this example created only
// one WMEncoder object.

    hr = pEncNames->get_Count(&lCount);

    for (i=0; i<lCount; i++)
    {
        pDispEnc = NULL;
        CComBSTR bstrName;

        // Retrieve the name of each WMEncoder object.
        hr = pEncNames->Item(i, &bstrName);

        // Retrieve the IDispatch pointer to each
        // WMEncoder object.
        hr = pAgent->GetEncoder(bstrName, &pDispEnc);

        // Retrieve each IWMEncoder pointer.
        hr = pDispEnc->QueryInterface(IID_IWMEncoder,
                                          (void**) &pEncoder);

     }

See Also

  • IWMEncoderAgent Interface
  • IWMEncoderNamesCollection Interface


IWMEncoderAgent::GetEncoder

The GetEncoder method retrieves a pointer to an instance of Windows Media Encoder.

Syntax

HRESULT GetEncoder(
  BSTR  name,
  IDispatch**  ppDispEncoder
);

Parameters

name

[in] BSTR containing the name of the encoder engine to be retrieved.

ppDispEncoder

[out] Pointer to an IDispatch pointer to the encoder engine corresponding to name.

Return Values

If the method succeeds, it returns S_OK. If it fails, it returns E_FAIL.

Example Code

#ifndef _WIN32_WINNT
#define _WIN32_WINNT 0x0400
#endif

// Include libraries.

#include <windows.h>
#include <atlbase.h>
#include <objbase.h>
#include "wmencode.h"
#include "localagent.h"

// Declare variables.

    HRESULT hr;
    IWMEncoder* pEncoder = NULL;
    IWMEncoderApp* pEncoderApp = NULL;
    IWMEncoderAgent* pAgent = NULL;
    IDispatch* pDispEncNames = NULL;
    IDispatch* pDispEnc = NULL;
    IDispatch* pDispEncApp = NULL;
    IWMEncoderNamesCollection* pEncNames = NULL;

    long lCount;
    int i;

// Create a COSERVERINFO structure containing information
// about the computer on which to create the IWMEncoderAgent
// object.

    COSERVERINFO cs;
    ZeroMemory(&cs,sizeof(cs));
    cs.pwszName = L"name of remote computer";
    cs.pAuthInfo = NULL;

// Create a MULTI_QI structure to hold an IUnknown pointer
// to a IWMEncoderAgent object.

    MULTI_QI mqi;
    ZeroMemory(&mqi,sizeof(mqi));
    mqi.pIID = &IID_IWMEncoderAgent;
    mqi.pItf = pAgent;
    mqi.hr = 0;

// Initialize the COM library and retrieve a pointer
// to an IWMEncoderAgent interface on the remote computer.

    hr = CoInitialize(NULL);
    hr = CoCreateInstanceEx(CLSID_WMEncoderAgent,
                            NULL,
                            CLSCTX_SERVER,
                            &cs,
                            1,
                            &mqi);

    hr = mqi.pItf->QueryInterface(IID_IWMEncoderAgent,
                                  (void**) &pAgent);

// Create a WMEncoderApp object on the remote computer.

    CComVariant var;
    var = L"WMEnc.WMEncoderApp";
    CComBSTR    bstrEncoderName;
    bstrEncoderName = L"WMEncoder_1";

    // Instead of a ProgID, you can also set the vt member
    // of the Variant structure to VT_ERROR to create a
    // WMEncoderApp object.

    hr = pAgent->CreateEncoder(bstrEncoderName,var,&pDispEncApp);

    // Call QueryInterface() to retrieve an IWMEncoderApp pointer.

    hr = pDispEncApp->QueryInterface(IID_IWMEncoderApp,
                                     (void**) &pEncoderApp);

// Retrieve an IDispatch pointer to an IWMEncoderNamesCollection
// interface.

    hr = pAgent->get_EncoderNamesCollection(&pDispEncNames);

// Call QueryInterface() to retrieve an IWMEncoderNamesCollection
// interface.

    hr = pDispEncNames->QueryInterface(
                           IID_IWMEncoderNamesCollection,
                           (void**) &pEncNames);

// Retrieve the number of WMEncoder objects created on the
// remote computer. For simplicity, this example created only
// one WMEncoder object.

    hr = pEncNames->get_Count(&lCount);

    for (i=0; i<lCount; i++)
    {
        pDispEnc = NULL;
        CComBSTR bstrName;

        // Retrieve the name of each WMEncoder object.
        hr = pEncNames->Item(i, &bstrName);

        // Retrieve the IDispatch pointer to each
        // WMEncoder object.
        hr = pAgent->GetEncoder(bstrName, &pDispEnc);

        // Retrieve each IWMEncoder pointer.
        hr = pDispEnc->QueryInterface(IID_IWMEncoder,
                                          (void**) &pEncoder);

     }

See Also

  • IWMEncoderAgent Interface


IWMEncoderAgent::Register

The Register method registers Windows Media Encoder.

Syntax

HRESULT Register(
  BSTR  bstrName,
  IDispatch**  pDispEncoder,
  DWORD*  pdwCookie
);

Parameters

bstrName

[in] BSTR containing the name of the remote computer.

pDispEncoder

[in] Pointer to an IDispatch pointer to Windows Media Encoder.

pdwCookie

[out] DWORD containing a unique value identifying the registry entry.

Return Values

If the method succeeds, it returns S_OK. If it fails, it returns E_FAIL.

Remarks

The Register method is used internally.

See Also

  • IWMEncoderAgent Interface


IWMEncoderAgent::UnRegister

The UnRegister method removes Windows Media Encoder from the registry.

Syntax

HRESULT UNRegister(
  DWORD  dwCookie
);

Parameters

dwCookie

[in] DWORD containing a unique value identifying the registry entry to remove.

Return Values

If the method succeeds, it returns S_OK. If it fails, it returns E_FAIL.

Remarks

The UnRegister method is used internally.

See Also

  • IWMEncoderAgent Interface


IWMEncoderNamesCollection Interface

The IWMEncoderNamesCollection interface contains a collection of string names of the encoder engines running on remote computers. In addition to the methods inherited from IDispatch, the IWMEncoderNamesCollection interface exposes the following methods.

Method | Description
get_Count | Retrieves the number of names in the collection.
get_length | Retrieves the number of names in the collection. This is the JScript version of the get_Count method.
Item | Retrieves a specific Windows Media Encoder name, by index, from the collection.

See Also

  • [Visual Basic] Remote Administration Objects (Visual Basic)
  • Remote Administration Interfaces (C++)


IWMEncoderNamesCollection::get_Count

The get_Count method retrieves the number of names in the collection.

Syntax

HRESULT get_Count(
  LONG*  plCount
);

Parameters

plCount

[out] Pointer to a LONG containing the number of names.

Return Values

If the method succeeds, it returns S_OK. If it fails, it returns an HRESULT error code.

Return code | Meaning
E_POINTER | The pointer to the name count is NULL.

Example Code

#ifndef _WIN32_WINNT
#define _WIN32_WINNT 0x0400
#endif

// Include libraries.

#include <windows.h>
#include <atlbase.h>
#include <objbase.h>
#include "wmencode.h"
#include "localagent.h"

// Declare variables.

    HRESULT hr;
    IWMEncoder* pEncoder = NULL;
    IWMEncoderApp* pEncoderApp = NULL;
    IWMEncoderAgent* pAgent = NULL;
    IDispatch* pDispEncNames = NULL;
    IDispatch* pDispEnc = NULL;
    IDispatch* pDispEncApp = NULL;
    IWMEncoderNamesCollection* pEncNames = NULL;

    long lCount;
    int i;

// Create a COSERVERINFO structure containing information
// about the computer on which to create the IWMEncoderAgent
// object.

    COSERVERINFO cs;
    ZeroMemory(&cs,sizeof(cs));
    cs.pwszName = L"name of remote computer";
    cs.pAuthInfo = NULL;

// Create a MULTI_QI structure to hold an IUnknown pointer
// to a IWMEncoderAgent object.

    MULTI_QI mqi;
    ZeroMemory(&mqi,sizeof(mqi));
    mqi.pIID = &IID_IWMEncoderAgent;
    mqi.pItf = pAgent;
    mqi.hr = 0;

// Initialize the COM library and retrieve a pointer
// to an IWMEncoderAgent interface on the remote computer.

    hr = CoInitialize(NULL);
    hr = CoCreateInstanceEx(CLSID_WMEncoderAgent,
                            NULL,
                            CLSCTX_SERVER,
                            &cs,
                            1,
                            &mqi);

    hr = mqi.pItf->QueryInterface(IID_IWMEncoderAgent,
                                  (void**) &pAgent);

// Create a WMEncoderApp object on the remote computer.

    CComVariant var;
    var = L"WMEnc.WMEncoderApp";
    CComBSTR    bstrEncoderName;
    bstrEncoderName = L"WMEncoder_1";

    // Instead of a ProgID, you can also set the vt member
    // of the Variant structure to VT_ERROR to create a
    // WMEncoderApp object.

    hr = pAgent->CreateEncoder(bstrEncoderName,var,&pDispEncApp);

    // Call QueryInterface() to retrieve an IWMEncoderApp pointer.

    hr = pDispEncApp->QueryInterface(IID_IWMEncoderApp,
                                     (void**) &pEncoderApp);

// Retrieve an IDispatch pointer to an IWMEncoderNamesCollection
// interface.

    hr = pAgent->get_EncoderNamesCollection(&pDispEncNames);

// Call QueryInterface() to retrieve an IWMEncoderNamesCollection
// interface.

    hr = pDispEncNames->QueryInterface(
                           IID_IWMEncoderNamesCollection,
                           (void**) &pEncNames);

// Retrieve the number of WMEncoder objects created on the
// remote computer. For simplicity, this example created only
// one WMEncoder object.

    hr = pEncNames->get_Count(&lCount);

    for (i=0; i<lCount; i++)
    {
        pDispEnc = NULL;
        CComBSTR bstrName;

        // Retrieve the name of each WMEncoder object.
        hr = pEncNames->Item(i, &bstrName);

        // Retrieve the IDispatch pointer to each
        // WMEncoder object.
        hr = pAgent->GetEncoder(bstrName, &pDispEnc);

        // Retrieve each IWMEncoder pointer.
        hr = pDispEnc->QueryInterface(IID_IWMEncoder,
                                          (void**) &pEncoder);

     }

See Also

  • IWMEncoderNamesCollection Interface


IWMEncoderNamesCollection::get_length

The get_length method retrieves the number of names in the collection.

Syntax

HRESULT get_length(
  LONG*  plCount
);

Parameters

plCount

[out] Pointer to a LONG containing the count.

Return Values

If the method succeeds, it returns S_OK. If it fails, it returns an HRESULT error code.

Return code | Meaning
E_POINTER | The pointer to the name count is NULL.

Remarks

This is the JScript version of the get_Count method. It is provided for JScript developers or developers more accustomed to JScript syntax.

See Also

  • IWMEncoderNamesCollection Interface


IWMEncoderNamesCollection::Item

The Item method retrieves a specific Windows Media Enocder name, by index, from the collection.

Syntax

HRESULT Item(
  LONG  iIndex,
  BSTR*  pbstrValue
);

Parameters

iIndex

[in] LONG containing the index.

pbstrValue

[out] Pointer to a BSTR containing the name of the encoder engine.

Return Values

If the method succeeds, it returns S_OK. If it fails, it returns an HRESULT error code.

Return code | Meaning
E_INVALIDARG | The index is less than zero or greater than the number of names in the collection.
E_POINTER | The pointer to the name is NULL.

Example Code

#ifndef _WIN32_WINNT
#define _WIN32_WINNT 0x0400
#endif

// Include libraries.

#include <windows.h>
#include <atlbase.h>
#include <objbase.h>
#include "wmencode.h"
#include "localagent.h"

// Declare variables.

    HRESULT hr;
    IWMEncoder* pEncoder = NULL;
    IWMEncoderApp* pEncoderApp = NULL;
    IWMEncoderAgent* pAgent = NULL;
    IDispatch* pDispEncNames = NULL;
    IDispatch* pDispEnc = NULL;
    IDispatch* pDispEncApp = NULL;
    IWMEncoderNamesCollection* pEncNames = NULL;

    long lCount;
    int i;

// Create a COSERVERINFO structure containing information
// about the computer on which to create the IWMEncoderAgent
// object.

    COSERVERINFO cs;
    ZeroMemory(&cs,sizeof(cs));
    cs.pwszName = L"name of remote computer";
    cs.pAuthInfo = NULL;

// Create a MULTI_QI structure to hold an IUnknown pointer
// to a IWMEncoderAgent object.

    MULTI_QI mqi;
    ZeroMemory(&mqi,sizeof(mqi));
    mqi.pIID = &IID_IWMEncoderAgent;
    mqi.pItf = pAgent;
    mqi.hr = 0;

// Initialize the COM library and retrieve a pointer
// to an IWMEncoderAgent interface on the remote computer.

    hr = CoInitialize(NULL);
    hr = CoCreateInstanceEx(CLSID_WMEncoderAgent,
                            NULL,
                            CLSCTX_SERVER,
                            &cs,
                            1,
                            &mqi);

    hr = mqi.pItf->QueryInterface(IID_IWMEncoderAgent,
                                  (void**) &pAgent);

// Create a WMEncoderApp object on the remote computer.

    CComVariant var;
    var = L"WMEnc.WMEncoderApp";
    CComBSTR    bstrEncoderName;
    bstrEncoderName = L"WMEncoder_1";

    // Instead of a ProgID, you can also set the vt member
    // of the Variant structure to VT_ERROR to create a
    // WMEncoderApp object.

    hr = pAgent->CreateEncoder(bstrEncoderName,var,&pDispEncApp);

    // Call QueryInterface() to retrieve an IWMEncoderApp pointer.

    hr = pDispEncApp->QueryInterface(IID_IWMEncoderApp,
                                     (void**) &pEncoderApp);

// Retrieve an IDispatch pointer to an IWMEncoderNamesCollection
// interface.

    hr = pAgent->get_EncoderNamesCollection(&pDispEncNames);

// Call QueryInterface() to retrieve an IWMEncoderNamesCollection
// interface.

    hr = pDispEncNames->QueryInterface(
                           IID_IWMEncoderNamesCollection,
                           (void**) &pEncNames);

// Retrieve the number of WMEncoder objects created on the
// remote computer. For simplicity, this example created only
// one WMEncoder object.

    hr = pEncNames->get_Count(&lCount);

    for (i=0; i<lCount; i++)
    {
        pDispEnc = NULL;
        CComBSTR bstrName;

        // Retrieve the name of each WMEncoder object.
        hr = pEncNames->Item(i, &bstrName);

        // Retrieve the IDispatch pointer to each
        // WMEncoder object.
        hr = pAgent->GetEncoder(bstrName, &pDispEnc);

        // Retrieve each IWMEncoder pointer.
        hr = pDispEnc->QueryInterface(IID_IWMEncoder,
                                          (void**) &pEncoder);

     }

See Also

  • IWMEncoderNamesCollection Interface


Remote Administration Objects (Visual Basic)

You can use the following objects to develop applications that enable an administrator to control multiple instances of Windows Media Encoder running on remote computers. Windows Media Encoder must be installed on the remote computer, and you must use the DCOMCnfg utility to set the access, launch, and configuration permissions for both Windows Media Encoder and Windows Media Encoder Agent. To create WMEncoderApp objects, the WMEncoderAgent object must be running on the remote computer. You can start the WMEncoderAgent object either manually or programmatically.

Object | Description
IWMEncoderNamesCollection Object | Contains a collection of string names that identify running instances of Windows Media Encoder.
WMEncoderAgent Object | Enumerates running encoder engines and creates WMEncoderApp objects.
WMEncAgentLocator Object | Creates a WMEncoderAgent object on a remote computer to facilitate a remote connection for developers using scripting languages.

See Also

  • [Visual C++] Remote Administration Interfaces (C++)
  • Programming Reference
  • WMEncoderApp Object


IWMEncoderNamesCollection Object

The IWMEncoderNamesCollection interface contains a collection of string names of the encoder engines running on remote computers.

The IWMEncoderNamesCollection object exposes the following properties and one method

Property | Description
Count | Retrieves the number of names in the collection.
length | Retrieves the number of names in the collection. This is the JScript version of the get_Count method.

Method | Description
Item | Retrieves a specific Windows Media Encoder name, by index, from the collection.

See Also

  • [Visual C++] Remote Administration Interfaces (C++)
  • Remote Administration Objects (Visual Basic)


IWMEncoderNamesCollection.Count

The Count property retrieves the number of names in the collection.

Syntax

LONG = IWMEncoderNamesCollection.Count

Parameters

This property takes no parameters.

Return Values

When getting the value, this property returns a LONG containing the number of names.

Remarks

This property is read-only.

Example Code

' Declare objects and variables.
Dim Encoder As WMEncoder
Dim EncoderApp As WMEncoderApp
Dim EncoderAgent As WMEncoderAgent
Dim EncoderNames As IWMEncoderNamesCollection

Dim lCount As Long
Dim i As Integer
Dim sName As String

' Create a WMEncoderAgent object on a remote computer.
Set EncoderAgent = CreateObject("WMEncAgt.WMEncoderAgent",
                        "computer name")

' Create a WMEncoderApp object on the remote computer.
Set EncoderApp = EncoderAgent.CreateEncoder("WMEnc_1",
                        "WMEnc.WMEncoderApp")

' Retrieve an IWMEncoderNamesCollection object.
Set EncoderNames = EncoderAgent.EncoderNamesCollection

' Retrieve the number of WMEncoder objects that have been
' created on the remote computer.
lCount = EncoderNames.Count

' For simplicity, this example created only one WMEncoder object.
' Retrieve the name.
sName = EncoderNames.Item(0)

' Retrieve the WMEncoder object.
Set Encoder = EncoderAgent.GetEncoder(sName)

See Also

  • IWMEncoderNamesCollection Object


IWMEncoderNamesCollection.length

The length property retrieves the number of names in the collection.

Syntax

LONG = IWMEncoderNamesCollection.length

Parameters

This property takes no parameters.

Return Values

When getting the value, this property returns a LONG containing the count

Remarks

This property is read-only. This is the JScript version of the get_Count method. It is provided for JScript developers or developers more accustomed to JScript syntax.

See Also

  • IWMEncoderNamesCollection Object


IWMEncoderNamesCollection.Item

The Item method retrieves a specific Windows Media Enocder name, by index, from the collection.

Syntax

BSTR = IWMEncoderNamesCollection.Item( iIndex )

Parameters

iIndex

[in] LONG containing the index.

Return Values

This method returns a BSTR containing the name of the encoder engine.

Example Code

' Declare objects and variables.
Dim Encoder As WMEncoder
Dim EncoderApp As WMEncoderApp
Dim EncoderAgent As WMEncoderAgent
Dim EncoderNames As IWMEncoderNamesCollection

Dim lCount As Long
Dim i As Integer
Dim sName As String

' Create a WMEncoderAgent object on a remote computer.
Set EncoderAgent = CreateObject("WMEncAgt.WMEncoderAgent",
                        "computer name")

' Create a WMEncoderApp object on the remote computer.
Set EncoderApp = EncoderAgent.CreateEncoder("WMEnc_1",
                        "WMEnc.WMEncoderApp")

' Retrieve an IWMEncoderNamesCollection object.
Set EncoderNames = EncoderAgent.EncoderNamesCollection

' Retrieve the number of WMEncoder objects that have been
' created on the remote computer.
lCount = EncoderNames.Count

' For simplicity, this example created only one WMEncoder object.
' Retrieve the name.
sName = EncoderNames.Item(0)

' Retrieve the WMEncoder object.
Set Encoder = EncoderAgent.GetEncoder(sName)

See Also

  • IWMEncoderNamesCollection Object


WMEncoderAgent Object

You can use the WMEncoderAgent object to create WMEncoderApp objects on remote computers, and retrieve the running encoder engines.

The WMEncoderAgent object enumerates running instances of Windows Media Encoder and creates encoder engines upon request. Each encoder engine puts a unique string name into an internal table. The WMEncoderAgent object retrieves the table and enumerates the running encoder engines, passing the string names to the IWMEncoderNamesCollection object.

The WMEncoderAgent object exposes the following property and methods.

Property | Description
EncoderNamesCollection | Retrieves an IWMEncoderNamesCollection object that contains the names of the WMEncoder objects running on remote computers.

Methods | Description
CreateEncoder | Creates a WMEncoderApp object on a remote computer.
GetEncoder | Retrieves a WMEncoder object running on a remote computer.
Register | Registers Windows Media Encoder. This method is used internally.
UnRegister | Removes Windows Media Encoder from the registry. This method is used internally.

See Also

  • [Visual C++] IWMEncoderAgent Interface
  • IWMEncoderNamesCollection Object
  • Remote Administration Objects (Visual Basic)


WMEncoderAgent.EncoderNamesCollection

The EncoderNamesCollection property retrieves a collection of Windows Media Encoder names.

Syntax

IWMEncoderNamesCollection = WMEncoderAgent.EncoderNamesCollection

Parameters

This property takes no parameters.

Return Values

When getting the value, this property returns an IWMEncoderNamesCollection object.

Remarks

This property is read-only.

Example Code

' Declare objects and variables.
Dim Encoder As WMEncoder
Dim EncoderApp As WMEncoderApp
Dim EncoderAgent As WMEncoderAgent
Dim EncoderNames As IWMEncoderNamesCollection

Dim lCount As Long
Dim i As Integer
Dim sName As String

' Create a WMEncoderAgent object on a remote computer.
Set EncoderAgent = CreateObject("WMEncAgt.WMEncoderAgent",
                        "computer name")

' Create a WMEncoderApp object on the remote computer.
Set EncoderApp = EncoderAgent.CreateEncoder("WMEnc_1",
                        "WMEnc.WMEncoderApp")

' Retrieve an IWMEncoderNamesCollection object.
Set EncoderNames = EncoderAgent.EncoderNamesCollection

' Retrieve the number of WMEncoder objects that have been
' created on the remote computer.
lCount = EncoderNames.Count

' For simplicity, this example created only one WMEncoder object.
' Retrieve the name.
sName = EncoderNames.Item(0)

' Retrieve the WMEncoder object.
Set Encoder = EncoderAgent.GetEncoder(sName)

See Also

  • IWMEncoderNamesCollection Object
  • WMEncoderAgent Object
  • WMEncoderApp Object


WMEncoderAgent.CreateEncoder

The CreateEncoder method creates an instance of Windows Media Encoder.

Syntax

WMEncoderApp = WMEncoderAgent.CreateEncoder bstrEncoderName, varEncoderProgId

Parameters

bstrEncoderName

[in] BSTR containing the name of the new encoder engine.

varEncoderProgId

[in] VARIANT containing the ProgID of the new encoder engine. This is an optional argument. If you do not specify a ProgID, the ProgID for the Windows Media Encoder application is used. ProgIDs are strings in the form company.component[.version].

Return Values

This method returns a WMEncoderApp object.

Example Code

' Declare objects and variables.
Dim Encoder As WMEncoder
Dim EncoderApp As WMEncoderApp
Dim EncoderAgent As WMEncoderAgent
Dim EncoderNames As IWMEncoderNamesCollection

Dim lCount As Long
Dim i As Integer
Dim sName As String

' Create a WMEncoderAgent object on a remote computer.
Set EncoderAgent = CreateObject("WMEncAgt.WMEncoderAgent",
                        "computer name")

' Create a WMEncoderApp object on the remote computer.
Set EncoderApp = EncoderAgent.CreateEncoder("WMEnc_1",
                        "WMEnc.WMEncoderApp")

' Retrieve an IWMEncoderNamesCollection object.
Set EncoderNames = EncoderAgent.EncoderNamesCollection

' Retrieve the number of WMEncoder objects that have been
' created on the remote computer.
lCount = EncoderNames.Count

' For simplicity, this example created only one WMEncoder object.
' Retrieve the name.
sName = EncoderNames.Item(0)

' Retrieve the WMEncoder object.
Set Encoder = EncoderAgent.GetEncoder(sName)

See Also

  • WMEncoderAgent Object
  • WMEncoderApp Object


WMEncoderAgent.GetEncoder

The GetEncoder method retrieves an instance of Windows Media Encoder.

Syntax

WMEncoder = WMEncoderAgent.GetEncoder( name )

Parameters

name

[in] BSTR containing the name of the encoder engine to be retrieved.

Return Values

This method returns an WMEncoder object corresponding to name.

Example Code

' Declare objects and variables.
Dim Encoder As WMEncoder
Dim EncoderApp As WMEncoderApp
Dim EncoderAgent As WMEncoderAgent
Dim EncoderNames As IWMEncoderNamesCollection

Dim lCount As Long
Dim i As Integer
Dim sName As String

' Create a WMEncoderAgent object on a remote computer.
Set EncoderAgent = CreateObject("WMEncAgt.WMEncoderAgent",
                        "computer name")

' Create a WMEncoderApp object on the remote computer.
Set EncoderApp = EncoderAgent.CreateEncoder("WMEnc_1",
                        "WMEnc.WMEncoderApp")

' Retrieve an IWMEncoderNamesCollection object.
Set EncoderNames = EncoderAgent.EncoderNamesCollection

' Retrieve the number of WMEncoder objects that have been
' created on the remote computer.
lCount = EncoderNames.Count

' For simplicity, this example created only one WMEncoder object.
' Retrieve the name.
sName = EncoderNames.Item(0)

' Retrieve the WMEncoder object.
Set Encoder = EncoderAgent.GetEncoder(sName)

See Also

  • WMEncoder Object
  • WMEncoderAgent Object


WMEncoderAgent.Register

The Register method registers Windows Media Encoder.

Syntax

dwCookie = WMEncoderAgent.Register ( bstrName, DispEncoder )

Parameters

bstrName

[in] BSTR containing the name of the remote computer.

DispEncoder

[in] WMEncoder object.

Return Values

This method returns a DWORD containing a unique value identifying the registry entry.

Remarks

The Register method is used internally.

See Also

  • WMEncoderAgent Object


WMEncoderAgent.UnRegister

The UnRegister method removes Windows Media Encoder from the registry.

Syntax

EncoderAgent.UnRegister dwCookie

Parameters

dwCookie

[in] DWORD containing a unique value identifying the registry entry to remove.

Return Values

This method does not return a value.

Remarks

The UnRegister method is used internally.

See Also

  • WMEncoderAgent Object


WMEncAgentLocator Object

The WMEncAgentLocator object creates a WMEncoderAgent object on a remote computer. If you are using a scripting language to administer Windows Media Encoder over a network, you must use WMEncAgentLocator. Scripting languages cannot create objects on remote computers.

The WMEncAgentLocator object exposes the following method.

Method | Description
GetAgent | Creates a WMEncoderAgent object on a remote computer.

See Also

  • [Visual C++] IWMEncAgentLocator Interface
  • WMEncoderAgent Object
  • Remote Administration Objects (Visual Basic)


WMEncAgentLocator.GetAgent

The GetAgent method creates a WMEncoderAgent object on a remote computer.

Syntax

WMEncoderAgent = WMEncAgentLocator.GetAgent(bstrMachineName)

Parameters

bstrMachineName

[in] BSTR containing the name of the remote computer.

Return Values

This method returns a WMEncoderAgent object.

Remarks

The name that you use for the remote conputer depends on the network transport used, but universal naming convention (UNC) names such as Remote1, Domain Name System (DNS) names such as Remote1.com, and IP addresses such as 194.222.147.74 are valid.

Example Code

' Declare objects.
Dim AgentLocator
Dim EncoderAgent

' Create a WMEncAgentLocator object.
Set AgentLocator = CreateObject("WMEncLoc.WNEncAgentLocator")

' Create a WMEncoderAgent object on a remote computer.
Set EncoderAgent = AgentLocator.GetAgent("computer name")

See Also

  • WMEncoderAgent Object
  • WMEncoderAgentLocator Object


Structures and Enumeration Types

The Windows Media Encoder SDK implements the following structures and enumeration types.

Structure or enumeration type | Description
PSSTYLE | Defines whether a property page is tabbed.
WMENC_ARCHIVE_OPERATION | Defines whether the archiving operation has been started or stopped.
WMENC_ARCHIVE_STATE | Defines whether archiving is running, stopped or paused.
WMENC_ARCHIVE_TYPE | Defines where encoded content is saved.
WMENC_AUDIOLEVEL_UNITS | Defines the units of measure for the volume of an audio stream.
WMENC_BROADCAST_PROTOCOL | Defines the protocol used to broadcast encoded media content.
WMENC_CROPPING_MODE | Defines how an image is cropped.
WMENC_ENCODER_STATE | Defines whether the encoder has been started or stopped.
WMENC_INDEXER_OPERATION | Defines whether the indexing process has been stopped.
WMENC_INDEXER_STATE | Defines the state of the indexing process.
WMENC_MEDIA_FILTER | Defines the types of input streams supported by a profile.
WMENC_PIXELFORMAT_VIDEO | Defines the pixel format of a video stream or image.
WMENC_PLUGIN_TYPE | Defines whether a plug-in is a source or transform type.
WMENC_SOURCE_STATE | Defines whether the process of capturing an input stream has been started or stopped.
WMENC_SOURCE_TYPE | Defines whether the input source stream is audio, video, or script.
WMENC_VIDEO_OPTIMIZATION | Defines how video is rendered in the video window.
WMENCAPP_PROP_CLASS | Defines the property class that identifies the display state of the user interface panels and windows.
WM_MEDIA_TYPE | Defines a media sample type.

See Also

  • Programming Reference


PSSTYLE

The PSSTYLE enumeration type defines whether a property page is tabbed.

Syntax

typedef enum PSSTYLE
{
    pssNoTabs = 0,
    pssTabsTop = 1,
    pssTabsBottom = 2,
 }PSSTYLE;

Remarks

A property page can have either no tabs, tabs along the top of the page, or tabs along the bottom.

See Also

  • Structures and Enumeration Types


WMENC_ARCHIVE_OPERATION

The WMENC_ARCHIVE_OPERATION enumeration type defines whether the archiving operation has been started, stopped, or paused.

Syntax

typedef enum WMENC_ARCHIVE_OPERATION{
    WMENC_ARCHIVE_START = 1,
    WMENC_ARCHIVE_STOP = 2,
    WMENC_ARCHIVE_PAUSE = 3,
} WMENC_ARCHIVE_OPERATION;

Remarks

No special remarks.

See Also

  • Structures and Enumeration Types


WMENC_ARCHIVE_STATE

The WMENC_ARCHIVE_STATE enumeration type defines whether archiving is running, stopped or paused.

Syntax

typedef enum WMENC_ARCHIVE_STATE{
    WMENC_ARCHIVE_RUNNING = 1,
    WMENC_ARCHIVE_PAUSED = 2,
    WMENC_ARCHIVE_STOPPED = 3
} WMENC_ARCHIVE_STATE;

Remarks

No special remarks.

See Also

  • Structures and Enumeration Types


WMENC_ARCHIVE_TYPE

The WMENC_ARCHIVE_TYPE enumeration type defines where encoded content is saved.

Syntax

typedef enum WMENC_ARCHIVE_TYPE{
    WMENC_ARCHIVE_LOCAL = 1,
} WMENC_ARCHIVE_TYPE;

Remarks

Currently, the encoded content can only be saved to a local destination defined as the computer on which the content was originated and the network on which that computer is located.

See Also

  • Structures and Enumeration Types


WMENC_AUDIOLEVEL_UNITS

The WMENC_ARCHIVE_TYPE enumeration type defines where encoded content is saved.

Syntax

typedef enum WMENC_ARCHIVE_TYPE{
    WMENC_AUDIOLEVEL_DB = 1,
    WMENC_AUDIOLEVEL_LINEAR = 2,
} WMENC_ARCHIVE_TYPE;

Remarks

Audio volume can be expressed on either a decibel or linear scale.

See Also

  • Structures and Enumeration Types


WMENC_BROADCAST_PROTOCOL

The WMENC_BROADCAST_PROTOCOL enumeration type defines the protocol used to broadcast encoded media content.

Syntax

typedef enum WMENC_BROADCAST_PROTOCOL {
    WMENC_PROTOCOL_HTTP = 1,
} WMENC_BROADCAST_PROTOCOL;

Remarks

No special remarks.

See Also

  • Structures and Enumeration Types


WMENC_CROPPING_MODE

The WMENC_CROPPING_MODE enumeration type defines how an image is cropped.

Syntax

typedef enum WMENC_CROPPING_MODE{
    WMENC_CROPPING_ABSOLUTE  = 0
}WMENC_CROPPING_MODE;

Remarks

The default value, WMENC_CROPPING_ABSOLUTE, specifies that an absolute number of pixels is cropped from the edge of an image.

See Also

  • Structures and Enumeration Types


WMENC_ENCODER_STATE

The WMENC_ENCODER_STATE enumeration type defines whether the encoder has been started or stopped.

Syntax

typedef enum WMENC_ENCODER_STATE{
    WM_ENCODER_STARTING = 1,
    WM_ENCODER_RUNNING = 2,
    WM_ENCODER_PAUSED = 3,
    WM_ENCODER_STOPPING = 4
    WM_ENCODER_STOPPED = 5,
} WMENC_ENCODER_STATE;

Remarks

Windows Media Encoder version 4.5 cannot be paused.

See Also

  • Structures and Enumeration Types


WMENC_INDEXER_STATE

The WMENC_INDEXER_STATE enumeration type defines the state of the indexing process.

Syntax

typedef enum WMENC_INDEXER_STATE{
    WMENC_INDEXER_RUNNING  = 1,
    WNEBC_INDEXER_STOPPED  = 2,
}WMENC_INDEXER_STATE;

Remarks

No special remarks.

See Also

  • Structures and Enumeration Types


WMENC_INDEXER_OPERATION

The WMENC_INDEXER_OPERATION enumeration type defines whether the indexing process has been stopped.

Syntax

typedef enum WMENC_INDEXER_OPERATION{
    WMENC_INDEXER_STOP  = 1
}WMENC_INDEXER_OPERATION;

Remarks

No special remarks.

See Also

  • Structures and Enumeration Types


WMENC_MEDIA_FILTER

The WMENC_MEDIA_FILTER enumeration type defines the types of input streams supported by a profile.

Syntax

typedef enum WMENC_MEDIA_FILTER{
    WMENC_FILTER_NONE = 0,
    WMENC_FILTER_A = 1,
    WMENC_FILTER_AV = 3,
    WMENC_FILTER_AS = 4
....WMENC_FILTER_AVS = 5,
} WMENC_MEDIA_FILTER;

Members

WMENC_FILTER_NONE

No media types are supported.

WMENC_FILTER_A

One audio stream is supported.

WMENC_FILTER_AV

One audio and one video stream are supported.

WMENC_FILTER_AS

One audio and one text stream are supported.

WMENC_FILTER_AVS

One audio, one video and one text stream are supported.

Remarks

No special remarks.

See Also

  • IWMEncProfileManager Interface
  • Structures and Enumeration Types


WMENC_PIXELFORMAT_VIDEO

The WMENC_PIXELFORMAT_VIDEO enumeration type defines the pixel format of a video stream or image.

Syntax

typedef enum WMENC_PIXELFORMAT_VIDEO{
    WMENC_PIXELFORMAT_AUTO  = 0x00000001,
    WMENC_PIXELFORMAT_IYUV  = 0x56555949,
    WMENC_PIXELFORMAT_I420  = 0x30323449,
    WMENC_PIXELFORMAT_YV12  = 0x32315659,
    WMENC_PIXELFORMAT_YUY2  = 0x32595559,
    WMENC_PIXELFORMAT_UYVY  = 0x59565955,
    WMENC_PIXELFORMAT_YVYU  = 0x55595659,
    WMENC_PIXELFORMAT_YVU9  = 0x39555659,
    WMENC_PIXELFORMAT_RGB24  = 0xE436EB7D,
    WMENC_PIXELFORMAT_RGB32  = 0xE436EB7E,
    WMENC_PIXELFORMAT_RGB555  = 0xE436EB7C,
    WMENC_PIXELFORMAT_RGB565  = 0xE436EB7B,
    WMENC_PIXELFORMAT_RGB8  = 0xE436EB7A,
    WMENC_PIXELFORMAT_RGB4  = 0xE436EB79,
    WMENC_PIXELFORMAT_RGB1  = 0xE436EB78
};

Remarks

No special remarks.

See Also

  • Structures and Enumeration Types


WMENC_PLUGIN_TYPE

The WMENC_PLUGIN_TYPE enumeration type defines whether a plug-in is a source or transform type.

Syntax

typedef enum WMENC_PLUGIN_TYPE {
    WMENC_PLUGIN_SOURCE = 1,
    WMENC_PLUGIN_TRANSFORM = 2,
} WMENC_PLUGIN_TYPE’

Remarks

A source plug-in provides video, audio, or script content. A transform plug-in modifies an existing stream.

See Also

  • Structures and Enumeration Types


WMENC_SOURCE_STATE

The WMENC_SOURCE_STATE enumeration type defines whether input stream capture has been started or stopped.

Syntax

typedef enum WMENC_SOURCE_STATE{
    WMENC_SOURCE_START = 1,
    WMENC_SOURCE_STOP = 2,
    WMENC_SOURCE_PREPARE = 3,
    WMENC_SOURCE_UNPREPARE = 4,
} WMENC_SOURCE_STATE;

Remarks

No special remarks.

See Also

  • Structures and Enumeration Types


WMENC_SOURCE_TYPE

The WMENC_SOURCE_TYPE enumeration type defines whether the input source stream is audio, video, or script.

Syntax

typedef enum WMENC_SOURCE_TYPE{
    WMENC_AUDIO = 1,
    WMENC_VIDEO = 2,
    WMENC_SCRIPT = 4,
} WMENC_SOURCE_TYPE;

Remarks

No special remarks.

See Also

  • Structures and Enumeration Types


WMENC_VIDEO_OPTIMIZATION

The WMENC_VIDEO_OPTIMIZATION enumeration type defines how video is rendered in the video window.

Syntax

typedef enum WMENC_VIDEO_OPTIMIZATION{
    WMENC_VIDEO_STANDARD  = 1,
    WMENC_VIDEO_DEINTERLACE  = 2,
    WMENC_VIDEO_INVERSETELECINE  = 3,
}WMENC_VIDEO_OPTIMIZATION;

Remarks

No special remarks.

See Also

  • Structures and Enumeration Types


WMENCAPP_PROP_CLASS

The WMENCAPP_PROP_CLASS enumeration type defines the property class that identifies the display state of the user interface panels and windows.

Syntax

typedef enum WMENCAPP_PROP_CLASS{
    WMENCAPP_PROP_USER = 1,
} WMENCAPP_PROP_CLASS;

Remarks

No special remarks.

See Also

  • Structures and Enumeration Types


WM_MEDIA_TYPE

The WM_MEDIA_TYPE structure describes a media sample type.

Syntax

typedef struct _WMMediaType{
    GUID  majortype;
    GUID  subtype;
    BOOL  bFixedSizeSamples;
    BOOL  bTemporalCompression;
    ULONG  lSampleSize;
    GUID  formattype;
    IUnknown*  pUnk;
    ULONG  cbFormat;
    [size_is(cbFormat)] BYTE  *pbFormat;
} WM_MEDIA_TYPE;

Members

majortype

Specifies the major type of the media sample.

subtype

Specifies the subtype of the media sample.

bFixedSizeSamples

Set to true if the samples are of a fixed size.

bTemporalCompression

Set to true if the samples are compressed.

lSampleSize

Long integer containing the size of the sample, in bytes.

formattype

Specifies the GUID of the format type.

pUnk

Pointer to an IUnknown object.

cbFormat

Size of the format section of the media type.

pbFormat

Pointer to the format section of the media type. The layout of this is determined by the format type GUID. Format types include: FORMAT_MPEGVideo (MPEG1VIDEOINFO structure), FORMAT_VideoInfo (VIDEOINFOHEADER structure), FORMAT_WaveFormatEx (WAVEFORMATEX structure), FORMAT_MPEG2Video (MPEG2VIDEOINFO structure), FORMAT_VideoInfo2 (VIDEOINFOHEADER2 structure).

Remarks

This is the same as the DirectShow structure AM_MEDIA_TYPE but is redefined in this SDK to avoid conflict with DirectShow names.

See Also

  • Structures and Enumeration Types


Windows Media Encoder SDK Glossary

This glossary defines terms used in the beta version of the Microsoft® Windows Media™ Encoder 7.1 Software Development Kit (SDK). In addition to Windows Media Encoder terms, Microsoft® Windows Media™ Technologies and other common industry terms are also defined.

To find a term in the glossary, click the letter of the alphabet that is the first letter in the term you want to look up.

You can also read glossary terms within the text of the SDK documentation by clicking the underlined glossary term links. After you click a glossary link, the glossary term and definition appear in a pop-up window. To close the window, click anywhere on the screen.

A | B | C | D | E | F | G | H | I | J | K | L | M
N | O | P | Q | R | S | T | U | V | W | X | Y | Z


Glossary

To find a term in the glossary, click the letter of the alphabet that is the first letter in the term you want to look up.

A | B | C | D | E | F | G | H | I | J | K | L | M
N | O | P | Q | R | S | T | U | V | W | X | Y | Z

B

bandwidth

The data transfer capacity of a digital communications system, such as the Internet or a LAN. Bandwidth is usually expressed in the number of bits that a system is capable of transferring in a second: bits per second (bps). High bandwidth or broadband refers to a network capable of a fast data transfer rate.

bit rate

The speed at which digital audio and video content is streamed from a source, such as a file, to be rendered properly by a player, or the speed at which binary content in general is streamed on a network. Bit rate is usually measured in kilobits per second (Kbps), for example, 28.8 Kbps. The bit rate of a Windows Media file or live stream is determined during the encoding process, when the streaming content is created. Bandwidth is the total bit rate capacity of a network. For audio and video content to render properly when streaming over a network, the bandwidth of the network must be high enough to accommodate the bit rates of all the different content that is concurrently being streamed.

C

CD quality

Audio that is encoded by using uncompressed PCM at 44.1 kHz and 16 bit stereo. A CD and an audio stream encoded at CD quality sound identical.

caption

Text that accompanies an image or video stream.

codec

Abbreviation for compressor/decompressor. An algorithm or scheme used when recording digital video or audio. A codec is used, for example, when video is transmitted over the Internet; the video is compressed on the sending end and decompressed on the receiving end. Users can select a codec based on the audio or image quality, and image size preferred.

compression

The coding of data to reduce file size or the bit rate of a stream. Content that has been compressed must be decompressed for playback. A codec contains the algorithms for compressing and decompressing audio and video.

content

Data that an encoder or server streams to a client or clients. Content can originate from live audio or live video presentation, stored audio or video files, still images, or slide shows. The content must be translated from its original state into a Windows Media format before a Windows Media server can stream it. Windows Media servers can stream live streams or stored Window Media files as content.

D

deinterlace

To combine two interlaced fields into a single frame and render them at 30 frames per second (fps). Deinterlacing is done to remove artifacts and improve the quality of encoded video.

delta frame

Frames that contain only the changes from the previous frame.

E

encode

To convert information into a specified digital format for convenient storage and retrieval by using computer technology, usually involving compression technology and encryption technology.

I

intelligent streaming

A type of streaming that detects network conditions and adjusts the properties of a video or audio stream to maximize quality. Intelligent streaming is only available for content encoded using a multiple bit rate profile.

See also streaming

interlace

To display video by using a half-resolution image known as a field. Interlaced video uses two video fields to make a single frame of video. Each field of video contains alternating lines of an image: field one displays the odd numbered lines and field two displays the even numbered lines. Interlacing saves bandwidth when the video is transmitted over the airways or on cable.

inverse telecine

The process that intelligently removes the frames that were added when 24 fps film was converted to 30 fps video.

ISO MPEG-4 video codec version 1.0

A type of codec based on the ISO MPEG-4 standard. It enables you to encode content produced by many consumer electronics devices, such as digital video cameras and cell phones.

L

looping

The process in which file-based content is played repeatedly until encoding is completed. Looping ensures that you have no interruption in the stream as a result of reaching the end of a file before completing a broadcast or capture session.

lossless compression

Data compression techniques in which no data is lost.

lossy compression

Refers to data compression techniques in which some amount of data is lost. Lossy compression technologies attempt to eliminate redundant or unnecessary information.

M

Media Stream Broadcast Distribution protocol

A protocol used to reference Windows Media Encoder, which is the source of a stream. Used when streaming from the Windows Media Station service to a content-storage server or for server-to-server distribution. Do not use the MSBD protocol over a firewall.

Microsoft MPEG-4 version 3 codec

A video codec included with Microsoft Windows Media Encoder version 4.0.

Microsoft Windows Media Audio codec version 7.0

A codec used to encode most audio streams. It is best used for Internet narrowband streaming and high-fidelity downloadable music.

Microsoft Windows Media Screen codec version 7.0

A codec that enables lossless streaming of computer screen images at data rates as low as 15 Kbps for on-demand training, software demos, and helpdesk applications. It is well suited for capturing screens in productivity applications, such as Microsoft Word, Excel, and Visual Studio. This screen capture codec is included with Windows Media Player 7.

Microsoft Windows Media Video codec version 7.0

A codec that supports a wide variety of network bandwidths and enhances video quality for broadband Internet users. It supports multiple bit rate profiles and can be used to deliver TV-quality compression at 700 Kbps.

MSBD

See Media Stream Broadcast Distribution protocol

multicast

A one-to-many connection in which multiple clients can receive the same stream from a server. To receive a multicast, a client must have access to a multicast-enabled network. In contrast, a unicast is a one-to-one connection in which one client receives a distinct stream from a server.

multicast station

A defined location from which a player can receive streams. In effect, it is an IP address and a port. Windows Media server components use stations with Windows Media streams only and save station information as a Windows Media file with an .nsc extension.

multiple bit rate video

A feature of Windows Media Technologies that supports the creating and streaming of multiple encoded video streams within one Windows Media stream. By using multiple bit rate video in Windows Media Encoder, you can create Windows Media-based content that has a variety of video streams at variable bandwidths ranging from 28.8 Kbps through 300 Kbps, as well as a separate audio stream. After receiving this multiple encoded stream, the server determines which bandwidth to stream based on the network bandwidth available. Multiple bit rate video is not supported on generic HTTP servers.

N

National Television Standards Committee

The standards body that is responsible for setting television and video standards in the United States. The NTSC standard for television defines a composite video signal with a refresh rate of 60 half-frames (interlaced) per second. Each frame contains 525 lines and can contain 16 million different colors.

NTSC

See National Television Standards Committee

NTFS

An advanced file system designed for use specifically within the Windows 2000 operating system. It supports file system recovery, extremely large storage media, and long file names. It also supports object-oriented applications by treating all files as objects with user-defined and system-defined attributes.

P

PAL

See Phase Alternating Line

.prx

The file name extension that indicates a custom profile you have created by using Profile Manager. See also profile

Phase Alternating Line

The dominant television standard in Europe. Whereas The NTSC, the U.S. standard, delivers 525 lines of resolution at 60 half-frames per second, PAL delivers 625 lines at 50 half-frames per second. See also NTSC

pixel format

The color depth of an image, usually measured in RGB or YUV.

profile

A predefined group of settings that match content type and bit rate with appropriate audio and video codecs.

Profile Manager

A component of Windows Media Encoder that creates and edits the encoding profiles needed to identify the appropriate codec, the multimedia input streams, and the number and bit rate of the encoded output streams.

pulse code modulation

A sampling technique for digitizing analog signals, especially audio signals. When you encode audio by using PCM, no compression is applied.

R

RGB

A color model that describes color information in terms of the red (R), green (G), and blue (B) intensities that make up the color.

S

script

A caption, URL, or custom script command that is inserted into a stream during an encoding session. The caption is displayed on Windows Media Player during playback of the encoded content. The URL causes the browser to open to the specified Web page. The custom script command sends notification of an event, such as launching a Web page with an embedded player. See also caption

Sipro Labs ACELP codec

A type of codec that provides excellent voice compression at low bit rates. This codec comes with several audio formats depending on the network bandwidth you choose.

source

The type of content that Windows Media Encoder can encode: audio, video, or script. Audio and video content is captured from a card installed on your computer or from a file that was converted to Windows Media Format. Scripts are typed directly from the encoder user interface during an encoding session.

source group

Audio, video, and scripts that are encoded into a stream and played in Windows Media Player.

stream

Data transmitted across a network and any properties associated with the data. Streaming data enables the player to begin rendering the data immediately instead of waiting for the entire file to be downloaded.

stream format file

A file used by Windows Media Player to decode a multicast Windows Media format stream. A stream format file includes information about the stream, the media that the stream contains, and its codec.

T

target bandwidths

The number of bits that are transferred to users based on the speed of their network connections.

telecine

The film-to-video conversion system that adds frames to video to compensate for the differences in frame rates between film and video. When converting 24 fps film to 30 fps NTSC video, an additional 6 frames per second are added.

time-to-live

In multicasting, a value that defines the number of routers through which a multicast can pass before a router stops forwarding the multicast.

TTL

See time-to-live

U

UDP

See User Datagram Protocol

unicast

A one-to-one client/server connection during which the client receives a distinct stream from the server. No other client has access to the stream. Each client has its own connection to the server and a separate content stream must be generated for each client requesting content from the server.

User Datagram Protocol

A communication protocol that sends a data unit or datagram from one computer to another. It does not sequence the packets that the data arrives in, but it does provide a checksum capability to verify that the data arrived intact.

W

.wme

The file name extension that identifies the Windows Media Encoder configuration file created when you set up an encoding session.

Windows Media file

A file created by Windows Media Technologies, which contains audio, video, or script data that is stored in Windows Media Format. It is highly optimized for streaming. This file can be streamed by Windows Media server and played by Windows Media Player.

Windows Media Format

The format used by Microsoft Windows Media Technologies (or a third party product that incorporates a licensed Windows Media technology) to author, store, edit, distribute, stream, or play timeline-based content.

Y

YUV

A color model that describes color information in terms of luminance (Y) and chrominance (U, V).

Previous


Legal Notice

Information in this document, including URL and other Internet Web site references, is subject to change without notice. Unless otherwise noted, the example companies, organizations, products, people and events depicted herein are fictitious and no association with any real company, organization, product, person or event is intended or should be inferred. Complying with all applicable copyright laws is the responsibility of the user. Without limiting the rights under copyright, no part of this document may be reproduced, stored in or introduced into a retrieval system, or transmitted in any form or by any means (electronic, mechanical, photocopying, recording, or otherwise), or for any purpose, without the express written permission of Microsoft Corporation.

Microsoft may have patents, patent applications, trademarks, copyrights, or other intellectual property rights covering subject matter in this document. Except as expressly provided in any written license agreement from Microsoft, the furnishing of this document does not give you any license to these patents, trademarks, copyrights, or other intellectual property.

© 2000-2001 Microsoft Corporation. All rights reserved.

Microsoft, MS-DOS, Windows, Windows Media, Windows NT, ActiveSync, ActiveX, Direct3D, DirectDraw, DirectInput, DirectMusic, DirectPlay, DirectShow, DirectSound, DirectX, FrontPage, JScript, Microsoft Press, MSN, NetShow, Outlook, PowerPoint, SQL Server, Visual Basic, Visual C++, Visual InterDev, Visual J++, Visual Studio, WebTV, Win32, and Win32s are either registered trademarks or trademarks of Microsoft Corporation in the U.S.A. and/or other countries.

The names of actual companies and products mentioned herein may be the trademarks of their respective owners.