Exemplo n.º 1
0
void XMH323Connection::OnDecodingVideoFailed(OpalMediaFormat & mediaFormat, INT ignore)
{
  excludedFormats += mediaFormat;
  
  // Request a mode change, use the existing audio / H.224 channels and all available video formats
  PString modePrefix = "";
  OpalMediaStreamPtr audioStream = GetMediaStream(OpalMediaType::Audio(), true);
  OpalMediaStreamPtr h224Stream = GetMediaStream(OpalH224MediaType::MediaType(), true);
  if (audioStream != NULL) {
    modePrefix += audioStream->GetMediaFormat().GetName() + "\t";
  }
  if (h224Stream != NULL) {
    modePrefix += h224Stream->GetMediaFormat().GetName() + "\t";
  }
  PString modes = "";
  OpalMediaFormatList mediaFormats = GetMediaFormats();
  mediaFormats -= excludedFormats;
  for (PINDEX i = 0; i < mediaFormats.GetSize(); i++) {
    const OpalMediaFormat & mediaFormat = mediaFormats[i];
    if (mediaFormat.GetMediaType() == OpalMediaType::Video()) {
      modes += modePrefix + mediaFormat.GetName() + "\n";
    }
  }
  PTRACE(1, "XMH323Con\tRequest mode change since can't decode incoming video stream");
  RequestModeChange(modes);
}
Exemplo n.º 2
0
CodecDescription::CodecDescription (const OpalMediaFormat & _format,
                                    bool _active)
{
  name = (const char *) _format;
  if (name == "G722")  // G722 has the wrong rate in RFC
    rate = 16000;
  else
    rate = _format.GetClockRate ();
  audio = (_format.GetMediaType () == OpalMediaType::Audio ());
  video = (_format.GetMediaType () == OpalMediaType::Video ());
  if (_format.IsValidForProtocol ("SIP"))
    protocols.push_back ("SIP");
  if (_format.IsValidForProtocol ("H.323"))
    protocols.push_back ("H.323");
  protocols.sort ();
  for (PINDEX i = 0 ; KnownCodecs[i][0] ; i++) {
    if (name == KnownCodecs[i][0]) {
      display_name = gettext (KnownCodecs[i][1]);
      display_info = gettext (KnownCodecs[i][2]);
      break;
    }
  }
  if (display_name.empty ())
    display_name = name;

  format = _format;
  active = _active;
}
Exemplo n.º 3
0
PBoolean
CallManager::CreateVideoOutputDevice(const OpalConnection & connection,
                                     const OpalMediaFormat & media_fmt,
                                     PBoolean preview,
                                     PVideoOutputDevice * & device,
                                     PBoolean & auto_delete)
{
  PVideoDevice::OpenArgs videoArgs;
  PString title;

  videoArgs = preview ?
    GetVideoPreviewDevice() : GetVideoOutputDevice();

  if (!preview) {
    unsigned openChannelCount = 0;
    OpalMediaStreamPtr mediaStream;

    while ((mediaStream = connection.GetMediaStream(OpalMediaType::Video(),
                                                    preview, mediaStream)) != NULL)
      ++openChannelCount;

    videoArgs.deviceName += psprintf(" ID=%u", openChannelCount);
  }

  media_fmt.AdjustVideoArgs(videoArgs);

  auto_delete = true;
  device = PVideoOutputDevice::CreateOpenedDevice(videoArgs, false);
  return device != NULL;
}
Exemplo n.º 4
0
void CallManager::set_video_options (const CallManager::VideoOptions & options)
{
  OpalMediaFormatList media_formats_list;
  OpalMediaFormat::GetAllRegisteredMediaFormats (media_formats_list);

  // Configure all mediaOptions of all Video MediaFormats
  for (int i = 0 ; i < media_formats_list.GetSize () ; i++) {

    OpalMediaFormat media_format = media_formats_list [i];
    if (media_format.GetMediaType() == OpalMediaType::Video ()) {

      media_format.SetOptionInteger (OpalVideoFormat::FrameWidthOption (),
                                     Ekiga::VideoSizes [options.size].width);
      media_format.SetOptionInteger (OpalVideoFormat::FrameHeightOption (),
                                     Ekiga::VideoSizes [options.size].height);
      media_format.SetOptionInteger (OpalVideoFormat::FrameTimeOption (),
                                     (int) (90000 / (options.maximum_frame_rate > 0 ? options.maximum_frame_rate : 30)));
      media_format.SetOptionInteger (OpalVideoFormat::MaxBitRateOption (),
                                     (options.maximum_received_bitrate > 0 ? options.maximum_received_bitrate : 4096) * 1000);
      media_format.SetOptionInteger (OpalVideoFormat::TargetBitRateOption (),
                                     (options.maximum_transmitted_bitrate > 0 ? options.maximum_transmitted_bitrate : 48) * 1000);
      media_format.SetOptionInteger (OpalVideoFormat::MinRxFrameWidthOption(),
                                     160);
      media_format.SetOptionInteger (OpalVideoFormat::MinRxFrameHeightOption(),
                                     120);
      media_format.SetOptionInteger (OpalVideoFormat::MaxRxFrameWidthOption(),
                                     1920);
      media_format.SetOptionInteger (OpalVideoFormat::MaxRxFrameHeightOption(),
                                     1088);
      media_format.AddOption(new OpalMediaOptionUnsigned (OpalVideoFormat::TemporalSpatialTradeOffOption (),
                                                          true, OpalMediaOption::NoMerge,
                                                          options.temporal_spatial_tradeoff));
      media_format.SetOptionInteger (OpalVideoFormat::TemporalSpatialTradeOffOption(),
                                     (options.temporal_spatial_tradeoff > 0 ? options.temporal_spatial_tradeoff : 31));
      media_format.AddOption(new OpalMediaOptionUnsigned (OpalVideoFormat::MaxFrameSizeOption (),
                                                          true, OpalMediaOption::NoMerge, 1400));
      media_format.SetOptionInteger (OpalVideoFormat::MaxFrameSizeOption (),
                                     1400);

      if ( media_format.GetName() != "YUV420P" &&
           media_format.GetName() != "RGB32" &&
           media_format.GetName() != "RGB24") {

        media_format.SetOptionInteger (OpalVideoFormat::RateControlPeriodOption(),
                                       300);
      }

      switch (options.extended_video_roles) {
      case 0 :
        media_format.SetOptionInteger(OpalVideoFormat::ContentRoleMaskOption(), 0);
        break;

      case 2 : // Force Presentation (slides)
        media_format.SetOptionInteger(OpalVideoFormat::ContentRoleMaskOption(),
                                      OpalVideoFormat::ContentRoleBit(OpalVideoFormat::ePresentation));
        break;

      case 3 : // Force Live (main)
        media_format.SetOptionInteger(OpalVideoFormat::ContentRoleMaskOption(),
                                      OpalVideoFormat::ContentRoleBit(OpalVideoFormat::eMainRole));
        break;

        default :
          break;
      }

      OpalMediaFormat::SetRegisteredMediaFormat(media_format);
    }
  }

  // Adjust setting for all sessions of all connections of all calls
  for (PSafePtr<OpalCall> call = activeCalls;
       call != NULL;
       ++call) {

    for (int i = 0;
         i < 2;
         i++) {

      PSafePtr<OpalRTPConnection> connection = PSafePtrCast<OpalConnection, OpalRTPConnection> (call->GetConnection (i));
      if (connection) {

        OpalMediaStreamPtr stream = connection->GetMediaStream (OpalMediaType::Video (), false);
        if (stream != NULL) {

          OpalMediaFormat mediaFormat = stream->GetMediaFormat ();
          mediaFormat.SetOptionInteger (OpalVideoFormat::TemporalSpatialTradeOffOption(),
                                        (options.temporal_spatial_tradeoff > 0 ? options.temporal_spatial_tradeoff : 31));
          mediaFormat.SetOptionInteger (OpalVideoFormat::TargetBitRateOption (),
                                        (options.maximum_transmitted_bitrate > 0 ? options.maximum_transmitted_bitrate : 48) * 1000);
          mediaFormat.ToNormalisedOptions();
          stream->UpdateMediaFormat (mediaFormat);
        }
      }
    }
  }
}
Exemplo n.º 5
0
void CallManager::set_video_options (const CallManager::VideoOptions & options)
{
  OpalMediaFormatList media_formats_list;
  OpalMediaFormat::GetAllRegisteredMediaFormats (media_formats_list);

  // Configure all mediaOptions of all Video MediaFormats
  for (int i = 0 ; i < media_formats_list.GetSize () ; i++) {

    OpalMediaFormat media_format = media_formats_list [i];
    if (media_format.GetMediaType() == OpalMediaType::Video ()) {

      media_format.SetOptionInteger (OpalVideoFormat::FrameWidthOption (), 
                                     Ekiga::VideoSizes [options.size].width);  
      media_format.SetOptionInteger (OpalVideoFormat::FrameHeightOption (), 
                                     Ekiga::VideoSizes [options.size].height);  
      media_format.SetOptionInteger (OpalVideoFormat::FrameTimeOption (),
                                     (int) (90000 / options.maximum_frame_rate));
      media_format.SetOptionInteger (OpalVideoFormat::MaxBitRateOption (), 
                                     options.maximum_received_bitrate * 1000);
      media_format.SetOptionInteger (OpalVideoFormat::TargetBitRateOption (), 
                                     options.maximum_transmitted_bitrate * 1000);
      media_format.SetOptionInteger (OpalVideoFormat::MinRxFrameWidthOption(), 
                                     160);
      media_format.SetOptionInteger (OpalVideoFormat::MinRxFrameHeightOption(), 
                                     120);
      media_format.SetOptionInteger (OpalVideoFormat::MaxRxFrameWidthOption(), 
                                     1920);
      media_format.SetOptionInteger (OpalVideoFormat::MaxRxFrameHeightOption(), 
                                     1088);
      media_format.AddOption(new OpalMediaOptionUnsigned (OpalVideoFormat::TemporalSpatialTradeOffOption (), 
                                                          true, OpalMediaOption::NoMerge, 
                                                          options.temporal_spatial_tradeoff));  
      media_format.SetOptionInteger (OpalVideoFormat::TemporalSpatialTradeOffOption(), 
                                     options.temporal_spatial_tradeoff);  
      media_format.AddOption(new OpalMediaOptionUnsigned (OpalVideoFormat::MaxFrameSizeOption (), 
                                                          true, OpalMediaOption::NoMerge, 1400));
      media_format.SetOptionInteger (OpalVideoFormat::MaxFrameSizeOption (), 
                                     1400);  

      if ( media_format.GetName() != "YUV420P" &&
           media_format.GetName() != "RGB32" &&
           media_format.GetName() != "RGB24") {

        media_format.SetOptionBoolean (OpalVideoFormat::RateControlEnableOption(),
                                       true);
        media_format.SetOptionInteger (OpalVideoFormat::RateControlWindowSizeOption(),
                                       500);
        media_format.SetOptionInteger (OpalVideoFormat::RateControlMaxFramesSkipOption(),
                                       1);
      }

      OpalMediaFormat::SetRegisteredMediaFormat(media_format);
    }
  }

  // Adjust setting for all sessions of all connections of all calls
  for (PSafePtr<OpalCall> call = activeCalls;
       call != NULL;
       ++call) {

    for (int i = 0; 
         i < 2;
         i++) {

      PSafePtr<OpalRTPConnection> connection = PSafePtrCast<OpalConnection, OpalRTPConnection> (call->GetConnection (i));
      if (connection) {

        OpalMediaStreamPtr stream = connection->GetMediaStream (OpalMediaType::Video (), false);
        if (stream != NULL) {

          OpalMediaFormat mediaFormat = stream->GetMediaFormat ();
          mediaFormat.SetOptionInteger (OpalVideoFormat::TemporalSpatialTradeOffOption(),
                                        options.temporal_spatial_tradeoff);
          mediaFormat.SetOptionInteger (OpalVideoFormat::TargetBitRateOption (),
                                        options.maximum_transmitted_bitrate * 1000);
          mediaFormat.ToNormalisedOptions();
          stream->UpdateMediaFormat (mediaFormat);
        }
      }
    }
  }
}