Example #1
0
   String
      MimeBody::GetCleanContentType() const
   {
      String sMainPart = GetMainType();
      String sSubPart = GetSubType();

      return sMainPart + "/" + sSubPart;
   }
Example #2
0
   bool
      MimeBody::IsAttachment()  const
   {
      /*
      Previously we looked at the ContentDisposition header and the Name header to determine
      whether it's an attachment or not. This was not safe, since a lot of attachments did
      not have these headers but just a Content-type header. The new strategy is:


      1) If the ContentDisposition is of type attachment, we assume it's an attachment
      2) If the main ContentType is text or multipart, we assume that it's not an attachment
      3) In all other cases, we treat it as an attachment.

      discrete-type := "text" / "image" / "audio" / "video" / "application" / extension-token
      composite-type := "message" / "multipart" / extension-token
      */

      // If the content-disposition is set to attachment, we always treats it as an attachment
      // even if the main type is set to multipart or text.
      AnsiString sDisposition = GetRawFieldValue(CMimeConst::ContentDisposition());
      if (sDisposition.StartsWith(CMimeConst::Attachment()))
         return true;

      if (sDisposition.StartsWith(CMimeConst::Inline()))
      {
         AnsiString sFileName = GetParameter(CMimeConst::ContentDisposition(), "filename");

         if (!sFileName.IsEmpty())
            return true;
      }

      String sMainType = GetMainType();

      if (sMainType.CompareNoCase(_T("multipart")) == 0)
      {
         // Multipart ...
         return false;
      }

      if (sMainType.CompareNoCase(_T("text")) == 0)
      {
         // This is just a text part.
         return false;
      }

      return true;
   }
Example #3
0
   bool 
      MimeBody::IsEncapsulatedRFC822Message() const
   {
      if (!IsAttachment())
         return false;

      String sMainType = GetMainType();
      String sSubType = GetSubType();

      sMainType.ToUpper();
      sSubType.ToUpper();

      if (sMainType == _T("MESSAGE") && sSubType == _T("RFC822"))
         return true;
      else
         return false;
   }
Example #4
0
bool MP4MediaFormat::MakeAllStreams(std::shared_ptr<Aka4Splitter>& core)
{
	auto p = core->GetTracks();
	if (p->GetCount() > MAX_MP4_STREAM_COUNT)
		return false;

	for (unsigned i = 0;i < p->GetCount();i++)
	{
		auto t = p->Get(i);
		if (t->Type != Aka4Splitter::TrackInfo::TrackType_Audio &&
			t->Type != Aka4Splitter::TrackInfo::TrackType_Video &&
			t->Type != Aka4Splitter::TrackInfo::TrackType_Subtitle)
			continue;

		auto s = std::make_shared<MP4MediaStream>(t,_stream_count);
		switch (t->Type)
		{
		case Aka4Splitter::TrackInfo::TrackType_Audio:
			if (!s->ProbeAudio(core))
				continue;
			break;
		case Aka4Splitter::TrackInfo::TrackType_Video:
			if (!s->ProbeVideo(core,_force_avc1))
				continue;
			break;
		case Aka4Splitter::TrackInfo::TrackType_Subtitle:
			if (!s->ProbeText(core,
					t->Codec.CodecId.CodecFcc != ISOM_FCC('tx3g') &&
					t->Codec.CodecId.CodecFcc != ISOM_FCC('text')))
				continue;
			break;
		default:
			continue;
		}

		//bitrate
		if (t->BitratePerSec > 128)
		{
			if (s->GetMainType() == MEDIA_MAIN_TYPE_AUDIO)
			{
				AudioBasicDescription audio = {};
				if (s->GetAudioInfo()->GetAudioDescription(&audio))
				{
					if (audio.bitrate == 0)
						UpdateAudioDescriptionBitrate(s->GetAudioInfo(),t->BitratePerSec);
				}
			}else if (s->GetMainType() == MEDIA_MAIN_TYPE_VIDEO)
			{
				VideoBasicDescription video = {};
				if (s->GetVideoInfo()->GetVideoDescription(&video))
				{
					if (video.bitrate == 0)
					{
						video.bitrate = t->BitratePerSec;
						s->GetVideoInfo()->ExternalUpdateVideoDescription(&video);
					}
				}
			}
		}

		_streams[_stream_count] = std::move(s);
		_stream_count++;
	}
	return true;
}