llvorbisencode.h 3.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. /**
  2. * @file vorbisencode.h
  3. * @brief Vorbis encoding routine routine for Indra.
  4. *
  5. * $LicenseInfo:firstyear=2000&license=viewergpl$
  6. *
  7. * Copyright (c) 2000-2009, Linden Research, Inc.
  8. *
  9. * Second Life Viewer Source Code
  10. * The source code in this file ("Source Code") is provided by Linden Lab
  11. * to you under the terms of the GNU General Public License, version 2.0
  12. * ("GPL"), unless you have obtained a separate licensing agreement
  13. * ("Other License"), formally executed by you and Linden Lab. Terms of
  14. * the GPL can be found in doc/GPL-license.txt in this distribution, or
  15. * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2
  16. *
  17. * There are special exceptions to the terms and conditions of the GPL as
  18. * it is applied to this Source Code. View the full text of the exception
  19. * in the file doc/FLOSS-exception.txt in this software distribution, or
  20. * online at
  21. * http://secondlifegrid.net/programs/open_source/licensing/flossexception
  22. *
  23. * By copying, modifying or distributing this software, you acknowledge
  24. * that you have read and understood your obligations described above,
  25. * and agree to abide by those obligations.
  26. *
  27. * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
  28. * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
  29. * COMPLETENESS OR PERFORMANCE.
  30. * $/LicenseInfo$
  31. */
  32. #ifndef LL_VORBISENCODE_H
  33. #define LL_VORBISENCODE_H
  34. constexpr S32 LLVORBISENC_NOERR = 0; // No error
  35. constexpr S32 LLVORBISENC_SOURCE_OPEN_ERR = 1; // Error opening source
  36. constexpr S32 LLVORBISENC_DEST_OPEN_ERR = 2; // Error opening dest
  37. constexpr S32 LLVORBISENC_WAV_FORMAT_ERR = 3; // not a WAV
  38. constexpr S32 LLVORBISENC_PCM_FORMAT_ERR = 4; // not a PCM
  39. constexpr S32 LLVORBISENC_MONO_ERR = 5; // Ccannot do mono
  40. constexpr S32 LLVORBISENC_STEREO_ERR = 6; // Cannot do stereo
  41. constexpr S32 LLVORBISENC_MULTICHANNEL_ERR = 7; // Cannot do stereo
  42. constexpr S32 LLVORBISENC_UNSUPPORTED_SAMPLE_RATE = 8; // Unsupported sample rate
  43. constexpr S32 LLVORBISENC_UNSUPPORTED_WORD_SIZE = 9; // Unsupported word size
  44. constexpr S32 LLVORBISENC_CLIP_TOO_LONG = 10; // Src file too long
  45. constexpr S32 LLVORBISENC_CHUNK_SIZE_ERR = 11; // Wrong chunk size
  46. constexpr F32 LLVORBIS_CLIP_MAX_TIME = 30.f;
  47. constexpr U8 LLVORBIS_CLIP_MAX_CHANNELS = 2;
  48. constexpr U32 LLVORBIS_CLIP_SAMPLE_RATE = 44100;
  49. constexpr U32 LLVORBIS_CLIP_MAX_SAMPLES_PER_CHANNEL = (U32)(LLVORBIS_CLIP_MAX_TIME * LLVORBIS_CLIP_SAMPLE_RATE);
  50. constexpr U32 LLVORBIS_CLIP_MAX_SAMPLES = LLVORBIS_CLIP_MAX_SAMPLES_PER_CHANNEL * LLVORBIS_CLIP_MAX_CHANNELS;
  51. constexpr size_t LLVORBIS_CLIP_MAX_SAMPLE_DATA = LLVORBIS_CLIP_MAX_SAMPLES * 2; // 2 = 16-bit
  52. // Treat anything this long as a bad asset. A little fudge factor at the end:
  53. // Make that a lot of fudge factor. We're allowing 30 sec for now - 3x legal upload
  54. constexpr size_t LLVORBIS_CLIP_REJECT_SAMPLES = LLVORBIS_CLIP_MAX_SAMPLES * 3;
  55. constexpr size_t LLVORBIS_CLIP_REJECT_SIZE = LLVORBIS_CLIP_MAX_SAMPLE_DATA * 3;
  56. S32 check_for_invalid_wav_formats(const std::string& in_fname,
  57. std::string& error_msg, F32 max_duration);
  58. S32 encode_vorbis_file(const std::string& in_fname,
  59. const std::string& out_fname, F32 max_duration);
  60. #endif