Ticket #8791: multiangle.diff

File multiangle.diff, 16.9 KB (added by robertm, 14 years ago)

Add Multiple Angle support in DVD and Blu-ray

  • libs/libmythtv/mythbdplayer.h

     
    1313    virtual int64_t GetChapter(int chapter);
    1414
    1515    virtual int GetNumTitles(void) const;
     16    virtual int GetNumAngles(void) const;
    1617    virtual int GetCurrentTitle(void) const;
     18    virtual int GetCurrentAngle(void) const;
    1719    virtual int GetTitleDuration(int title) const;
    1820    virtual QString GetTitleName(int title) const;
     21    virtual QString GetAngleName(int angle) const;
    1922    virtual bool SwitchTitle(int title);
    2023    virtual bool PrevTitle(void);
    2124    virtual bool NextTitle(void);
     25    virtual bool SwitchAngle(int angle);
     26    virtual bool PrevAngle(void);
     27    virtual bool NextAngle(void);
    2228};
    2329
    2430#endif // MYTHBDPLAYER_H
  • libs/libmythtv/DVDRingBuffer.cpp

     
    3838      m_currentpos(0),
    3939      m_lastNav(NULL),    m_part(0),
    4040      m_title(0),         m_titleParts(0),
    41       m_gotStop(false),
     41      m_gotStop(false),   m_currentAngle(0),
     42      m_currentTitleAngleCount(0),
    4243      m_cellHasStillFrame(false), m_audioStreamsChanged(false),
    4344      m_dvdWaiting(false),
    4445      m_titleLength(0), m_hl_button(0, 0, 0, 0),
     
    187188
    188189        int32_t numTitles  = 0;
    189190        m_titleParts = 0;
     191
    190192        dvdnav_title_play(m_dvdnav, 0);
    191193        dvdRet = dvdnav_get_number_of_titles(m_dvdnav, &numTitles);
    192194        if (numTitles == 0 )
     
    220222        dvdnav_current_title_info(m_dvdnav, &m_title, &m_part);
    221223        dvdnav_get_title_string(m_dvdnav, &m_dvdname);
    222224        dvdnav_get_serial_string(m_dvdnav, &m_serialnumber);
     225        dvdnav_get_angle_info(m_dvdnav, &m_currentAngle, &m_currentTitleAngleCount);
    223226        SetDVDSpeed();
    224227        VERBOSE(VB_PLAYBACK, QString("DVD Serial Number %1").arg(m_serialnumber));
    225228        return true;
     
    14981501    s->rects[0]->y += y1;
    14991502    return 1;
    15001503}
     1504
     1505bool DVDRingBufferPriv::SwitchAngle(uint angle)
     1506{
     1507    if (m_dvdnav)
     1508    {
     1509        VERBOSE(VB_IMPORTANT, LOC + QString("Switching to Angle %1...")
     1510                .arg(angle));
     1511        dvdnav_status_t status = dvdnav_angle_change(m_dvdnav,
     1512                                                    (int32_t)angle);
     1513        if (status == DVDNAV_STATUS_OK)
     1514        {
     1515            m_currentAngle = angle;
     1516            return true;
     1517        }
     1518        else
     1519            return false;
     1520    }
     1521    else
     1522        return false;
     1523}
     1524
  • libs/libmythtv/tv_play.h

     
    448448    int  GetTitleDuration(const PlayerContext *ctx, int title) const;
    449449    QString GetTitleName(const PlayerContext *ctx, int title) const;
    450450    void DoSwitchTitle(PlayerContext*, int title);
     451    int  GetNumAngles(const PlayerContext *ctx) const;
     452    int  GetCurrentAngle(const PlayerContext *ctx) const;
     453    QString GetAngleName(const PlayerContext *ctx, int angle) const;
     454    void DoSwitchAngle(PlayerContext*, int angle);
    451455    void DoJumpChapter(PlayerContext*, int direction);
    452456    void DoSkipCommercials(PlayerContext*, int direction);
    453457
  • libs/libmythtv/BDRingBuffer.cpp

     
    7272        m_titlesize = 0;
    7373        m_currentTime = 0;
    7474        m_currentTitleInfo = NULL;
     75        m_currentTitleAngleCount = 0;
     76        m_currentAngle = 0;
    7577
    7678        VERBOSE(VB_IMPORTANT, LOC + QString("Found %1 relevant titles.")
    7779                .arg(m_numTitles));
     
    164166            return false;
    165167
    166168        m_currentTitleLength = m_currentTitleInfo->duration;
     169        m_currentTitleAngleCount = m_currentTitleInfo->angle_count;
     170        m_currentAngle = 0;
    167171        bd_select_title(bdnav, title);
    168172        uint32_t chapter_count = m_currentTitleInfo->chapter_count;
    169173        VERBOSE(VB_IMPORTANT, LOC + QString("Selected title: index %1. "
    170174                                            "Duration: %2 (%3 mins) "
    171                                             "Number of Chapters: %4")
     175                                            "Number of Chapters: %4 Number of Angles: %5")
    172176                                            .arg(title)
    173177                                            .arg(m_currentTitleLength)
    174178                                            .arg(m_currentTitleLength / (90000 * 60))
    175                                             .arg(chapter_count));
     179                                            .arg(chapter_count)
     180                                            .arg(m_currentTitleAngleCount));
    176181        VERBOSE(VB_PLAYBACK, LOC + QString("Frame Rate: %1").arg(GetFrameRate()));
    177182        if (chapter_count)
    178183        {
     
    198203        return false;
    199204}
    200205
     206bool BDRingBufferPriv::SwitchAngle(uint angle)
     207{
     208    if (bdnav)
     209    {
     210        VERBOSE(VB_IMPORTANT, LOC + QString("Switching to Angle %1...")
     211                .arg(angle));
     212        bd_seamless_angle_change(bdnav, angle);
     213        m_currentAngle = angle;
     214        return true;
     215    }
     216    else
     217        return false;
     218}
     219
    201220uint64_t BDRingBufferPriv::GetTotalReadPosition(void)
    202221{
    203222    if (bdnav)
     
    289308    }
    290309
    291310    return iso639_str3_to_key("und");
    292 }
    293  No newline at end of file
     311}
  • libs/libmythtv/mythdvdplayer.h

     
    4646
    4747    void HideDVDButton(bool hide) { hidedvdbutton = hide; }
    4848
     49    virtual int GetNumAngles(void) const;
     50    virtual int GetCurrentAngle(void) const;
     51    virtual QString GetAngleName(int angle) const;
     52    virtual bool SwitchAngle(int angle);
     53
    4954  private:
    5055    void SetDVDBookmark(uint64_t frame);
    5156    void DisplayDVDButton(void);
  • libs/libmythtv/mythbdplayer.cpp

     
    6161    return 0;
    6262}
    6363
     64int MythBDPlayer::GetNumAngles(void) const
     65{
     66    if (player_ctx->buffer->BD() && player_ctx->buffer->BD()->IsOpen())
     67        return player_ctx->buffer->BD()->GetNumAngles();
     68    return 0;
     69}
     70
    6471int MythBDPlayer::GetCurrentTitle(void) const
    6572{
    6673    if (player_ctx->buffer->BD() && player_ctx->buffer->BD()->IsOpen())
     
    6875    return -1;
    6976}
    7077
     78int MythBDPlayer::GetCurrentAngle(void) const
     79{
     80    if (player_ctx->buffer->BD() && player_ctx->buffer->BD()->IsOpen())
     81        return player_ctx->buffer->BD()->GetCurrentAngle();
     82    return -1;
     83}
     84
    7185int MythBDPlayer::GetTitleDuration(int title) const
    7286{
    7387    if (player_ctx->buffer->BD() && player_ctx->buffer->BD()->IsOpen() &&
     
    95109    return QString();
    96110}
    97111
     112QString MythBDPlayer::GetAngleName(int angle) const
     113{
     114    if (angle >= 0 && angle < GetNumAngles())
     115    {
     116        QString name = QObject::tr("Angle %1").arg(angle+1);
     117        return name;
     118    }
     119    return QString();
     120}
     121
    98122bool MythBDPlayer::SwitchTitle(int title)
    99123{
    100124    uint total = GetNumTitles();
     
    134158
    135159    return SwitchTitle(prev);
    136160}
     161
     162bool MythBDPlayer::SwitchAngle(int angle)
     163{
     164    uint total = GetNumAngles();
     165    if (!total || angle == GetCurrentAngle())
     166        return false;
     167
     168    if (angle >= (int)total)
     169        angle = 0;
     170
     171    bool ok = static_cast<bool>(player_ctx->buffer->BD()->SwitchAngle(angle));
     172
     173    return ok;
     174}
     175
     176bool MythBDPlayer::NextAngle(void)
     177{
     178    uint total = GetNumAngles();
     179    int next = GetCurrentAngle() + 1;
     180    if (!total)
     181        return false;
     182
     183    if (next >= (int)total)
     184        next = 0;
     185
     186    return SwitchAngle(next);
     187}
     188
     189bool MythBDPlayer::PrevAngle(void)
     190{
     191    uint total = GetNumAngles();
     192    int prev = GetCurrentAngle() - 1;
     193    if (!total || total == 1)
     194        return false;
     195
     196    if (prev < 0)
     197        prev = total;
     198
     199    return SwitchAngle(prev);
     200}
     201
  • libs/libmythtv/mythplayer.h

     
    269269    virtual bool NextTitle(void) { return false; }
    270270    virtual bool PrevTitle(void) { return false; }
    271271
     272    // Angle stuff
     273    virtual bool SwitchAngle(int title) { return false; }
     274    virtual bool NextAngle(void) { return false; }
     275    virtual bool PrevAngle(void) { return false; }
     276
    272277    // Commercial stuff
    273278    void SetAutoCommercialSkip(CommSkipMode autoskip)
    274279        { commBreakMap.SetAutoCommercialSkip(autoskip, framesPlayed); }
     
    389394    virtual int GetTitleDuration(int title) const { return 0; }
    390395    virtual QString GetTitleName(int title) const { return QString(); }
    391396
     397    // Angle public stuff
     398    virtual int GetNumAngles(void) const { return 0; }
     399    virtual int GetCurrentAngle(void) const { return 0; }
     400    virtual QString GetAngleName(int title) const { return QString(); }
     401
    392402    // DVD public stuff
    393403    virtual void ChangeDVDTrack(bool ffw)       { (void) ffw;       }
    394404    virtual bool GoToDVDMenu(QString str)       { return false;     }
  • libs/libmythtv/mythdvdplayer.cpp

     
    465465    }
    466466    player_ctx->UnlockPlayingInfo(__FILE__, __LINE__);
    467467}
     468
     469int MythDVDPlayer::GetNumAngles(void) const
     470{
     471    if (player_ctx->buffer->DVD() && player_ctx->buffer->DVD()->IsOpen())
     472        return player_ctx->buffer->DVD()->GetNumAngles();
     473    return 0;
     474}
     475
     476int MythDVDPlayer::GetCurrentAngle(void) const
     477{
     478    if (player_ctx->buffer->DVD() && player_ctx->buffer->DVD()->IsOpen())
     479        return player_ctx->buffer->DVD()->GetCurrentAngle();
     480    return -1;
     481}
     482
     483QString MythDVDPlayer::GetAngleName(int angle) const
     484{
     485    if (angle >= 0 && angle < GetNumAngles())
     486    {
     487        QString name = QObject::tr("Angle %1").arg(angle+1);
     488        return name;
     489    }
     490    return QString();
     491}
     492
     493bool MythDVDPlayer::SwitchAngle(int angle)
     494{
     495    uint total = GetNumAngles();
     496    if (!total || angle == GetCurrentAngle())
     497        return false;
     498
     499    if (angle >= (int)total)
     500        angle = 0;
     501
     502    bool ok = static_cast<bool>(player_ctx->buffer->DVD()->SwitchAngle(angle));
     503
     504    return ok;
     505}
     506
  • libs/libmythtv/DVDRingBuffer.h

     
    3434    // gets
    3535    int  GetTitle(void) const { return m_title;        }
    3636    int  GetPart(void)  const { return m_part;         }
     37    int GetCurrentAngle(void) const { return m_currentAngle; };
     38    int GetNumAngles(void) { return m_currentTitleAngleCount; };
    3739    bool IsInMenu(bool update = false);
    3840    bool IsOpen(void)   const { return m_dvdnav;       }
    3941    long long GetReadPosition(void);
     
    108110    void JumpToTitle(bool change) { m_jumptotitle = change; }
    109111    void SetDVDSpeed(void);
    110112    void SetDVDSpeed(int speed);
     113    bool SwitchAngle(uint angle);
    111114
    112115    void SetParent(MythDVDPlayer *p) { m_parent = p; }
    113116
     
    130133    int32_t        m_title;
    131134    int32_t        m_titleParts;
    132135    bool           m_gotStop;
     136    int            m_currentAngle;
     137    int            m_currentTitleAngleCount;
    133138
    134139    bool           m_cellHasStillFrame;
    135140    bool           m_audioStreamsChanged;
  • libs/libmythtv/tv_play.cpp

     
    60446044    return currentTitle;
    60456045}
    60466046
     6047int TV::GetNumAngles(const PlayerContext *ctx) const
     6048{
     6049    int num_angles = 0;
     6050    ctx->LockDeletePlayer(__FILE__, __LINE__);
     6051    if (ctx->player)
     6052        num_angles = ctx->player->GetNumAngles();
     6053    ctx->UnlockDeletePlayer(__FILE__, __LINE__);
     6054    return num_angles;
     6055}
     6056
     6057int TV::GetCurrentAngle(const PlayerContext *ctx) const
     6058{
     6059    int currentAngle = 0;
     6060    ctx->LockDeletePlayer(__FILE__, __LINE__);
     6061    if (ctx->player)
     6062        currentAngle = ctx->player->GetCurrentAngle();
     6063    ctx->UnlockDeletePlayer(__FILE__, __LINE__);
     6064    return currentAngle;
     6065}
     6066
     6067QString TV::GetAngleName(const PlayerContext *ctx, int angle) const
     6068{
     6069    QString name;
     6070    ctx->LockDeletePlayer(__FILE__, __LINE__);
     6071    if (ctx->player)
     6072        name = ctx->player->GetAngleName(angle);
     6073    ctx->UnlockDeletePlayer(__FILE__, __LINE__);
     6074    return name;
     6075}
     6076
    60476077int TV::GetTitleDuration(const PlayerContext *ctx, int title) const
    60486078{
    60496079    int seconds = 0;
     
    60866116    ctx->UnlockDeletePlayer(__FILE__, __LINE__);
    60876117}
    60886118
     6119void TV::DoSwitchAngle(PlayerContext *ctx, int angle)
     6120{
     6121    NormalSpeed(ctx);
     6122    StopFFRew(ctx);
     6123
     6124    PauseAudioUntilBuffered(ctx);
     6125
     6126    osdInfo info;
     6127    ctx->CalcPlayerSliderPosition(info);
     6128    info.text["description"] = tr("Switch Angle");
     6129    info.text["title"] = tr("Switching");
     6130    UpdateOSDStatus(ctx, info, kOSDFunctionalType_Default, kOSDTimeout_Med);
     6131
     6132    ctx->LockDeletePlayer(__FILE__, __LINE__);
     6133    if (ctx->player)
     6134    {
     6135        ctx->player->SwitchAngle(angle);
     6136    }
     6137    ctx->UnlockDeletePlayer(__FILE__, __LINE__);
     6138}
     6139
    60896140void TV::DoSkipCommercials(PlayerContext *ctx, int direction)
    60906141{
    60916142    NormalSpeed(ctx);
     
    998910040            int title = action.right(3).toInt();
    999010041            DoSwitchTitle(actx, title);
    999110042        }
     10043        else if (action.left(13) == "SWITCHTOANGLE")
     10044        {
     10045            int angle = action.right(3).toInt();
     10046            DoSwitchAngle(actx, angle);
     10047        }
    999210048        else if (action == "EDIT")
    999310049            StartProgramEditMode(actx);
    999410050        else if (action == "TOGGLEAUTOEXPIRE")
     
    1040910465{
    1041010466    int num_chapters  = GetNumChapters(ctx);
    1041110467    int num_titles    = GetNumTitles(ctx);
     10468    int num_angles    = GetNumAngles(ctx);
    1041210469    TVState state     = ctx->GetState();
    1041310470    bool isdvd        = state == kState_WatchingDVD;
    1041410471    bool islivetv     = StateIsLiveTV(state);
     
    1045910516            osd->DialogAddButton(tr("Chapter"), "DIALOG_MENU_AVCHAPTER_0",
    1046010517                                 true, selected == "AVCHAPTER");
    1046110518        }
     10519        if (num_angles > 1)
     10520        {
     10521            osd->DialogAddButton(tr("Angle"), "DIALOG_MENU_AVANGLE_0",
     10522                                 true, selected == "AVANGLE");
     10523        }
    1046210524        if (num_titles)
    1046310525        {
    1046410526            osd->DialogAddButton(tr("Title"), "DIALOG_MENU_AVTITLE_0",
     
    1050710569                                 false, current_title == i);
    1050810570        }
    1050910571    }
     10572    else if (category == "AVANGLE")
     10573    {
     10574        backaction = "NAVIGATE";
     10575        currenttext = tr("Angle");
     10576        int current_angle = GetCurrentAngle(ctx);
     10577
     10578        for (int i = 0; i < num_angles; i++)
     10579        {
     10580            QString angleIdx = QString("%1").arg(i, 3, 10, QChar(48));
     10581            QString desc = GetAngleName(ctx, i);
     10582            osd->DialogAddButton(desc, QString("SWITCHTOANGLE%1").arg(angleIdx),
     10583                                 false, current_angle == i);
     10584        }
     10585    }
    1051010586    else if (category == "COMMSKIP")
    1051110587    {
    1051210588        backaction = "NAVIGATE";
  • libs/libmythtv/BDRingBuffer.h

     
    2525
    2626    uint32_t GetNumTitles(void) const { return m_numTitles; }
    2727    int      GetCurrentTitle(void) const;
     28    uint64_t GetCurrentAngle(void) const { return m_currentAngle; };
    2829    int      GetTitleDuration(int title) const;
    2930    // Get the size in bytes of the current title (playlist item).
    3031    uint64_t GetTitleSize(void) const { return m_titlesize; }
     
    3435    uint64_t GetReadPosition(void);
    3536    uint64_t GetTotalReadPosition(void);
    3637    uint32_t GetNumChapters(void);
     38    uint64_t GetNumAngles(void) { return m_currentTitleAngleCount; };
    3739    uint64_t GetChapterStartTime(uint32_t chapter);
    3840    uint64_t GetChapterStartFrame(uint32_t chapter);
    3941    bool IsOpen(void)        const { return bdnav; }
     
    4951    void close(void);
    5052
    5153    bool SwitchTitle(uint title);
     54    bool SwitchAngle(uint angle);
    5255
    5356    int  safe_read(void *data, unsigned sz);
    5457    uint64_t Seek(uint64_t pos);
     
    6063    uint64_t           m_currentTitleLength; // Selected title's duration, in ticks (90Khz)
    6164    BLURAY_TITLE_INFO *m_currentTitleInfo; // Selected title info from struct in bluray.h
    6265    uint64_t           m_titlesize;
     66    uint64_t           m_currentAngle;
     67    uint64_t           m_currentTitleAngleCount;
    6368    uint64_t           m_currentTime;
    6469};
    6570#endif