예제 #1
0
        } //END InternalAudioSampleRecieved

        //------------------------------//
        private void CallStopRecordingEvent()
        //------------------------------//
        {

#if NATCORDER
            if( NatCorder.IsRecording )
            {
                if( showDebug ) Debug.Log( "BlockEventRecorder.cs CallStopRecordingEvent() calling NatCorder.StopRecording()" );

                //If we were capturing audio samples from an AudioListener or AudioSource, destroy the AudioGetter.cs helper script attached to it
                if( audioGetter != null )
                {
                    audioGetter.StopRecordingAudio();
                    Destroy( audioGetter );
                    audioGetter = null;
                }

                //Stop the recording and convert the samples into a completed video file
                NatCorder.StopRecording();
                
                if( onActionCompleted != null ) { onActionCompleted.Invoke(); }
            }
#else
            Debug.LogError( "BlockEventRecorder.cs CallStopRecordingEvent() missing NATCORDER scripting define symbol under project settings" );
#endif

        } //END CallStopRecordingEvent
예제 #2
0
        } //END CallStartRecordingBlockEventExternalCamera

        //-------------------------------//
        private void OnRecordingComplete( string path )
        //-------------------------------//
        {
            //If our PersistentDataPath/VideoRecordings path does not exist, create it now
            if( !Directory.Exists( DatabaseStringHelper.CreatePersistentDataPath("VideoRecordings") ) )
            {
                Directory.CreateDirectory( DatabaseStringHelper.CreatePersistentDataPath("VideoRecordings") );
            }

            //Move the recording into the PersistentData folder under the 'VideoRecordings' subfolder
            if ( File.Exists( path ) )
            {
                FileInfo fileInfo = new FileInfo( path );

                if( fileInfo != null )
                {
                    File.Move( path, DatabaseStringHelper.CreatePersistentDataPath("VideoRecordings/" + fileInfo.Name ) );
                    path = DatabaseStringHelper.CreatePersistentDataPath("VideoRecordings/" + fileInfo.Name );
                }
            }

            if( showDebug ) { Debug.Log( "BlockEventRecorder.cs OnRecordingComplete() adding path to list of captured videos = " + path ); }

            //Add our path to our list of recorded videos
            if( recordedVideos == null ) { recordedVideos = new List<string>(); }

            recordedVideos.Add( path );

#if NATCORDER
            //If we were capturing images from a passed in camera, dispose of the cameraRecorder at this time to free up memory
            if( cameraRecorder != null )
            {
                cameraRecorder.Dispose();
                cameraRecorder = null;
            }
#endif

            //If we were capturing audio samples from an AudioListener or AudioSource, destroy the AudioGetter.cs helper script attached to it
            if( audioGetter != null )
            {
                Destroy( audioGetter );
                audioGetter = null;
            }

#if NATCORDER
            //If we were capturing audio from the app, dispose of the audioRecorder at this time
            if( audioRecorder != null )
            {
                audioRecorder.Dispose();
                audioRecorder = null;
            }
#endif

            if( onRecordingCompleted != null ) { onRecordingCompleted.Invoke( path ); }

        } //END OnRecordingComplete
예제 #3
0
        } //END GetVideoFormatForBlockEventExternalCamera
