videotoolbox-utils.cpp 4.24 KB
Newer Older
François Grisez's avatar
François Grisez committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
/*
 Mediastreamer2 videotoolbox-utils.h
 Copyright (C) 2018 Belledonne Communications SARL

 This program is free software; you can redistribute it and/or
 modify it under the terms of the GNU General Public License
 as published by the Free Software Foundation; either version 2
 of the License, or (at your option) any later version.

 This program is distributed in the hope that it will be useful,
 but WITHOUT ANY WARRANTY; without even the implied warranty of
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 GNU General Public License for more details.

 You should have received a copy of the GNU General Public License
 along with this program; if not, write to the Free Software
 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
*/

#include <sstream>
21
#include <unordered_map>
François Grisez's avatar
François Grisez committed
22 23 24 25 26 27 28

#include "videotoolbox-utils.h"

using namespace std;

namespace mediastreamer {

29
static unordered_map<OSStatus, string> _errorMsg = {
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62
	{ noErr                                     , "no error"                                },
	{ kCVReturnAllocationFailed                 , "return allocation failed"                },
	{ kVTPropertyNotSupportedErr                , "property not supported"                  },
	{ kVTPropertyReadOnlyErr                    , "read only error"                         },
	{ kVTParameterErr                           , "parameter error"                         },
	{ kVTInvalidSessionErr                      , "invalid session"                         },
	{ kVTAllocationFailedErr		            , "allocation failed"                       },
	{ kVTPixelTransferNotSupportedErr           , "pixel transfer not supported"            },
	{ kVTCouldNotFindVideoDecoderErr            , "could not find video decoder"            },
	{ kVTCouldNotCreateInstanceErr              , "could not create instance"               },
	{ kVTCouldNotFindVideoEncoderErr            , "could not find video encoder"            },
	{ kVTVideoDecoderBadDataErr                 , "bad data"                                },
	{ kVTVideoDecoderUnsupportedDataFormatErr   , "unsupported data format"                 },
	{ kVTVideoDecoderMalfunctionErr             , "decoder malfunction"                     },
	{ kVTVideoEncoderMalfunctionErr             , "encoder mulfunction"                     },
	{ kVTVideoDecoderNotAvailableNowErr         , "decoder not available now"               },
	{ kVTImageRotationNotSupportedErr           , "image rotation not supported"            },
	{ kVTVideoEncoderNotAvailableNowErr         , "encoder not available now"               },
	{ kVTFormatDescriptionChangeNotSupportedErr , "format description change not supported" },
	{ kVTInsufficientSourceColorDataErr         , "insufficient source color data"          },
	{ kVTCouldNotCreateColorCorrectionDataErr   , "could not create color correction data"  },
	{ kVTColorSyncTransformConvertFailedErr     , "color sync transform convert failed"     },
	{ kVTVideoDecoderAuthorizationErr           , "video decoder authorization error"       },
	{ kVTVideoEncoderAuthorizationErr           , "video encoder authorization error"       },
	{ kVTColorCorrectionPixelTransferFailedErr  , "color correction pixel transfer failed"  },
	{ kVTMultiPassStorageIdentifierMismatchErr  , "multi-pass storage identifier mismatch"  },
	{ kVTMultiPassStorageInvalidErr             , "multi-pass storage invalid"              },
	{ kVTFrameSiloInvalidTimeStampErr           , "frame silo invalid timestamp"            },
	{ kVTFrameSiloInvalidTimeRangeErr           , "frame silo invalid time range"           },
	{ kVTCouldNotFindTemporalFilterErr          , "could not find temporal filter"          },
	{ kVTPixelTransferNotPermittedErr           , "pixel transfer not permitted"            },
	{ kVTColorCorrectionImageRotationFailedErr  , "color correction image rotation failed"  },
	{ kVTVideoDecoderRemovedErr                 , "video decoder removed"                   }
63 64
};

François Grisez's avatar
François Grisez committed
65 66
std::string toString(::OSStatus status) {
	ostringstream message;
67 68 69 70 71
	unordered_map<OSStatus, string>::const_iterator it = _errorMsg.find(status);
	if (it != _errorMsg.cend()) {
		message << it->second;
	} else {
		message << "unknown error";
François Grisez's avatar
François Grisez committed
72
	}
73
	message << " [osstatus=" << status << "]";
François Grisez's avatar
François Grisez committed
74 75 76 77
	return message.str();
}

} // namespace mediastreamer