/// <summary> /// Constructs a new FilterEventArgs. /// </summary> /// <param name="cache"> /// The IObservableCache object that fired the event /// </param> /// <param name="type"> /// This event's type. /// </param> /// <param name="key"> /// The key into the cache. /// </param> /// <param name="valueOld"> /// The old value. /// </param> /// <param name="valueNew"> /// The new value. /// </param> /// <param name="isSynthetic"> /// <b>true</b> if the event is caused by the cache internal /// processing such as eviction or loading. /// </param> /// <param name="transformState"> /// The TransformationState state describing /// how this event has been or should be transformed. /// </param> /// <param name="filters"> /// An array of filters that caused this event. /// </param> /// <since>Coherence 3.7.1.9</since> public FilterEventArgs(IObservableCache cache, CacheEventType type, object key, object valueOld, object valueNew, bool isSynthetic, TransformationState transformState, IFilter[] filters) : base(cache, type, key, valueOld, valueNew, isSynthetic) { Debug.Assert(filters != null); m_filters = filters; m_event = null; m_transformState = transformState; }
/// <summary> /// Constructs a new CacheEventArgs. /// </summary> /// <param name="source"> /// The <see cref="IObservableCache"/> object that fired the /// event. /// </param> /// <param name="eventType"> /// This event's type, one of <see cref="CacheEventType"/> /// values. /// </param> /// <param name="key"> /// The key into the cache. /// </param> /// <param name="valueOld"> /// The old value (for update and delete events). /// </param> /// <param name="valueNew"> /// The new value (for insert and update events). /// </param> /// <param name="isSynthetic"> /// <b>true</b> if the event is caused by the cache internal /// processing such as eviction or loading. /// </param> /// <param name="transformState"> /// <b>true</b> if the event is a priming event. /// has been or should be transformed. /// </param> /// <param name="isPriming"> /// <b>true</b> if the event is a priming event. /// </param> public CacheEventArgs(IObservableCache source, CacheEventType eventType, object key, object valueOld, object valueNew, bool isSynthetic, TransformationState transformState, bool isPriming) { m_source = source; m_eventType = eventType; m_key = key; m_valueOld = valueOld; m_valueNew = valueNew; m_isSynthetic = isSynthetic; m_transformState = transformState; m_isPriming = isPriming; }
public void Pop() { if (_stack.Count == 0) { Init(); return; } _stack.Pop(); var peek = _stack.Peek(); State = peek; Matrix = peek.Transformation; }
public void ClickChangeTransformationState(TransformationState newState) { bool rotationBoxRigActiveOld = transformationState == TransformationState.Rotate; bool scaleBoxRigActiveOld = transformationState == TransformationState.Scale; if (newState == transformationState) { // clicking again on the same sidebar button just toggles it off newState = TransformationState.None; } transformationState = newState; HoloUtilities.SetButtonState(ButtonTranslate, newState == TransformationState.Translate); HoloUtilities.SetButtonState(ButtonRotate, newState == TransformationState.Rotate); HoloUtilities.SetButtonState(ButtonScale, newState == TransformationState.Scale); // if transform the model: disable clipping plane manipulator if (newState != TransformationState.None && ModelClipPlaneCtrl.ClippingPlaneState != ModelClippingPlaneControl.ClipPlaneState.Disabled) { ModelClipPlaneCtrl.ClippingPlaneState = ModelClippingPlaneControl.ClipPlaneState.Active; } // turn on/off translation manipulation handDraggable.enabled = newState == TransformationState.Translate; handDraggable.IsDraggingEnabled = newState == TransformationState.Translate; // turn on/off rotation manipulation /* * We do not switch BoundingBoxRig enabled now. * It would serve no purpose (calling Activate or Deactivate is enough), * and it woud actually break Activate (because you cannot call Activate in the same * frame as setting enabled=true for the 1st frame, this causes problems in BoundingBoxRig * as private "objectToBound" is only assigned in BoundingBoxRig.Start). * * rotationBoxRig.enabled = newState == TransformationState.Rotate; */ // call rotationBoxRig.Activate or Deactivate bool rotationBoxRigActiveNew = newState == TransformationState.Rotate; if (rotationBoxRigActiveOld != rotationBoxRigActiveNew && rotationBoxRig != null) { if (rotationBoxRigActiveNew) { rotationBoxRig.GetComponent <BoundingBoxRig>().Activate(); } else { rotationBoxRig.GetComponent <BoundingBoxRig>().Deactivate(); } } /* As with rotationBoxRig, note that you cannot toggle enabled below. * For now, GetComponent<BoundingBoxRig>() is just enabled all the time. */ bool scaleBoxRigActiveNew = newState == TransformationState.Scale; if (scaleBoxRigActiveOld != scaleBoxRigActiveNew) { if (scaleBoxRigActiveNew) { GetComponent <TwoHandManipulatable>().enabled = true; } else { GetComponent <TwoHandManipulatable>().enabled = false; } } }
static extern void VideoDriver_SetTransform(IntPtr videodriver, TransformationState state, float[] mat);
static extern void VideoDriver_GetTransform(IntPtr videodriver, TransformationState state, [MarshalAs(UnmanagedType.LPArray)] float[] mat);
public void SetTransform(TransformationState state, Matrix4 mat) { VideoDriver_SetTransform(_raw, state, mat.ToUnmanaged()); }
public Matrix4 GetTransform(TransformationState state) { float[] mat = new float[16]; VideoDriver_GetTransform(_raw, state, mat); return Matrix4.FromUnmanaged(mat); }
public void ChangeTransformationState(TransformationState newState) { bool rotationBoxRigActiveOld = transformationState == TransformationState.Rotate; bool scaleBoxRigActiveOld = transformationState == TransformationState.Scale; if (newState == transformationState) { // clicking again on the same sidebar button just toggles it off newState = TransformationState.None; } transformationState = newState; HoloUtilities.SetButtonState(ButtonTranslate, newState == TransformationState.Translate); HoloUtilities.SetButtonState(ButtonRotate, newState == TransformationState.Rotate); HoloUtilities.SetButtonState(ButtonScale, newState == TransformationState.Scale); // if transform the model: disable clipping plane manipulator if (newState != TransformationState.None && ModelClipPlaneCtrl.ClippingPlaneState != ModelClippingPlaneControl.ClipPlaneState.Disabled) { ModelClipPlaneCtrl.ClippingPlaneState = ModelClippingPlaneControl.ClipPlaneState.Active; } if (newState == TransformationState.Translate) { GetComponent <ObjectManipulator>().enabled = true; } else { GetComponent <ObjectManipulator>().enabled = false; } bool rotationBoxRigActiveNew = newState == TransformationState.Rotate; if (rotationBoxRigActiveOld != rotationBoxRigActiveNew && rotationBoxRig != null) { if (rotationBoxRigActiveNew) { rotationBoxRig.GetComponent <BoundsControl>().Active = true; rotationBoxRig.GetComponent <RotationAxisConstraint>().ConstraintOnRotation = AxisFlags.XAxis | AxisFlags.ZAxis; rotationBoxRig.GetComponent <MinMaxScaleConstraint>().enabled = true; } } /* As with rotationBoxRig, note that you cannot toggle enabled below. * For now, GetComponent<BoundingBoxRig>() is just enabled all the time. */ bool scaleBoxRigActiveNew = newState == TransformationState.Scale; if (scaleBoxRigActiveOld != scaleBoxRigActiveNew) { if (scaleBoxRigActiveNew) { rotationBoxRig.GetComponent <BoundsControl>().Active = true; rotationBoxRig.GetComponent <RotationAxisConstraint>().ConstraintOnRotation = AxisFlags.XAxis | AxisFlags.YAxis | AxisFlags.ZAxis; rotationBoxRig.GetComponent <MinMaxScaleConstraint>().enabled = false; } } if (!rotationBoxRigActiveNew && !scaleBoxRigActiveNew && rotationBoxRig != null) { rotationBoxRig.GetComponent <BoundsControl>().Active = false; } }
public void TranscodeAudio(SourceMedia sourceMedia, TargetMedia targetMedia, TrimConfig trimConfig, TransformationState transformationState) { if (targetMedia.targetFile.Exists()) { targetMedia.targetFile.Delete(); } transformationState.requestId = UUID.RandomUUID().ToString(); /* MediaTransformationListener transformationListener = new MediaTransformationListener(context, transformationState.requestId, transformationState, targetMedia); */ MediaRange mediaRange = trimConfig.enabled ? new MediaRange( TimeUnit.Milliseconds.ToMicros((long)(trimConfig.range[0] * 1000)), TimeUnit.Milliseconds.ToMicros((long)(trimConfig.range[1] * 1000))) : new MediaRange(0, long.MaxValue); try { var targetMimeType = targetMedia.writeToWav ? "audio/raw" : "audio/mp4a-latm"; IMediaTarget mediaTarget; if (targetMedia.writeToWav) { mediaTarget = new WavMediaTarget(targetMedia.targetFile.Path); } else { mediaTarget = new MediaMuxerMediaTarget(targetMedia.targetFile.Path, 1, 0, (int)MuxerOutputType.Mpeg4); } var mediaSource = new MediaExtractorMediaSource(context, sourceMedia.uri, mediaRange); List<TrackTransform> trackTransforms = new List<TrackTransform>(1); foreach (TargetTrack targetTrack in targetMedia.tracks) { if (targetTrack.format is AudioTrackFormat trackFormat) { MediaFormat mediaFormat = MediaFormat.CreateAudioFormat( targetMimeType, trackFormat.samplingRate, trackFormat.channelCount); mediaFormat.SetInteger(MediaFormat.KeyBitRate, trackFormat.bitrate); mediaFormat.SetLong(MediaFormat.KeyDuration, trackFormat.duration); IEncoder encoder; if (targetMedia.writeToWav) { encoder = new PassthroughBufferEncoder(8192); } else { encoder = new MediaCodecEncoder(); } //IEncoder encoder = targetMedia.writeToWav ? new PassthroughBufferEncoder(8192) : new MediaCodecEncoder(); TrackTransform trackTransform = new TrackTransform.Builder(mediaSource, targetTrack.sourceTrackIndex, mediaTarget) .SetTargetTrack(0) .SetDecoder(new MediaCodecDecoder()) .SetEncoder(encoder) .SetRenderer(new AudioRenderer(encoder)) .SetTargetFormat(mediaFormat) .Build(); trackTransforms.Add(trackTransform); break; } } _mediaTransformer.Transform( transformationState.requestId, trackTransforms, this, MediaTransformer.GranularityDefault); } catch (System.Exception err) { System.Diagnostics.Debug.WriteLine($"Exception when trying to transcode audio: {err.Message}"); } }
void ApplyWatermark(SourceMedia sourceMedia, TargetMedia targetMedia, TrimConfig trimConfig, TransformationState transformationState) { if (targetMedia.targetFile.Exists()) { targetMedia.targetFile.Delete(); } transformationState.requestId = UUID.RandomUUID().ToString(); /* MediaTransformationListener transformationListener = new MediaTransformationListener(this, transformationState.requestId, transformationState, targetMedia); */ var resourceId = Resource.Drawable.test_image_1; var watermarkUri = new Uri.Builder() .Scheme(ContentResolver.SchemeAndroidResource) .Authority(Resources.GetResourcePackageName(resourceId)) .AppendPath(Resources.GetResourceTypeName(resourceId)) .AppendPath(Resources.GetResourceEntryName(resourceId)) .Build(); List<IGlFilter> watermarkImageFilter = null; foreach (TargetTrack targetTrack in targetMedia.tracks) { if (targetTrack is TargetVideoTrack targetVideoTrack) { targetVideoTrack.overlay = watermarkUri; watermarkImageFilter = createGlFilters( sourceMedia, (TargetVideoTrack)targetTrack, 0.2f, new PointF(0.8f, 0.8f), 0); break; } } MediaRange mediaRange = trimConfig.enabled ? new MediaRange( TimeUnit.Milliseconds.ToMicros((long)(trimConfig.range[0] * 1000)), TimeUnit.Milliseconds.ToMicros((long)(trimConfig.range[1] * 1000))) : new MediaRange(0, long.MaxValue); TransformationOptions transformationOptions = new TransformationOptions.Builder() .SetGranularity(MediaTransformer.GranularityDefault) .SetVideoFilters(watermarkImageFilter) .SetSourceMediaRange(mediaRange) .Build(); _mediaTransformer.Transform( _transformationState.requestId, _sourceMedia.uri, targetMedia.targetFile.Path, null, null, this, transformationOptions); }