#endif

        //----------------------------------------------//
        private void CallStartRecordingBlockEventExternalCamera()
        //----------------------------------------------//
        {

#if NATCORDER
            //We can only record one source at a time
            if( NatCorder.IsRecording ) { return; }

            //We can only record if the BlockEventExternalCamera is playing
            if( !blockEventExternalCamera.IsPlaying() )
            {
                Debug.LogError( "BlockEventRecorder.cs CallStartRecordingBlockEventExternalCamera() We attempted to record from the attached BlockEventExternalCamera however it is not currently playing a camera stream" );
                return;
            }

            //Tell our recording to begin expecting new frames

            //If our Video Container format is GIF, we cannot allow any kind of audio recording
            if( IsVideoContainerGIF() )
            {
                NatCorder.StartRecording(
                container,
                GetVideoFormatForBlockEventExternalCamera(),
                AudioFormat.None,
                OnRecordingComplete );
            }

            //If we are skipping audio recording, just record video in .MP4 format and skip audio
            else if( IsExtCameraAudioFormatNone() )
            {
                NatCorder.StartRecording(
                container,
                GetVideoFormatForBlockEventExternalCamera(),
                AudioFormat.None,
                OnRecordingComplete );
            }

            //Otherwise our audio should be based on the AudioSource or AudioListener via using the AudioGetter.cs script to grab audio samples
            else
            {
                //If our AudioListener or AudioSource has been setup properly, we can use it to grab audio samples
                if( IsRecordAudioTypeAudioListener() && audioListener != null )
                {
                    NatCorder.StartRecording(
                    container,
                    GetVideoFormatForBlockEventExternalCamera(),
                    new AudioFormat( AudioSettings.outputSampleRate, (int)AudioSettings.speakerMode ),
                    OnRecordingComplete );

                    //Remove any pre-existing audioGetter's
                    if( audioGetter != null )
                    {
                        Destroy( audioGetter );
                        audioGetter = null;
                    }

                    if( audioListener.gameObject.GetComponent<AudioGetter>() != null )
                    {
                        Destroy( audioListener.gameObject.GetComponent<AudioGetter>() );
                    }

                    //Add an AudioGetter to the linked AudioListener to recieve it's audio samples for encoding into the video
                    audioGetter = audioListener.gameObject.AddComponent<AudioGetter>();
                    audioGetter.StartRecordingAudio( this );
                }

                else if( IsRecordAudioTypeAudioSource() && audioSource != null )
                {
                    NatCorder.StartRecording(
                    container,
                    GetVideoFormatForBlockEventExternalCamera(),
                    new AudioFormat( AudioSettings.outputSampleRate, (int)AudioSettings.speakerMode ),
                    OnRecordingComplete );

                    //Remove any pre-existing audioGetter's
                    if( audioGetter != null )
                    {
                        Destroy( audioGetter );
                        audioGetter = null;
                    }

                    if( audioSource.gameObject.GetComponent<AudioGetter>() != null )
                    {
                        Destroy( audioSource.gameObject.GetComponent<AudioGetter>() );
                    }

                    //Add an AudioGetter to the linked AudioSource to recieve it's audio samples for encoding into the video
                    audioGetter = audioSource.gameObject.AddComponent<AudioGetter>();
                    audioGetter.StartRecordingAudio( this );
                }

                //If BlockAudio is selected...
                else if( IsRecordAudioTypeBlockAudio() && blockAudio != null )
                {
                    NatCorder.StartRecording(
                    container,
                    GetVideoFormatForBlockEventExternalCamera(),
                    new AudioFormat( AudioSettings.outputSampleRate, (int)AudioSettings.speakerMode ),
                    OnRecordingComplete );

                    //Remove any pre-existing audioGetter's
                    if( audioGetter != null )
                    {
                        Destroy( audioGetter );
                        audioGetter = null;
                    }

                    if( blockAudio.gameObject.GetComponent<AudioGetter>() != null )
                    {
                        Destroy( blockAudio.gameObject.GetComponent<AudioGetter>() );
                    }

                    //Add an AudioGetter to the linked blockAudio to recieve it's audio samples for encoding into the video
                    audioGetter = blockAudio.gameObject.AddComponent<AudioGetter>();
                    audioGetter.StartRecordingAudio( this );
                }

                //Otherwise set our AudioFormat to None, we do not need to recieve audio samples
                else
                {
                    NatCorder.StartRecording(
                    container,
                    GetVideoFormatForBlockEventExternalCamera(),
                    AudioFormat.None,
                    OnRecordingComplete );
                }
                
            }
            
            //Request the frames from the ExternalCamera, these frames are sent to _ExternalCameraFrameRecieved
            blockEventExternalCamera.RequestFrames( this );
#else
            Debug.LogError( "BlockEventRecorder.cs CallStartRecordingBlockEventExternalCamera() missing NATCORDER scripting define symbol under project settings" );
#endif

        } //END CallStartRecordingBlockEventExternalCamera