VideoFormats.h revision 5abf87f9af48149972eeb851ecaea679911da040
1/* 2 * Copyright 2013, The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17#ifndef VIDEO_FORMATS_H_ 18 19#define VIDEO_FORMATS_H_ 20 21#include <media/stagefright/foundation/ABase.h> 22 23#include <stdint.h> 24 25namespace android { 26 27struct AString; 28 29// This class encapsulates that video resolution capabilities of a wfd source 30// or sink as outlined in the wfd specs. Currently three sets of resolutions 31// are specified, each of which supports up to 32 resolutions. 32// In addition to its capabilities each sink/source also publishes its 33// "native" resolution, presumably one that is preferred among all others 34// because it wouldn't require any scaling and directly corresponds to the 35// display capabilities/pixels. 36struct VideoFormats { 37 VideoFormats(); 38 39 enum ResolutionType { 40 RESOLUTION_CEA, 41 RESOLUTION_VESA, 42 RESOLUTION_HH, 43 kNumResolutionTypes, 44 }; 45 46 void setNativeResolution(ResolutionType type, size_t index); 47 void getNativeResolution(ResolutionType *type, size_t *index) const; 48 49 void disableAll(); 50 void enableAll(); 51 52 void setResolutionEnabled( 53 ResolutionType type, size_t index, bool enabled = true); 54 55 bool isResolutionEnabled(ResolutionType type, size_t index) const; 56 57 static bool GetConfiguration( 58 ResolutionType type, size_t index, 59 size_t *width, size_t *height, size_t *framesPerSecond, 60 bool *interlaced); 61 62 bool parseFormatSpec(const char *spec); 63 AString getFormatSpec(bool forM4Message = false) const; 64 65 static bool PickBestFormat( 66 const VideoFormats &sinkSupported, 67 const VideoFormats &sourceSupported, 68 ResolutionType *chosenType, 69 size_t *chosenIndex); 70 71private: 72 ResolutionType mNativeType; 73 size_t mNativeIndex; 74 75 uint32_t mResolutionEnabled[kNumResolutionTypes]; 76 77 DISALLOW_EVIL_CONSTRUCTORS(VideoFormats); 78}; 79 80} // namespace android 81 82#endif // VIDEO_FORMATS_H_ 83 84