IFileSourceFilter Interface

Interface Methods:

HRESULT GetCurfile(LPOLESTR *ppszFileName, AM_MEDIA_TYPE *pmt);

Parameters

ppszFileName

A valid pointer to a pointer that will receive a copy of the URL string. This cannot be NULL.

pmt

A pointer to an AM_MEDIA_TYPE structure. This pointer is optional and you can pass NULL if you do not need the media type.

Description

Gets the current URL string. This string contains the IP address, the port and the network card address. See the Load method for more information on the format of the URL string.

If the function succeeds, the ppszFileName pointer will be updated with a pointer to a buffer containing the URL. This buffer has been allocated with CoTaskMemAlloc. You are responsible for freeing this buffer when you are done with it by calling CoTaskMemFree.

If the function succeeds and you set pmt to a valid pointer to AM_MEDIA_TYPE structure, this structure will be initialized with a copy of the stream media type. You are responsible for freeing the data allocated in this structure by calling the FreeMediaType function. Please refer to the Microsoft documentation for more information on this function.

Returns

S_OK if successful, < 0 if an error occurred.

Common error codes:

Value

Meaning

E_POINTER

ppszFilename is NULL

 

HRESULT Load(LPCOLESTR pszFileName, const AM_MEDIA_TYPE *pmt);

Parameters

pszFileName

A valid pointer to a buffer containing the URL of the UDP stream. This cannot be NULL.

pmt

A pointer to an AM_MEDIA_TYPE structure indicating the media type of the data being streamed. This pointer can be NULL, in which case a default media type will be assumed.

Description

This function sets the URL of UDP or TCP stream. This string specifies the:

  1. IP address of the server sending the data

  2. (Optional) The UDP or TCP port on which the data will be received. If no port is specified, 9005 will be used.

  3. (Optional) The IP address of network card receiving the data. If no network card is specified, the default network connection will be used.

The format of the string for UDP streaming is as follows:

   udp://ip_address[:udp_port][/network_card]

 

ip_address

The IP address of the server sending the data. This can be in the usual Ipv4 format (xx.xx.xx.xx) or it can be a valid host address accepted by the standard function inet_addr. For example, localhost is equivalent to 127.0.0.1

The stream is considered to be multicast if the first number in the Ipv4 address is between 224..239 (0xE0 .. 0xEF). If the first number is not in this range, the stream is unicast.

network_card

(Optional) The address of the network card receiving the data. This is optional – if it is missing, the default network card will be used.This is used only for receiving multicast streams.

udp_port

(Optional) The port on which to listen. The port must be a number from 1 to 65535. Note that you must make sure the port is open if you are running firewall software.

 

The format of the string for TCP streaming is as follows:

ip_address

The IP address of the server sending the data. This can be in the usual Ipv4 format (xx.xx.xx.xx) or it can be a valid host address accepted by the standard function inet_addr. For example, localhost is equivalent to 127.0.0.1. This is usually the IP address of the sending (server) computer.

TCP streams cannot be multicast. All TCP streams are assumed to be unicast.

tcp_port

(Optional) The port on which to listen. The port must be a number from 1 to 65535. Note that you must make sure the port is open if you are running firewall software.

 

Examples of valid strings:

udp://127.0.0.1:9005 - receive the Unicast stream from 127.0.0.1 on port 9005

udp://224.1.1.1:9005/20.5.1.200 - receive the Multicast stream 224.1.1.1 on port 9005 using the network card with the IP address of 20.5.1.200

tcp://127.0.0.1:9005 – receive the TCP stream from 127.0.0.1 (local computer) on port 9005

Note that you can find out the IP addresses of the network connections on your computer on Windows XP by typing the ipconfig command at the DOS prompt. For more information on obtaining your machine's host name, refer to How to Get Your Own IP Address Programmatically.

One might want to use a particular network card if you have two network connections and one is faster than the other. For example, a laptop might be connected to the network with a wireless network card and a regular network wire. In this case, it would be better to using the wired connection because it is faster and more reliable.

Returns

S_OK if successful, < 0 if an error occurred.

Common error codes:

Value

Meaning

HRESULT_FROM_WIN32(WSAHOST_NOT_FOUND)

(0x80072AF9) The URL is invalid.

HRESULT_FROM_WIN32(WSAETIMEDOUT)

(0x8007274C) The URL might be valid, but the remote end is not sending data

E_OUTOFMEMORY

(0x8007000E) Out of memory

E_FAIL                                                                           

 (0x80004005) Unspecified error

HRESULT_FROM_WIN32(xxx)

Windows error xxx has occurred. You can consult the Microsoft documentation for the definition of the HRESULT_FROM_WIN32 macro and the complete list of Windows error codes.