Skip to content

Commit

Permalink
[Dash] detect subtitle stream labeled with video/mp4
Browse files Browse the repository at this point in the history
  • Loading branch information
peak3d committed Sep 22, 2019
1 parent 35b1662 commit 99b6dff
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 5 deletions.
7 changes: 4 additions & 3 deletions src/main.cpp
Expand Up @@ -2091,9 +2091,10 @@ void Session::GetSupportedDecrypterURN(std::string &key_system)

void Session::DisposeSampleDecrypter()
{
for (std::vector<CDMSESSION>::iterator b(cdm_sessions_.begin()), e(cdm_sessions_.end()); b != e; ++b)
if (!b->shared_single_sample_decryptor_)
decrypter_->DestroySingleSampleDecrypter(b->single_sample_decryptor_);
if (decrypter_)
for (std::vector<CDMSESSION>::iterator b(cdm_sessions_.begin()), e(cdm_sessions_.end()); b != e; ++b)
if (!b->shared_single_sample_decryptor_)
decrypter_->DestroySingleSampleDecrypter(b->single_sample_decryptor_);
}

void Session::DisposeDecrypter()
Expand Down
28 changes: 26 additions & 2 deletions src/parser/DASHTree.cpp
Expand Up @@ -51,6 +51,8 @@ enum
MPDNODE_PLAYREADYWRMHEADER = 1 << 16
};

static const char* CONTENTPROTECTION_TAG = "ContentProtection";

static const char* ltranslate(const char * in)
{
if (strlen(in) == 2 || strlen(in) == 3
Expand Down Expand Up @@ -471,7 +473,7 @@ start(void *data, const char *el, const char **attr)
}
dash->currentNode_ |= MPDNODE_SEGMENTTEMPLATE;
}
else if (strcmp(el, "ContentProtection") == 0)
else if (strcmp(el, CONTENTPROTECTION_TAG) == 0)
{
if (!dash->current_representation_->pssh_set_ || dash->current_representation_->pssh_set_ == 0xFF)
{
Expand Down Expand Up @@ -579,6 +581,24 @@ start(void *data, const char *el, const char **attr)
}
dash->currentNode_ |= MPDNODE_SEGMENTLIST;
}
else if (strcmp(el, "Role") == 0)
{
bool schemeOk = false;
const char* value = nullptr;
for (; *attr;)
{
if (strcmp((const char*)*attr, "schemeIdUri") == 0)
{
if (strcmp((const char*)*(attr + 1), "urn:mpeg:dash:role:2011") == 0)
schemeOk = true;
}
else if (strcmp((const char*)*attr, "value") == 0)
value = (const char*)*(attr + 1);
attr += 2;
}
if (schemeOk && value && strcmp(value, "subtitle") == 0)
dash->current_adaptationset_->type_ = DASHTree::SUBTITLE;
}
else if (strcmp(el, "Representation") == 0)
{
dash->current_representation_ = new DASHTree::Representation();
Expand Down Expand Up @@ -643,6 +663,10 @@ start(void *data, const char *el, const char **attr)
|| dash->current_adaptationset_->mimeType_ == "text/vtt"))
dash->current_representation_->flags_ |= DASHTree::Representation::SUBTITLESTREAM;

if (dash->current_adaptationset_->type_ != DASHTree::SUBTITLE
&& dash->current_representation_->codecs_ == "wvtt")
dash->current_adaptationset_->type_ = DASHTree::SUBTITLE;

dash->current_representation_->segtpl_ = dash->current_adaptationset_->segtpl_;
if (!dash->current_adaptationset_->segtpl_.media.empty())
{
Expand Down Expand Up @@ -676,7 +700,7 @@ start(void *data, const char *el, const char **attr)
}
dash->currentNode_ |= MPDNODE_SEGMENTDURATIONS;
}
else if (strcmp(el, "ContentProtection") == 0)
else if (strcmp(el, CONTENTPROTECTION_TAG) == 0)
{
if (!dash->adp_pssh_set_ || dash->adp_pssh_set_== 0xFF)
{
Expand Down

0 comments on commit 99b6dff

Please sign in to comment.