WMEncoder.GetWatermark

Windows Media Encoder SDK banner art

The GetWatermark method retrieves the name of a watermark used in the current encoding session.

Syntax

string WMEncoder.GetWatermark(
  WMENC_SOURCE_TYPE  enumSourceType,
  short  iIndex,
  out object  pvarConfigFile,
  out object  pvarCLSID
);

Parameters

enumSourceType

[in]  Specifies a member of the WMENC_SOURCE_TYPE enumeration type indicating the type of content.

iIndex

[in]  Int16 containing the index.

pvarConfigFile

[out]  Object specifying the configuration file.

pvarCLSID

[out]  Object specifying the CLSID.

Return Values

This method returns a String containing the name of the watermark.

If this method fails, it returns an error number.

Return code Number Description
E_INVALIDARG 0x80070057 Invalid argument:
  • iIndex is not 0.
  • The enumSourceType is invalid.

Remarks

Use this method to find out which watermarks are being used in the current encoding session. To determine the index, use the IWMEncWatermarkCollection.Count property.

Example Code

using WMEncoderLib;

try
{
// Create a WMEncoder object.
  WMEncoder Encoder;
  Encoder = new WMEncoder();

// Configure the encoding session, including the sources, output, and
// profile.

// Declare variables and create objects to hold the audio and video
// watermark collections.
  IWMEncWatermarkCollection WMCollAud;
  IWMEncWatermarkCollection WMCollVid;
  WMCollAud = Encoder.get_WatermarkCollection(WMENC_SOURCE_TYPE.WMENC_AUDIO);
  WMCollVid = Encoder.get_WatermarkCollection(WMENC_SOURCE_TYPE.WMENC_VIDEO);

// Retrieve the number of audio and video watermarks in the registry.
  int lWatercountAud;
  int lWatercountVid;
  lWatercountAud = WMCollAud.Count;
  lWatercountVid = WMCollVid.Count;

// Declare variables for the name of the audio watermark, the name of the
// video watermark, the configuration file, and a placeholder for a CLSID.
  string sAudioWatermark;
  string sVideoWatermark;
  string sWatermarkConfig;
  object vWatermarkID;

// Retrieve the name of the first audio watermark in the collection.
  sAudioWatermark = WMCollAud.Item(0, vWatermarkID);

// Retrieve the name of the first video watermark in the collection.
  sVideoWatermark = WMCollVid.Item(0, vWatermarkID);

// Specify the location of the watermark configuration file.
  sWatermarkConfig = "REPLACE WITH A PATH AND FILENAME";

// Set the audio and video watermarks into the WMEncoder object.
  Encoder.SetWatermark(WMENC_SOURCE_TYPE.WMENC_AUDIO, 0, sAudioWatermark, vWatermarkID.ToString(), sWatermarkConfig);
  Encoder.SetWatermark(WMENC_SOURCE_TYPE.WMENC_VIDEO, 0, sVideoWatermark, vWatermarkID.ToString(), sWatermarkConfig);

// Retrieve the names of the watermarks being used in the current session.
  string sWMarkNameAud = Encoder.GetWatermark(WMENC_SOURCE_TYPE.WMENC_AUDIO, 0, out sWatermarkConfig, out sAudioWatermark);
  string sWMarkNameVid = Encoder.GetWatermark(WMENC_SOURCE_TYPE.WMENC_VIDEO, 0, out sWatermarkConfig, out sVideoWatermark);
}

catch (Exception e)
{
     // TODO: Handle exceptions.
}

Requirements

Reference: Windows Media Encoder

Namespace: WMEncoderLib

Assembly: Interop.WMEncoderLib.dll

Library: WMEncoderLib.dll

See Also