⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 av_upnp.h

📁 Windows CE 6.0 Server 源码
💻 H
📖 第 1 页 / 共 5 页
字号:
//
// Copyright (c) Microsoft Corporation.  All rights reserved.
//
//
// Use of this source code is subject to the terms of the Microsoft shared
// source or premium shared source license agreement under which you licensed
// this source code. If you did not accept the terms of the license agreement,
// you are not authorized to use this source code. For the terms of the license,
// please see the license agreement between you and Microsoft or, if applicable,
// see the SOURCE.RTF on your install media or the root of your tools installation.
// THE SOURCE CODE IS PROVIDED "AS IS", WITH NO WARRANTIES.
//

#ifndef __AV_UPNP_H
#define __AV_UPNP_H

#include <atlbase.h>

extern CComModule _Module;

#include <atlcom.h>
#include <upnp.h>
#include <upnphost.h>

#include "av_dcp.h"

#include <string.hxx>
#include <hash_map.hxx>
#include <hash_set.hxx>
#include <sync.hxx>
#include <auto_xxx.hxx>

// Debug zone bits
#define BIT_AV_ERROR            0
#define BIT_AV_WARN             1
#define BIT_AV_TRACE            2

// Debug zones
#define ZONE_AV_ERROR           DEBUGZONE(BIT_AV_ERROR)
#define ZONE_AV_WARN            DEBUGZONE(BIT_AV_WARN)
#define ZONE_AV_TRACE           DEBUGZONE(BIT_AV_TRACE)

#define ZONE_AV_ERROR_NAME      L"AV UPnP error"
#define ZONE_AV_WARN_NAME       L"AV UPnP warning"
#define ZONE_AV_TRACE_NAME      L"AV UPnP trace"

// Default zones
#define DEFAULT_AV_ZONES        (1 << BIT_AV_ERROR) | (1 << BIT_AV_WARN)

namespace av_upnp
{

enum UPnPAVError
{
    SUCCESS_AV                                              = 0,

    // Internal-AV-toolkit-only Errors
    ERROR_AV_POINTER                                        = -1,  // unexpected NULL pointer function argument
    ERROR_AV_OOM                                            = -2,  // ran out of memory during function's execution
    ERROR_AV_INVALID_INSTANCE                               = -3,  // nonexistant (when it must exist) or existing (when it must not exist) Instance ID/pointer
    ERROR_AV_INVALID_STATEVAR                               = -4,  // the given state variable name is invalid
    ERROR_AV_ALREADY_INITED                                 = -5,  // this service class has already had its Init() called
    
    // Internal-AV-toolkit ctrl-point-only Errors
    ERROR_AV_NONEXISTANT_SERVICE                            = -6,  // a required service does not exist on the device
    ERROR_AV_NO_MORE_ITEMS                                  = -7,  // returned enumerators to indicate end of data set
    ERROR_AV_UPNP_ERROR                                     = -8,  // UPnP control point APIs returned a system error; the specific error is available using GetLastError
    ERROR_AV_INVALID_OUT_ARGUMENTS                          = -9,  // action returned wrong number and/or type of [out] arguments

    // Standard UPnP Errors
    ERROR_AV_UPNP_INVALID_ACTION                            = FAULT_INVALID_ACTION,
    ERROR_AV_UPNP_ACTION_FAILED                             = FAULT_DEVICE_INTERNAL_ERROR,

    // ConnectionManager Errors
    ERROR_AV_UPNP_CM_INCOMPATIBLE_PROTOCOL                  = 701,
    ERROR_AV_UPNP_CM_INCOMPATIBLE_DIRECTION                 = 702,
    ERROR_AV_UPNP_CM_INSUFFICIENT_NET_RESOURCES             = 703,
    ERROR_AV_UPNP_CM_LOCAL_RESTRICTIONS                     = 704,
    ERROR_AV_UPNP_CM_ACCESS_DENIED                          = 705,
    ERROR_AV_UPNP_CM_INVALID_CONNECTION_REFERENCE           = 706,
    ERROR_AV_UPNP_CM_NOT_IN_NETWORK                         = 707,

