IDecoder createDefaultDecoder() { switch (options.outType) { case RemoteVoiceOptions.OutputType.Float: if (Info.Codec == Codec.AudioOpus) { voiceClient.transport.LogInfo(LogPrefix + ": Creating default decoder for output type = " + options.outType); return(new OpusCodec.DecoderFloat(options.output as Action <float[]>, voiceClient.transport)); } else { voiceClient.transport.LogError(LogPrefix + ": Action<float[]> output set for not audio decoder (output type = " + options.outType + ")"); return(null); } case RemoteVoiceOptions.OutputType.Short: if (Info.Codec == Codec.AudioOpus) { voiceClient.transport.LogInfo(LogPrefix + ": Creating default decoder for output type = " + options.outType); return(new OpusCodec.DecoderShort(options.output as Action <short[]>, voiceClient.transport)); } else { voiceClient.transport.LogError(LogPrefix + ": Action<short[]> output set for not audio decoder (output type = " + options.outType + ")"); return(null); } #if PHOTON_VOICE_VIDEO_ENABLE case RemoteVoiceOptions.OutputType.Image: if (Info.Codec == Codec.VideoVP8) { voiceClient.transport.LogInfo(LogPrefix + ": Creating default decoder for output type = " + options.outType); var vd = new VPxCodec.Decoder(options.output as Action <ImageOutputBuf>); if (options.OutputImageFormat != ImageFormat.Undefined) { vd.OutputImageFormat = options.OutputImageFormat; } if (options.OutputImageFlip != Flip.Undefined) { vd.OutputImageFlip = options.OutputImageFlip; } return(vd); } else { voiceClient.transport.LogError(LogPrefix + ": Action<ImageOutputBuf> output set for not video decoder (output type = " + options.outType + ")"); return(null); } #endif case RemoteVoiceOptions.OutputType.None: default: voiceClient.transport.LogError(LogPrefix + ": Output must be set in RemoteVoiceOptions with SetOutput call (output type = " + options.outType + ")"); return(null); } }
static public IVideoPlayer CreateDefaultVideoPlayer(ILogger logger, PreviewManager previewManager, VoiceInfo info) { // native platform-specific players #if UNITY_ANDROID && !UNITY_EDITOR var vd = new Unity.UnityAndroidVideoDecoder(logger, previewManager, info.Codec); return(new VideoPlayer(vd, vd.Preview, info.Width, info.Height)); #elif UNITY_IOS && !UNITY_EDITOR if (info.Codec == Codec.VideoH264) { var vd = new IOS.VideoDecoder(logger); return(new VideoPlayer(vd, vd.Preview, info.Width, info.Height)); } throw new UnsupportedCodecException("Platform.CreateDefaultVideoPlayer", info.Codec, logger); #elif WINDOWS_UWP || (UNITY_WSA && !UNITY_EDITOR) if (info.Codec == Codec.VideoH264) { var vd = new UWP.VideoDecoder(logger, info); return(new VideoPlayer(vd, vd.Preview, info.Width, info.Height)); } throw new UnsupportedCodecException("Platform.CreateDefaultVideoPlayer", info.Codec, logger); #else // multi-platform VideoPlayerUnity or generic VideoPlayer IDecoderQueuedOutputImageNative vd; switch (info.Codec) { case Codec.VideoVP8: case Codec.VideoVP9: vd = new VPxCodec.Decoder(logger); break; #if UNITY_EDITOR_WIN || UNITY_STANDALONE_WIN case Codec.VideoH264: //vd = new FFmpegCodec.Decoder(logger); vd = new Windows.MFTCodec.VideoDecoder(logger, info); break; #elif UNITY_EDITOR_OSX || UNITY_STANDALONE_OSX case Codec.VideoH264: //vd = new FFmpegCodec.Decoder(logger); vd = new MacOS.VideoDecoder(logger, info); break; #endif default: throw new UnsupportedCodecException("Platform.CreateDefaultVideoPlayer", info.Codec, logger); } #if UNITY_5_3_OR_NEWER // #if UNITY var vp = new Unity.VideoPlayerUnity(vd); // assign Draw method copying Image to Unity texture as software decoder Output vd.Output = vp.Draw; return(vp); #else return(new VideoPlayer(vd, null, 0, 0)); #endif #endif }
static public IVideoPlayer CreateDefaultVideoPlayer(ILogger logger, PreviewManager previewManager, VoiceInfo info) { #if UNITY_ANDROID && !UNITY_EDITOR var vd = new Unity.UnityAndroidVideoDecoder(logger, previewManager, info.Codec); return(new VideoPlayer(vd, vd.Preview, info.Width, info.Height)); #elif UNITY_IOS && !UNITY_EDITOR var vd = new IOS.VideoDecoder(logger); return(new VideoPlayer(vd, vd.Preview, info.Width, info.Height)); #elif UNITY_WSA && !UNITY_EDITOR var vd = new UWP.VideoDecoder(logger, info); return(new VideoPlayer(vd, vd.Preview, info.Width, info.Height)); #else IDecoderQueuedOutputImageNative vd; switch (info.Codec) { case Codec.VideoVP8: case Codec.VideoVP9: vd = new VPxCodec.Decoder(logger); break; case Codec.VideoH264: vd = new FFmpegCodec.Decoder(logger); break; default: throw new UnsupportedCodecException("Platform.CreateDefaultVideoDecoder", info.Codec, logger); } #if UNITY_5_3_OR_NEWER // #if UNITY var vp = new Unity.VideoPlayerUnity(vd); // assign Draw method copying Image to Unity texture as software decoder Output vd.Output = vp.Draw; return(vp); #else return(new VideoPlayer(vd, null, 0, 0)); #endif #endif }
IDecoder createDefaultDecoder() { switch (options.outType) { case RemoteVoiceOptions.OutputType.Float: if (Info.Codec == Codec.AudioOpus) { voiceClient.logger.LogInfo(LogPrefix + ": Creating default decoder for output type = " + options.outType); return(new OpusCodec.Decoder <float>(options.output as Action <FrameOut <float> >, voiceClient.logger)); } else if (Info.Codec == Codec.Raw) { voiceClient.logger.LogInfo(LogPrefix + ": Creating default decoder for output type = " + options.outType); return(new RawCodec.Decoder <float>(options.output as Action <FrameOut <float> >)); } else { voiceClient.logger.LogError(LogPrefix + ": Action<float[]> output set for not audio decoder (output type = " + options.outType + ")"); return(null); } case RemoteVoiceOptions.OutputType.Short: if (Info.Codec == Codec.AudioOpus) { voiceClient.logger.LogInfo(LogPrefix + ": Creating default decoder for output type = " + options.outType); return(new OpusCodec.Decoder <short>(options.output as Action <FrameOut <short> >, voiceClient.logger)); } else if (Info.Codec == Codec.Raw) { voiceClient.logger.LogInfo(LogPrefix + ": Creating default decoder for output type = " + options.outType); return(new RawCodec.Decoder <short>(options.output as Action <FrameOut <short> >)); } else { voiceClient.logger.LogError(LogPrefix + ": Action<short[]> output set for not audio decoder (output type = " + options.outType + ")"); return(null); } #if PHOTON_VOICE_VIDEO_ENABLE case RemoteVoiceOptions.OutputType.Image: voiceClient.logger.LogInfo(LogPrefix + ": Creating default decoder for output type = " + options.outType); IDecoderQueuedOutputImageNative vd = null; switch (Info.Codec) { case Codec.VideoVP8: case Codec.VideoVP9: vd = new VPxCodec.Decoder(voiceClient.logger); vd.Output = options.output as Action <ImageOutputBuf>; break; case Codec.VideoH264: //vd = new FFmpegCodec.Decoder(voiceClient.transport); //vd.Output = options.output as Action<ImageOutputBuf>; break; default: voiceClient.logger.LogError(LogPrefix + ": Action<ImageOutputBuf> output set for not video decoder (output type = " + options.outType + ")"); return(null); } if (vd != null && options.OutputImageFormat != ImageFormat.Undefined) { vd.OutputImageFormat = options.OutputImageFormat; } return(vd); #endif case RemoteVoiceOptions.OutputType.None: default: voiceClient.logger.LogError(LogPrefix + ": Output must be set in RemoteVoiceOptions with SetOutput call (output type = " + options.outType + ")"); return(null); } }