onvif
    Preparing search index...

    Interface Media2

    Media2 service, ver20 (Profile T profiles, configurations, OSD, stream URI).

    import { Onvif } from 'onvif';

    const onvif = new Onvif({ hostname: '192.168.1.13', username: 'admin', password: 'admin' });
    await onvif.connect();

    const profiles = await onvif.media2.getProfiles({ type: ['All'] });
    const profileToken = profiles[0]!.token;
    const encoders = await onvif.media2.getVideoEncoderConfigurations({ profileToken });
    console.log(profiles[0]?.name, encoders[0]?.encoding, encoders[0]?.resolution);

    const { uri } = await onvif.media2.getStreamUri({ profileToken, protocol: 'RtspUnicast' });
    const snap = await onvif.media2.getSnapshotUri({ profileToken });
    console.log(uri, snap.uri);

    const sources = await onvif.media2.getVideoSourceConfigurations({ profileToken });
    const osds = await onvif.media2.getOSDs({ configurationToken: sources[0]!.token });
    console.log('OSDs', osds.map((o) => o.token));
    interface Media2 {
        onvif: Onvif;
        service: keyof OnvifServices;
        xmlns: string;
        addConfiguration(options: AddConfigurationExtended): Promise<void>;
        createMask(options: Mask): Promise<string>;
        createOSD(options: OSDConfiguration): Promise<string>;
        createProfile(options: CreateProfileExtended): Promise<string>;
        deleteMask(token: DeleteMask): Promise<void>;
        deleteOSD(OSDToken: DeleteOSD): Promise<void>;
        deleteProfile(options: DeleteProfile): Promise<void>;
        getAnalyticsConfigurations(
            options?: GetAnalyticsConfigurations,
        ): Promise<VideoAnalyticsConfiguration[]>;
        getAudioDecoderConfigurationOptions(
            options?: GetConfiguration,
        ): Promise<AudioDecoderConfigurationOptions>;
        getAudioDecoderConfigurations(
            options?: GetAudioDecoderConfigurations,
        ): Promise<AudioDecoderConfiguration[]>;
        getAudioEncoderConfigurationOptions(
            options?: GetConfiguration,
        ): Promise<AudioEncoderConfigurationOption[]>;
        getAudioEncoderConfigurations(
            options?: GetAudioEncoderConfigurations,
        ): Promise<AudioEncoder2Configuration[]>;
        getAudioOutputConfigurationOptions(
            options?: GetConfiguration,
        ): Promise<AudioOutputConfigurationOptions>;
        getAudioOutputConfigurations(
            options?: GetAudioOutputConfigurations,
        ): Promise<AudioOutputConfigurationExtended[]>;
        getAudioSourceConfigurationOptions(
            options?: GetConfiguration,
        ): Promise<AudioSourceConfigurationOptions>;
        getAudioSourceConfigurations(
            options?: GetAudioSourceConfigurations,
        ): Promise<AudioSourceConfiguration[]>;
        getMaskOptions(configurationToken: GetMaskOptions): Promise<MaskOptions>;
        getMasks(options?: GetMasks): Promise<Mask[]>;
        getMetadataConfigurationOptions(
            options?: GetConfiguration,
        ): Promise<MetadataConfigurationOptions>;
        getMetadataConfigurations(
            options?: GetMetadataConfigurations,
        ): Promise<MetadataConfiguration[]>;
        getOSDOptions(
            options?: Partial<GetOSDOptions>,
        ): Promise<OSDConfigurationOptions>;
        getOSDs(options?: GetOSDs): Promise<OSDConfiguration[]>;
        getProfiles(options?: GetProfiles): Promise<MediaProfile[]>;
        getServiceCapabilities(): Promise<Capabilities2>;
        getSnapshotUri(options?: GetSnapshotUri): Promise<GetSnapshotUriResponse>;
        getStreamUri(
            __namedParameters: GetStreamUri,
        ): Promise<GetStreamUriResponse>;
        getVideoEncoderConfigurationOptions(
            options?: GetConfiguration,
        ): Promise<VideoEncoder2ConfigurationOptions[]>;
        getVideoEncoderConfigurations(
            options?: GetVideoEncoderConfigurations,
        ): Promise<VideoEncoder2Configuration[]>;
        getVideoEncoderInstances(
            options: GetVideoEncoderInstances,
        ): Promise<EncoderInstanceInfo>;
        getVideoSourceConfigurationOptions(
            options?: GetConfiguration,
        ): Promise<VideoSourceConfigurationOptions>;
        getVideoSourceConfigurations(
            options?: GetVideoSourceConfigurations,
        ): Promise<VideoSourceConfiguration[]>;
        getVideoSourceModes(
            options?: GetVideoSourceModes,
        ): Promise<VideoSourceMode[]>;
        getWebRTCConfigurations(): Promise<WebRTCConfiguration[]>;
        removeConfiguration(options: RemoveConfigurationExtended): Promise<void>;
        request<T = any>(
            body: OnvifSoapBody,
            options?: LineraseOptions,
        ): Promise<T>;
        setAudioDecoderConfiguration(
            configuration: AudioDecoderConfiguration,
        ): Promise<void>;
        setAudioEncoderConfiguration(
            configuration: AudioEncoder2Configuration,
        ): Promise<void>;
        setAudioOutputConfiguration(
            configuration: AudioOutputConfigurationExtended,
        ): Promise<void>;
        setAudioSourceConfiguration(
            configuration: AudioSourceConfiguration,
        ): Promise<void>;
        setMask(options: Mask): Promise<void>;
        setMetadataConfiguration(
            configuration: MetadataConfiguration,
        ): Promise<void>;
        setOSD(options: OSDConfiguration): Promise<void>;
        setSynchronizationPoint(options?: SetSynchronizationPoint): Promise<void>;
        setVideoEncoderConfiguration(
            configuration: VideoEncoder2Configuration,
        ): Promise<void>;
        setVideoSourceConfiguration(
            configuration: VideoSourceConfiguration,
        ): Promise<void>;
        setVideoSourceMode(options: SetVideoSourceMode): Promise<void>;
        startMulticastStreaming(
            profileToken?: StartMulticastStreaming,
        ): Promise<void>;
        stopMulticastStreaming(
            profileToken?: StopMulticastStreaming,
        ): Promise<void>;
    }

    Hierarchy (View Summary)

    Index
    onvif: Onvif
    service: keyof OnvifServices
    xmlns: string
    • This operation adds one or more Configurations to an existing media profile. If a configuration exists in the media profile, it will be replaced. A device shall support adding a compatible Configuration to a Profile containing a VideoSourceConfiguration and shall support streaming video data of such a profile.

      Note that OSD elements must be added via the CreateOSD command.

      Parameters

      • options: AddConfigurationExtended
        • Optionalconfiguration?: ConfigurationRefExtended[]

          List of configurations to be added. The types shall be provided in the order defined by tr2:ConfigurationEnumeration. List entries with tr2:ConfigurationEnumeration value "All" shall be ignored.

        • Optionalname?: string

          Optional item. If present updates the Name property of the profile.

        • OptionalprofileToken?: string

          Reference to the profile where the configuration should be added

      Returns Promise<void>

    • Create the Mask.

      Parameters

      Returns Promise<string>

      Token of the newly created mask

      const token = await cam.media2.createMask({
      type: 'Color',
      token: 'mask_token_1',
      color: { x: 1, y: 2, z: 3, colorspace: 'http://www.onvif.org/ver10/colorspace/YCbCr' },
      configurationToken: 'VideoSourceConfigurationToken_1',
      enabled: true,
      polygon: {
      point: [{ x: 0.1, y: 0.1 }, { x: 0.2, y: 0.2 }, { x: 0.3, y: 0.3 }],
      }
      });
    • Create the OSD. NB!: Unlike the reference implementation, this method returns the generated token, since not all implementations allow you to specify the token yourself; it is often generated on the server side.

      Parameters

      Returns Promise<string>

      Token of the newly created OSD

    • This operation creates a new media profile. A created profile created via this method may be deleted via the DeleteProfile method. Optionally Configurations can be assigned to the profile on creation. For details regarding profile assignment check also the method AddConfiguration.

      Parameters

      • options: CreateProfileExtended
        • Optionalconfiguration?: ConfigurationRefExtended[]

          Optional set of configurations to be assigned to the profile. List entries with tr2:ConfigurationEnumeration value "All" shall be ignored.

        • name: string

          friendly name of the profile to be created

      Returns Promise<string>

    • This operation deletes a profile. The device shall support the deletion of a media profile through the DeletePro- file command. A device signaling support for MultiTrackStreaming shall support deleting of virtual profiles via the command. Note that deleting a profile of a virtual profile set may invalidate the virtual profile.

      Parameters

      • options: DeleteProfile
        • token: string

          This element contains a reference to the profile that should be deleted.

      Returns Promise<void>

    • The getAnalyticsConfigurations operation allows to retrieve the analytics settings of one ore more configurations.

      • If a configuration token is provided the device shall respond with the requested configuration or provide an error if it does not exist.
      • In case only a profile token is provided the device shall respond with all configurations that are compatible to the provided media profile.
      • If no tokens are provided the device shall respond with all available configurations.

      Parameters

      • Optionaloptions: GetAnalyticsConfigurations
        • OptionalconfigurationToken?: string

          Token of the requested configuration.

        • OptionalprofileToken?: string

          Contains the token of an existing media profile the configurations shall be compatible with.

      Returns Promise<VideoAnalyticsConfiguration[]>

    • The getAudioDecoderConfigurations operation allows to retrieve the audio decoder settings of one ore more configurations.

      • If a configuration token is provided the device shall respond with the requested configuration or provide an error if it does not exist.
      • In case only a profile token is provided the device shall respond with all configurations that are compatible to the provided media profile.
      • If no tokens are provided the device shall respond with all available configurations.

      Parameters

      • Optionaloptions: GetAudioDecoderConfigurations
        • OptionalconfigurationToken?: string

          Token of the requested configuration.

        • OptionalprofileToken?: string

          Contains the token of an existing media profile the configurations shall be compatible with.

      Returns Promise<AudioDecoderConfiguration[]>

    • The getAudioEncoderConfigurations operation allows to retrieve the audio encoder settings of one ore more configurations.

      • If a configuration token is provided the device shall respond with the requested configuration or provide an error if it does not exist.
      • In case only a profile token is provided the device shall respond with all configurations that are compatible to the provided media profile.
      • If no tokens are provided the device shall respond with all available configurations.

      Parameters

      • Optionaloptions: GetAudioEncoderConfigurations
        • OptionalconfigurationToken?: string

          Token of the requested configuration.

        • OptionalprofileToken?: string

          Contains the token of an existing media profile the configurations shall be compatible with.

      Returns Promise<AudioEncoder2Configuration[]>

    • This operation returns the available options (supported values and ranges for audio output configuration parameters) for configuring an audio output. To retrieve the EQPresetList, a valid ConfigurationToken must be provided. If EQPreset is supported and isFrequencyDecibelEditable is signaled as true, the response shall include the FrequencyDecibelPair.

      Parameters

      Returns Promise<AudioOutputConfigurationOptions>

    • The getAudioOutputConfigurations operation allows to retrieve the audio output settings of one ore more configurations.

      • If a configuration token is provided the device shall respond with the requested configuration or provide an error if it does not exist.
      • In case only a profile token is provided the device shall respond with all configurations that are compatible to the provided media profile.
      • If no tokens are provided the device shall respond with all available configurations.

      Parameters

      • Optionaloptions: GetAudioOutputConfigurations
        • OptionalconfigurationToken?: string

          Token of the requested configuration.

        • OptionalprofileToken?: string

          Contains the token of an existing media profile the configurations shall be compatible with.

      Returns Promise<AudioOutputConfigurationExtended[]>

    • This operation returns the available options (supported values and ranges for audio source configuration parameters) when the audio source parameters are reconfigured. If an audio source configuration is specified, the options shall concern that particular configuration. If a media profile is specified, the options shall be compatible with that media profile.

      Parameters

      Returns Promise<AudioSourceConfigurationOptions>

    • The getAudioSourceConfigurations operation allows to retrieve the audio source settings of one ore more configurations.

      • If a configuration token is provided the device shall respond with the requested configuration or provide an error if it does not exist.
      • In case only a profile token is provided the device shall respond with all configurations that are compatible to the provided media profile.
      • If no tokens are provided the device shall respond with all available configurations.

      Parameters

      • Optionaloptions: GetAudioSourceConfigurations
        • OptionalconfigurationToken?: string

          Token of the requested configuration.

        • OptionalprofileToken?: string

          Contains the token of an existing media profile the configurations shall be compatible with.

      Returns Promise<AudioSourceConfiguration[]>

    • This operation lists existing Mask configurations for the device.

      • If an Mask token is provided the device shall respond with the requested configuration or provide an error if it does not exist.
      • In case only a video source configuration token is provided the device shall respond with all configurations that exist for the video source configuration.
      • If no tokens are provided the device shall respond with all available Mask configurations.

      Parameters

      Returns Promise<Mask[]>

    • The getMetadataConfigurations operation allows to retrieve the metadata settings of one ore more configurations.

      • If a configuration token is provided the device shall respond with the requested configuration or provide an error if it does not exist.
      • In case only a profile token is provided the device shall respond with all configurations that are compatible to the provided media profile.
      • If no tokens are provided the device shall respond with all available configurations.

      Parameters

      • Optionaloptions: GetMetadataConfigurations
        • OptionalconfigurationToken?: string

          Token of the requested configuration.

        • OptionalprofileToken?: string

          Contains the token of an existing media profile the configurations shall be compatible with.

      Returns Promise<MetadataConfiguration[]>

    • This operation lists existing OSD configurations for the device.

      • If an OSD token is provided the device shall respond with the requested configuration or provide an error if it does not exist.
      • In case only a video source configuration token is provided the device shall respond with all configurations that exist for the video source configuration.
      • If no tokens are provided the device shall respond with all available OSD configurations.

      Parameters

      Returns Promise<OSDConfiguration[]>

    • Retrieve the profile with the specified token or all defined media profiles.

      • If no Type is provided the returned profiles shall contain no configuration information.
      • If a single Type with value 'All' is provided the returned profiles shall include all associated configurations.
      • Otherwise the requested list of configurations shall for each profile include the configurations present as Type.

      Parameters

      • options: GetProfiles = {}
        • Optionaltoken?: string

          Optional token of the requested profile.

        • Optionaltype?: string[]

          The types shall be provided as defined by tr2:ConfigurationEnumeration.

      Returns Promise<MediaProfile[]>

    • A client uses the GetSnapshotUri command to obtain a JPEG snapshot from the device. The returned URI shall remain valid indefinitely even if the profile is changed. The URI can be used for acquiring a JPEG image through an HTTP GET operation. The image encoding will always be JPEG regardless of the encoding setting in the media profile. The Jpeg settings (like resolution or quality) may be taken from the profile if suitable. The provided image will be updated automatically and independent from calls to GetSnapshotUri.

      Parameters

      Returns Promise<GetSnapshotUriResponse>

    • This operation requests a URI that can be used to initiate a live media stream using RTSP as the control protocol. The returned URI shall remain valid indefinitely even if the profile is changed.

      Defined stream types are: RtspUnicast RTSP streaming RTP as UDP Unicast. RtspMulticast RTSP streaming RTP as UDP Multicast. RTSP RTSP streaming RTP over TCP. RtspOverHttp Tunneling both the RTSP control channel and the RTP stream over HTTP or HTTPS.

      If a multicast stream is requested at least one of VideoEncoder2Configuration, AudioEncoder2Configuration and MetadataConfiguration shall have a valid multicast setting.

      Parameters

      Returns Promise<GetStreamUriResponse>

    • This operation returns the available options (supported values and ranges for video encoder configuration parameters) when the video encoder parameters are reconfigured.

      This response contains the available video encoder configuration options. If a video encoder configuration is specified, the options shall concern that particular configuration. If a media profile is specified, the options shall be compatible with that media profile. If no tokens are specified, the options shall be considered generic for the device.

      Parameters

      Returns Promise<VideoEncoder2ConfigurationOptions[]>

    • The getVideoEncoderConfigurations operation allows to retrieve the video encoder settings of one ore more configurations.

      • If a configuration token is provided the device shall respond with the requested configuration or provide an error if it does not exist.
      • In case only a profile token is provided the device shall respond with all configurations that are compatible to the provided media profile.
      • If no tokens are provided the device shall respond with all available configurations.

      Parameters

      • Optionaloptions: GetVideoEncoderConfigurations
        • OptionalconfigurationToken?: string

          Token of the requested configuration.

        • OptionalprofileToken?: string

          Contains the token of an existing media profile the configurations shall be compatible with.

      Returns Promise<VideoEncoder2Configuration[]>

    • This operation returns the available options (supported values and ranges for video source configuration parameters) when the video source parameters are reconfigured If a video source configuration is specified, the options shall concern that particular configuration. If a media profile is specified, the options shall be compatible with that media profile.

      Parameters

      Returns Promise<VideoSourceConfigurationOptions>

    • The getVideoSourceConfigurations operation allows to retrieve the video source settings of one ore more configurations.

      • If a configuration token is provided the device shall respond with the requested configuration or provide an error if it does not exist.
      • In case only a profile token is provided the device shall respond with all configurations that are compatible to the provided media profile.
      • If no tokens are provided the device shall respond with all available configurations.

      Parameters

      • Optionaloptions: GetVideoSourceConfigurations
        • OptionalconfigurationToken?: string

          Token of the requested configuration.

        • OptionalprofileToken?: string

          Contains the token of an existing media profile the configurations shall be compatible with.

      Returns Promise<VideoSourceConfiguration[]>

    • Protected Experimental

      The getWebRTCConfigurations operation allows to retrieve the WebRTC settings of one ore more configurations.

      • If a configuration token is provided the device shall respond with the requested configuration or provide an error if it does not exist.
      • In case only a profile token is provided the device shall respond with all configurations that are compatible to the provided media profile.
      • If no tokens are provided the device shall respond with all available configurations. Specs not ready yet, this method is for the future development

      Returns Promise<WebRTCConfiguration[]>

    • This operation removes one or more configurations from an existing media profile. Tokens appearing in the configuration list shall be ignored. Presence of the "All" type shall result in an empty profile. Removing a non-existing configuration shall be ignored and not result in an error. A device supporting the Media2 service shall support this command

      Parameters

      • options: RemoveConfigurationExtended
        • Optionalconfiguration?: ConfigurationRefExtended[]

          List of configurations to be removed. The types shall be provided in the order defined by tr2:ConfigurationEnumeration. Tokens appearing in the configuration list shall be ignored. Presence of the "All" type shall result in an empty profile.

        • OptionalprofileToken?: string

          This element contains a reference to the media profile from which the configuration shall be removed.

      Returns Promise<void>

    • This operation modifies an audio encoder configuration. Running streams using this configuration may be immediately updated according to the new settings. The changes are not guaranteed to take effect unless the client requests a new stream URI and restarts any affected streams. NVC methods for changing a running stream are out of scope for this specification.

      Parameters

      Returns Promise<void>

    • This operation modifies an audio source configuration. Running streams using this configuration may be immediately updated according to the new settings. The changes are not guaranteed to take effect unless the client requests a new stream URI and restarts any affected stream NVC methods for changing a running stream are out of scope for this specification.

      Parameters

      Returns Promise<void>

    • This operation modifies a metadata configuration. Running streams using this configuration may be updated immediately according to the new settings. The changes are not guaranteed to take effect unless the client requests a new stream URI and restarts any affected streams. NVC methods for changing a running stream are out of scope for this specification.

      Parameters

      Returns Promise<void>

    • Synchronization points allow clients to decode and correctly use all data after the synchronization point. For example, if a video stream is configured with a large I-frame distance and a client loses a single packet, the client does not display video until the next I-frame is transmitted. In such cases, the client can request a Synchronization Point which enforces the device to add an I-Frame as soon as possible. Clients can request Synchronization Points for profiles. The device shall add synchronization points for all streams associated with this profile. Similarly, a synchronization point is used to get an update on full PTZ or event status through the metadata stream. If a video stream is associated with the profile, an I-frame shall be added to this video stream. If a PTZ metadata stream is associated to the profile, the PTZ position shall be repeated within the metadata stream.

      Parameters

      Returns Promise<void>

    • This operation modifies a video encoder configuration. Running streams using this configuration may be immediately updated according to the new settings. The changes are not guaranteed to take effect unless the client requests a new stream URI and restarts any affected stream. NVC methods for changing a running stream are out of scope for this specification. SessionTimeout is provided as a hint for keeping rtsp session by a device. If necessary the device may adapt parameter values for SessionTimeout elements without returning an error. For the time between keep alive calls the client shall adhere to the timeout value signaled via RTSP.

      Parameters

      Returns Promise<void>

    • This operation modifies a video source configuration. Running streams using this configuration may be immediately updated according to the new settings. The changes are not guaranteed to take effect unless the client requests a new stream URI and restarts any affected stream. NVC methods for changing a running stream are out of scope for this specification.

      Parameters

      Returns Promise<void>

    • SetVideoSourceMode changes the media profile structure relating to video source for the specified video source mode. A device that indicates a capability of VideoSourceModes shall support this command. The behavior after changing the mode is not defined in this specification.

      Parameters

      Returns Promise<void>

    • This command starts multicast streaming using a specified media profile of a device. Streaming continues until StopMulticastStreaming is called for the same Profile. The streaming shall continue after a reboot of the device until a StopMulticastStreaming request is received. The multicast address, port and TTL are configured in the VideoEncoderConfiguration, AudioEncoderConfiguration and MetadataConfiguration respectively.

      Parameters

      Returns Promise<void>