    // AVTransport Errors
    ERROR_AV_UPNP_AVT_INVALID_TRANSITION                    = 701,
    ERROR_AV_UPNP_AVT_NO_CONTENTS                           = 702,
    ERROR_AV_UPNP_AVT_READ_ERROR                            = 703,
    ERROR_AV_UPNP_AVT_UNSUPPORTED_PLAY_FORMAT               = 704,
    ERROR_AV_UPNP_AVT_TRANSPORT_LOCKED                      = 705,
    ERROR_AV_UPNP_AVT_WRITE_ERROR                           = 706,
    ERROR_AV_UPNP_AVT_PROTECTED_MEDIA                       = 707,
    ERROR_AV_UPNP_AVT_UNSUPPORTED_REC_FORMAT                = 708,
    ERROR_AV_UPNP_AVT_FULL_MEDIA                            = 709,
    ERROR_AV_UPNP_AVT_UNSUPPORTED_SEEK_MODE                 = 710,
    ERROR_AV_UPNP_AVT_ILLEGAL_SEEK_TARGET                   = 711,
    ERROR_AV_UPNP_AVT_UNSUPPORTED_PLAY_MODE                 = 712,
    ERROR_AV_UPNP_AVT_UNSUPPORTED_REC_QUALITY               = 713,
    ERROR_AV_UPNP_AVT_ILLEGAL_MIME                          = 714,
    ERROR_AV_UPNP_AVT_CONTENT_BUSY                          = 715,
    ERROR_AV_UPNP_AVT_RESOURCE_NOT_FOUND                    = 716,
    ERROR_AV_UPNP_AVT_UNSUPPORTED_PLAY_SPEED                = 717,
    ERROR_AV_UPNP_AVT_INVALID_INSTANCE_ID                   = 718,

    // RenderingControl Errors
    ERROR_AV_UPNP_RC_INVALID_PRESET_NAME                    = 701,
    ERROR_AV_UPNP_RC_INVALID_INSTANCE_ID                    = 702,

    // ContentDirectory Errors
    ERROR_AV_UPNP_CD_NO_SUCH_OBJECT                         = 701,
    ERROR_AV_UPNP_CD_INVALID_CURRENTTAGVALUE                = 702,
    ERROR_AV_UPNP_CD_INVALID_NEWTAGVALUE                    = 703,
    ERROR_AV_UPNP_CD_REQUIRED_TAG_DELETE                    = 704,
    ERROR_AV_UPNP_CD_READONLY_TAG_UPDATE                    = 705,
    ERROR_AV_UPNP_CD_PARAMETER_NUM_MISMATCH                 = 706,
    ERROR_AV_UPNP_CD_BAD_SEARCH_CRITERIA                    = 708,
    ERROR_AV_UPNP_CD_BAD_SORT_CRITERIA                      = 709,
    ERROR_AV_UPNP_CD_NO_SUCH_CONTAINER                      = 710,
    ERROR_AV_UPNP_CD_RESTRICTED_OBJECT                      = 711,
    ERROR_AV_UPNP_CD_BAD_METADATA                           = 712,
    ERROR_AV_UPNP_CD_RESTRICTED_PARENT_OBJECT               = 713,
    ERROR_AV_UPNP_CD_NO_SUCH_SOURCE_RESOURCE                = 714,
    ERROR_AV_UPNP_CD_SOURCE_RESOURCE_ACCESS_DENIED          = 715,
    ERROR_AV_UPNP_CD_TRANSFER_BUSY                          = 716,
    ERROR_AV_UPNP_CD_NO_SUCH_FILE_TRANSFER                  = 717,
    ERROR_AV_UPNP_CD_NO_SUCH_DESTINATION_RESOURCE           = 718,
    ERROR_AV_UPNP_CD_DESTINATION_RESOURCE_ACCESS_DENIED     = 719,
    ERROR_AV_UPNP_CD_REQUEST_FAILED                         = 720
};



enum DIRECTION
{
    OUTPUT,
    INPUT
};


//
// Define string classes in the av_upnp namespace
//
typedef ce::_string_t<wchar_t>                                      wstring;
typedef ce::_string_t<wchar_t, 16, ce::i_char_traits<wchar_t> >     wistring;


//
// Data structures used in parameter passing
//

// forward declaration for struct ConnectionInfo
class IRenderingControl;
class IAVTransport;

struct ConnectionInfo
{
    IRenderingControl*  pRenderingControl;
    IAVTransport*       pAVTransport;
    wstring             strRemoteProtocolInfo;
    wstring             strPeerConnectionManager;
    long                nPeerConnectionID;
    DIRECTION           Direction;
    wstring             strStatus;
};

struct MediaInfo
{
    unsigned long nNrTracks;
    wstring strMediaDuration;
    wstring strCurrentURI;
    wstring strCurrentURIMetaData;
    wstring strNextURI;
    wstring strNextURIMetaData;
    wstring strPlayMedium;
    wstring strRecordMedium;
    wstring strWriteStatus;
};

struct TransportInfo
{
    wstring strCurrentTransportState;
    wstring strCurrentTransportStatus;
    wstring strCurrentSpeed;
};

struct PositionInfo
{
    unsigned long nTrack;
    wstring strTrackDuration;
    wstring strTrackMetaData;
    wstring strTrackURI;
    wstring strRelTime;
    wstring strAbsTime;
    long nRelCount;
    long nAbsCount;
};

struct DeviceCapabilities
{
    wstring strPossiblePlayMedia;
    wstring strPossibleRecMedia;
    wstring strPossibleRecQualityModes;
};

struct TransportSettings
{
    wstring strPlayMode;
    wstring strRecQualityMode;
};

struct TransportActions
{
    bool bPlay;
    bool bStop;
    bool bPause;
    bool bSeek;
    bool bNext;
    bool bPrevious;
    bool bRecord;
};



// Class naming convention:
// upnp_av::I[Xxx]                 - interface
// upnp_av::[Functionality]Support - toolkit class providing functionality "Functionality", inherited from by toolkit classes
// upnp_av::[Xxx]Impl              - toolkit class which user may use as a base class but can not be instantiated
// upnp_av::[Xxx]ServiceImpl       - toolkit COM class implementing UPnP service
// upnp_av::[Xxx]                  - toolkit class user may instantiate but not use as base class


//
// Interfaces
//


//
// IEventSink
//
class IEventSink
{
public:
    virtual DWORD OnStateChanged(
        /*[in]*/  LPCWSTR pszStateVariableName,
        /*[in]*/  LPCWSTR pszValue) = 0;
        
