{"version":3,"file":"decoder-client-DU0ZCYQu.mjs","names":[],"sources":["../src/video/decoder/decoder-client.ts"],"sourcesContent":["/* SPDX-FileCopyrightText: 2026 Espressif Systems (Shanghai) CO LTD */\n/* SPDX-License-Identifier: Apache-2.0 */\n\nimport {\n  callServiceFunction,\n  closeService,\n  isServiceAvailable,\n  openService,\n  resolveHost,\n  type ServiceClientOptions,\n  type ServiceHandle,\n} from '../../common/service-rpc.ts';\nimport type { VideoDecoderConfig, VideoDecoderFrame } from './decoder-types.ts';\n\n/** Default registered name (`helper::VideoDecoder<0>::get_name()`). */\nexport const VIDEO_DECODER_DEFAULT_SERVICE_NAME = 'VideoDecoder0';\n\n/** RPC function names (`helper::Video::DecoderFunctionId`). */\nexport const VIDEO_DECODER_FUNCTIONS = {\n  Open: 'Open',\n  Close: 'Close',\n  Start: 'Start',\n  Stop: 'Stop',\n  FeedFrame: 'FeedFrame',\n} as const;\n\nexport type VideoDecoderClientOptions = ServiceClientOptions & {\n  /** Override service instance name (default `VideoDecoder0`). */\n  serviceName?: string;\n};\n\nexport { type ServiceHandle as VideoDecoderHandle };\n\nfunction resolveServiceName(options?: VideoDecoderClientOptions): string {\n  return options?.serviceName ?? VIDEO_DECODER_DEFAULT_SERVICE_NAME;\n}\n\nexport function isVideoDecoderAvailable(options?: VideoDecoderClientOptions): boolean {\n  return isServiceAvailable(resolveServiceName(options), options);\n}\n\nexport function openVideoDecoder(options?: VideoDecoderClientOptions): ServiceHandle {\n  return openService(resolveServiceName(options), options);\n}\n\nexport function closeVideoDecoder(\n  handle: ServiceHandle,\n  options?: VideoDecoderClientOptions,\n): void {\n  closeService(handle, options);\n}\n\nfunction callVideoDecoder<T>(\n  handle: ServiceHandle,\n  functionName: string,\n  params: Record<string, unknown>,\n  options?: VideoDecoderClientOptions,\n): T {\n  return callServiceFunction<T>(resolveHost(options), handle, functionName, params);\n}\n\nexport function openDecoder(\n  handle: ServiceHandle,\n  config: VideoDecoderConfig,\n  options?: VideoDecoderClientOptions,\n): void {\n  callVideoDecoder<void>(handle, VIDEO_DECODER_FUNCTIONS.Open, { Config: config }, options);\n}\n\nexport function closeDecoder(handle: ServiceHandle, options?: VideoDecoderClientOptions): void {\n  callVideoDecoder<void>(handle, VIDEO_DECODER_FUNCTIONS.Close, {}, options);\n}\n\nexport function startDecoder(handle: ServiceHandle, options?: VideoDecoderClientOptions): void {\n  callVideoDecoder<void>(handle, VIDEO_DECODER_FUNCTIONS.Start, {}, options);\n}\n\nexport function stopDecoder(handle: ServiceHandle, options?: VideoDecoderClientOptions): void {\n  callVideoDecoder<void>(handle, VIDEO_DECODER_FUNCTIONS.Stop, {}, options);\n}\n\nexport function feedDecoderFrame(\n  handle: ServiceHandle,\n  frame: VideoDecoderFrame,\n  options?: VideoDecoderClientOptions,\n): void {\n  callVideoDecoder<void>(handle, VIDEO_DECODER_FUNCTIONS.FeedFrame, { Frame: frame }, options);\n}\n"],"mappings":";;;AAeA,MAAa,qCAAqC;;AAGlD,MAAa,0BAA0B;CACrC,MAAM;CACN,OAAO;CACP,OAAO;CACP,MAAM;CACN,WAAW;AACb;AASA,SAAS,mBAAmB,SAA6C;CACvE,OAAO,SAAS,eAAA;AAClB;AAEA,SAAgB,wBAAwB,SAA8C;CACpF,OAAO,mBAAmB,mBAAmB,OAAO,GAAG,OAAO;AAChE;AAEA,SAAgB,iBAAiB,SAAoD;CACnF,OAAO,YAAY,mBAAmB,OAAO,GAAG,OAAO;AACzD;AAEA,SAAgB,kBACd,QACA,SACM;CACN,aAAa,QAAQ,OAAO;AAC9B;AAEA,SAAS,iBACP,QACA,cACA,QACA,SACG;CACH,OAAO,oBAAuB,YAAY,OAAO,GAAG,QAAQ,cAAc,MAAM;AAClF;AAEA,SAAgB,YACd,QACA,QACA,SACM;CACN,iBAAuB,QAAQ,wBAAwB,MAAM,EAAE,QAAQ,OAAO,GAAG,OAAO;AAC1F;AAEA,SAAgB,aAAa,QAAuB,SAA2C;CAC7F,iBAAuB,QAAQ,wBAAwB,OAAO,CAAC,GAAG,OAAO;AAC3E;AAEA,SAAgB,aAAa,QAAuB,SAA2C;CAC7F,iBAAuB,QAAQ,wBAAwB,OAAO,CAAC,GAAG,OAAO;AAC3E;AAEA,SAAgB,YAAY,QAAuB,SAA2C;CAC5F,iBAAuB,QAAQ,wBAAwB,MAAM,CAAC,GAAG,OAAO;AAC1E;AAEA,SAAgB,iBACd,QACA,OACA,SACM;CACN,iBAAuB,QAAQ,wBAAwB,WAAW,EAAE,OAAO,MAAM,GAAG,OAAO;AAC7F"}