symba (779893), страница 22
Текст из файла (страница 22)
The aVideoType parameter is used to specify theMIME type of the video codec and the aAudioType parameter is usedto specify the FourCC code of the audio codec. On S60 phones you don’tneed to specify the codec types if you don’t want to (the parameters havedefault NULL values); in this case, the controller chooses for you.
OnUIQ phones, you are required to choose the codec types. Failing to setthe video type results in an error code being returned. Failing to set theaudio type means the recording has no audio.Where multiple codecs are available to choose from, you need tothink about how to handle the choice. You could ask the user to chooseor you could try to make the decision in your application. The choiceof codec depends on a number of factors.
You may want to maintaincompatibility with other devices which, for instance, may not supportmore advanced formats such as the H.264 video format, or you may wantthe high level of compression that H.264 gives to save storage space onthe device. For audio, you may choose the AMR codec, if you know youwill be recording mostly speech, or you may choose a more compatiblegeneral-purpose format, such as AAC.You can choose to record your video into a descriptor buffer:void OpenDesL(TDes8& aDescriptor, TInt aCameraHandle,TUid aControllerUid, TUid aVideoFormat,const TDesC8& aVideoType, TFourCC aAudioType);This has the same parameters as the OpenFileL() methods, exceptthat it takes a descriptor instead of the file name or file handle.You can also choose to stream your video to a specified URL; however,you should note that the majority of Symbian smartphones do not currentlysupport this.void OpenUrlL(const TDesC& aUrl, TInt aIapId, TInt aCameraHandle,TUid aControllerUid, TUid aVideoFormat,const TDesC8& aVideoType, TFourCC aAudioType);You need to specify the URL to stream the recording to and theidentifier for the access point that should be used to connect to the URL.92MULTIMEDIA FRAMEWORK: VIDEOAll the open commands are asynchronous and you must wait for theMvruoOpenComplete() method of your observer to be called beforeproceeding.
If the open operation fails, then the initial API call can leavewith an error or an error code can be passed to the observer method. Youneed to handle both these scenarios when using these APIs.4.11.3 Preparing to RecordOnce the video open operation has completed, you need to prepare tostart the recording by calling the Prepare() method. This allows thevideo controller to allocate the buffers and resources it requires to performthe recording.void Prepare();This is an asynchronous method, and you should wait for the MvruoPrepareComplete() method of your observer to be called beforeproceeding.4.11.4 Starting the RecordingTo start recording the video, you call the Record() method.
This mustbe done after the prepare operation has completed.void Record();This is an asynchronous method. When the recording finishes theMvruoRecordComplete() method of your observer is called. Notehowever that the method is not called if you specifically call Stop() tostop the recording.4.11.5 Pausing the RecordingYou can pause the current recording using PauseL():void PauseL();4.11.6 Stopping the RecordingYou can stop the current recording using Stop():TInt Stop();CONTROLLING THE VIDEO THAT IS RECORDED934.11.7 Closing the Recorded FileAfter the recording has completed or been stopped, you can close the filethat is storing the video:void Close();4.12 Controlling the Video that Is RecordedFrame RateThe frame rate for the recording can be specified using the SetVideoFrameRateL() method.
You can read the current frame rate being usedwith the VideoFrameRateL() method.void SetVideoFrameRateL(TReal32 aFrameRate);TReal32 VideoFrameRateL() const;The frame rate is a floating-point number specifying the number offrames per second.From Symbian OS v9.4 onwards, you can specify whether the framerate is fixed or variable using the SetVideoFrameRateFixedL()method.void SetVideoFrameRateFixedL(TBool aFixedFrameRate);This method indicates to the controller that it should attempt to outputa constant frame rate and it may result in a lower picture quality beingoutput at lower bit rates. You should note that this is only an indicationto the controller that you would like a constant frame rate.
The controllermay not be fully able to meet your request and may still skip someframes.You can check whether the frame rate is fixed using the VideoFrameRateFixedL() method.TBool VideoFrameRateFixedL() const;By default, the frame rate is not fixed, although at higher bit rates thecontroller may be able to output a constant frame rate anyway.94MULTIMEDIA FRAMEWORK: VIDEOFrame SizeYou can specify the frame size for the recording using the SetVideoFrameSizeL() method. You can retrieve the current frame sizeusing the GetVideoFrameSizeL() method.void SetVideoFrameSizeL(const TSize& aSize);void GetVideoFrameSizeL(TSize& aSize) const;DurationYou can get the duration in microseconds of the current video recording:TTimeIntervalMicroSeconds DurationL() const;Bit RateYou can set the video bit rate (in bits per second) that should be used forthe recording using the SetVideoBitRateL() method.
You can readthe current video bit rate using the VideoBitRateL() method.void SetVideoBitRateL(TInt aBitRate);TInt VideoBitRateL();Maximum Clip SizeYou can specify a maximum size for a video recording. This limits therecording size to a maximum number of bytes.void SetMaxClipSizeL(TInt aClipSizeInBytes);If you don’t want to specify a limit, then set the aClipSizeInBytesparameter to KMMFNoMaxClipSize.Recording Time AvailableYou can ask the controller for an indication of how much longer thecurrent video recording can continue using the RecordTimeAvailable() method.
The controller examines the available resources, suchas file space and buffer space, in order to return an estimate of the timeremaining in microseconds.TTimeIntervalMicroSeconds RecordTimeAvailable() const;CONTROLLING THE VIDEO THAT IS RECORDED95Video TypeYou can get a list of the video codecs supported by the currently selectedcontroller using the GetSupportedVideoTypesL() method.void GetSupportedVideoTypesL(CDesC8Array& aVideoTypes) const;This method populates your array of descriptors aVideoTypes withthe names of supported video codecs.
The format of the video types isnot specified. Depending on the controller, the method might return a listof video MIME types or it might return a list of FourCC codes; you needto ensure that you can handle either.Once you have the list of supported video types, you can select theone you want using the SetVideoTypeL() method:void SetVideoTypeL(const TDesC8& aType);Where a controller has found multiple codecs that could be used, itwill already have chosen one that it thinks is suitable. There is no need foryou to change this unless you have a requirement that a specific codecis used.
For some information on how to choose a codec to use, seeSection 4.11.2.Getting MIME TypeYou can get the MIME type of the video format that the controller iscurrently using with the VideoFormatMimeType() method:const TDesC8& VideoFormatMimeType() const;Pixel Aspect RatioThe concept of pixel aspect ratio was first introduced in ‘Scaling’,Section 4.6.4. Pixel aspect ratio is important while recording a video.If you know the aspect ratio of the display that your recorded video willbe shown on, then you can adjust the pixel aspect ratio in order thatthe video scales properly to the display. Typically, Symbian smartphonedisplays use a pixel aspect ratio of 1:1. For TV broadcast signals, highdefinition TV uses 1:1, NTSC uses 10:11 and PAL uses 59:54.If you want to change the pixel aspect ratio used to encode videodata, you can ask the controller for a list of pixel aspect ratios that itsupports.96MULTIMEDIA FRAMEWORK: VIDEOvoid GetSupportedPixelAspectRatiosL(RArray<TVideoAspectRatio>& aAspectRatios) const;This returns an array of TVideoAspectRatio; this class stores twopublic data members, the iNumerator and iDenominator, whichgive the X and Y pixel widths respectively.Given the list of supported ratios, you can then choose which oneyou want.
To set the pixel aspect ratio, you should call the SetPixelAspectRatioL() method and pass the TVideoAspectRatiocontaining your choice.void SetPixelAspectRatioL(const TVideoAspectRatio& aAspectRatio);You can check which pixel aspect ratio is currently being usedby calling the GetPixelAspectRatioL() method which will fill aTVideoAspectRatio passed to it with the correct values:void GetPixelAspectRatioL(TVideoAspectRatio& aAspectRatio) const;Video QualityFrom Symbian OS v9.4, it is possible to control the quality of the outputvideo recording using the SetVideoQualityL() method:void SetVideoQualityL(TInt aQuality);The aQuality parameter is a value from 0 to 100 which defines thequality that you require.