aboutsummaryrefslogtreecommitdiffstats
path: root/Input/MediaObject.h
blob: 24c2995b773d9f47cf7c8ba16d1e2a1c37563d1f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
/*
 * MediaObject.h
 *****************************************************************************
 * Copyright (C) 2012, bitmovin Softwareentwicklung OG, All Rights Reserved
 *
 * Email: libdash-dev@vicky.bitmovin.net
 *
 * This source code and its use and distribution, is subject to the terms
 * and conditions of the applicable license agreement.
 *****************************************************************************/

#ifndef LIBDASH_FRAMEWORK_INPUT_MEDIAOBJECT_H_
#define LIBDASH_FRAMEWORK_INPUT_MEDIAOBJECT_H_

#include "../Adaptation/IAdaptationLogic.h"
#include "IMPD.h"
#include "IDownloadObserver.h"
#include "IDASHMetrics.h"
#include "../Portable/MultiThreading.h"
#include "ICNConnectionConsumerApi.h"

namespace libdash
{
namespace framework
{
namespace adaptation
{
class IAdaptationLogic;
}
namespace input
{
class DASHReceiver;
class MediaObject : public dash::network::IDownloadObserver, public dash::metrics::IDASHMetrics
{
public:
    MediaObject(dash::mpd::ISegment *segment, dash::mpd::IRepresentation *rep, bool withFeedBack = false);
    virtual ~MediaObject();

    bool StartDownload();
    bool StartDownload(IICNConnection* conn);
    void AbortDownload();
    void WaitFinished();
    int Read(uint8_t *data, size_t len);
    int Peek(uint8_t *data, size_t len);
    int Peek(uint8_t *data, size_t len, size_t offset);
    dash::mpd::IRepresentation*	GetRepresentation();
    dash::mpd::ISegment* GetSegment();
    const char*	GetPath();
    void SetFeedBack(bool flag);
    virtual void OnDownloadStateChanged(dash::network::DownloadState state);
    virtual void OnDownloadRateChanged(uint64_t bytesDownloaded); //Here the bytesDownloaded is in fact the bitrate bps
    virtual void OnDownloadTimeChanged(double dnltime);

    void AddInitSegment(MediaObject* initSeg);
    int ReadInitSegment(uint8_t* data, size_t len);
    const std::vector<dash::metrics::ITCPConnection *>& GetTCPConnectionList() const;
    const std::vector<dash::metrics::IHTTPTransaction *>& GetHTTPTransactionList() const;
    void SetAdaptationLogic(framework::adaptation::IAdaptationLogic *_adaptationLogic);
    void SetDASHReceiver(input::DASHReceiver *_dashReceiver);
    uint32_t GetRepresentationBandwidth();
    uint32_t GetRepresentationHeight();
    std::string GetRepresentationID();
    uint64_t GetSegmentDuration();
    void SetSegmentDuration(uint64_t segmentDuration);

private:
    dash::mpd::ISegment             *segment;
    MediaObject                     *initSeg;
    dash::mpd::IRepresentation      *rep;
    dash::network::DownloadState    state;
    uint64_t                        bps;
    bool                            withFeedBack;
    double                          dnltime;
    input::DASHReceiver             *dashReceiver;
    adaptation::IAdaptationLogic    *adaptationLogic;
    mutable CRITICAL_SECTION        stateLock;
    mutable CONDITION_VARIABLE      stateChanged;
    uint32_t                        representationBandwidth;
    uint32_t                        representationHeight;
    std::string                     representationId;
    uint64_t                        segmentDuration;
};
}
}
}

#endif /* LIBDASH_FRAMEWORK_INPUT_MEDIAOBJECT_H_ */