You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

81 lines
3.2 KiB

​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  1. //
  2. // libjingle
  3. // Copyright 2004--2007, Google Inc.
  4. //
  5. // Redistribution and use in source and binary forms, with or without
  6. // modification, are permitted provided that the following conditions are met:
  7. //
  8. // 1. Redistributions of source code must retain the above copyright notice,
  9. // this list of conditions and the following disclaimer.
  10. // 2. Redistributions in binary form must reproduce the above copyright notice,
  11. // this list of conditions and the following disclaimer in the documentation
  12. // and/or other materials provided with the distribution.
  13. // 3. The name of the author may not be used to endorse or promote products
  14. // derived from this software without specific prior written permission.
  15. //
  16. // THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
  17. // WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
  18. // MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
  19. // EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  20. // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
  21. // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
  22. // OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
  23. // WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
  24. // OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
  25. // ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  26. //
  27. #include "talk/examples/call/mediaenginefactory.h"
  28. #include "talk/base/stringutils.h"
  29. #include "talk/media/base/fakemediaengine.h"
  30. #include "talk/media/base/filemediaengine.h"
  31. #include "talk/media/base/mediaengine.h"
  32. std::vector<cricket::AudioCodec> RequiredAudioCodecs() {
  33. std::vector<cricket::AudioCodec> audio_codecs;
  34. audio_codecs.push_back(
  35. cricket::AudioCodec(9, "G722", 16000, 0, 1, 0));
  36. audio_codecs.push_back(
  37. cricket::AudioCodec(0, "PCMU", 8000, 0, 1, 0));
  38. audio_codecs.push_back(
  39. cricket::AudioCodec(13, "CN", 8000, 0, 1, 0));
  40. audio_codecs.push_back(
  41. cricket::AudioCodec(105, "CN", 16000, 0, 1, 0));
  42. return audio_codecs;
  43. }
  44. std::vector<cricket::VideoCodec> RequiredVideoCodecs() {
  45. std::vector<cricket::VideoCodec> video_codecs;
  46. video_codecs.push_back(
  47. cricket::VideoCodec(97, "H264", 320, 240, 30, 0));
  48. video_codecs.push_back(
  49. cricket::VideoCodec(99, "H264-SVC", 640, 360, 30, 0));
  50. return video_codecs;
  51. }
  52. cricket::MediaEngineInterface* MediaEngineFactory::CreateFileMediaEngine(
  53. const char* voice_in, const char* voice_out,
  54. const char* video_in, const char* video_out) {
  55. cricket::FileMediaEngine* file_media_engine = new cricket::FileMediaEngine;
  56. // Set the RTP dump file names.
  57. if (voice_in) {
  58. file_media_engine->set_voice_input_filename(voice_in);
  59. }
  60. if (voice_out) {
  61. file_media_engine->set_voice_output_filename(voice_out);
  62. }
  63. if (video_in) {
  64. file_media_engine->set_video_input_filename(video_in);
  65. }
  66. if (video_out) {
  67. file_media_engine->set_video_output_filename(video_out);
  68. }
  69. // Set voice and video codecs. TODO: The codecs actually depend on
  70. // the the input voice and video streams.
  71. file_media_engine->set_voice_codecs(RequiredAudioCodecs());
  72. file_media_engine->set_video_codecs(RequiredVideoCodecs());
  73. return file_media_engine;
  74. }