    virtual DWORD OnStateChanged(
        /*[in]*/  LPCWSTR pszStateVariableName,
        /*[in]*/  long nValue) = 0;

    virtual DWORD OnStateChanged(
        /*[in]*/  LPCWSTR pszStateVariableName,
        /*[in]*/  LPCWSTR pszChannel,
        /*[in]*/  long nValue) = 0;
};


//
// IEventSource
//
class IEventSource
{
public:
    virtual DWORD Advise(  /*[in]*/ IEventSink *pSubscriber) = 0;
    virtual DWORD Unadvise(/*[in]*/ IEventSink *pSubscriber) = 0;
};


//
// IVirtualService
//
class IVirtualService
{
public:
    virtual void Release() = 0;
};


//
// IAVTransport - interface of AVTransport virtual service
//
class IAVTransport : public IVirtualService, 
                     public IEventSource
{
public:
    virtual DWORD SetAVTransportURI(
        /* [in] */ LPCWSTR pszCurrentURI,
        /* [in] */ LPCWSTR pszCurrentURIMetaData) = 0;

    virtual DWORD SetNextAVTransportURI(
        /* [in] */ LPCWSTR pszNextURI,
        /* [in] */ LPCWSTR pszNextURIMetaData) = 0;

    virtual DWORD GetMediaInfo(
        /* [in, out] */ MediaInfo* pMediaInfo) = 0;

    virtual DWORD GetTransportInfo(
        /* [in, out] */ TransportInfo* pTransportInfo) = 0;

    virtual DWORD GetPositionInfo(
        /* [in, out] */ PositionInfo* pPositionInfo) = 0;

    virtual DWORD GetDeviceCapabilities(
        /* [in, out] */ DeviceCapabilities* pDeviceCapabilities) = 0;

    virtual DWORD GetTransportSettings(
        /* [in, out] */ TransportSettings* pTransportSettings) = 0;

    virtual DWORD Stop() = 0;

    virtual DWORD Play(
        /* [in] */ LPCWSTR pszSpeed) = 0;

    virtual DWORD Pause() = 0;

    virtual DWORD Record() = 0;

    virtual DWORD Seek(
        /* [in] */ LPCWSTR pszUnit,
        /* [in] */ LPCWSTR pszTarget) = 0;

    virtual DWORD Next() = 0;

    virtual DWORD Previous() = 0;

    virtual DWORD SetPlayMode(
        /* [in] */ LPCWSTR pszNewPlayMode) = 0;

    virtual DWORD SetRecordQualityMode(
        /* [in] */ LPCWSTR pszNewRecordQualityMode) = 0;

    virtual DWORD GetCurrentTransportActions(
        /* [in, out] */ TransportActions* pActions) = 0;

    virtual DWORD InvokeVendorAction(
        /* [in] */ LPCWSTR pszActionName,
        /* [in] */ DISPPARAMS* pdispparams, 
        /* [in, out] */ VARIANT* pvarResult) = 0;
};


//
// IRenderingControl - interface of RenderingControl virtual service
//
class IRenderingControl : public IVirtualService, 
                          public IEventSource
{
public:
    virtual DWORD ListPresets(
        /* [in, out] */ wstring* pstrPresetNameList) = 0;

    virtual DWORD SelectPreset(
        /* [in] */ LPCWSTR pszPresetName) = 0;

    virtual DWORD GetBrightness(
        /* [in, out] */ unsigned short* pBrightness) = 0;

    virtual DWORD SetBrightness(
        /* [in] */ unsigned short Brightness) = 0;

    virtual DWORD GetContrast(
        /* [in, out] */ unsigned short* pContrast) = 0;

    virtual DWORD SetContrast(
        /* [in] */ unsigned short Contrast) = 0;

    virtual DWORD GetSharpness(
        /* [in, out] */ unsigned short* pSharpness) = 0;

    virtual DWORD SetSharpness(
        /* [in] */ unsigned short Sharpness) = 0;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -