예제 #1
0
파일: track.cpp 프로젝트: jetlive/librtc
bool Init(
        const std::string kind, 
        const std::string label,
        talk_base::scoped_refptr<webrtc::PeerConnectionFactoryInterface> pc_factory,
        talk_base::scoped_refptr<webrtc::MediaStreamTrackInterface> track)
{
    m_track = track;
    if (m_track != NULL) {
        if (kind == kAudioKind)
            m_source = ((webrtc::AudioTrackInterface *)m_track.get())->GetSource();
        else
            m_source = ((webrtc::VideoTrackInterface *)m_track.get())->GetSource();
        return true;
    }

    returnv_assert(pc_factory.get(), false);
    if (kind == kAudioKind) {
        if (!m_source.get()) {
            WebrtcMediaConstraints constraints;
            if (m_constraints.mtype == XRTC_AUDIO && m_constraints.ptr) {
                audio_constraints_t *audio = (audio_constraints_t *)m_constraints.ptr;
                if (audio->aec.valid)
                    constraints.AddItem(webrtc::MediaConstraintsInterface::kEchoCancellation, audio->aec.val, audio->aec.optional);
                if (audio->agc.valid)
                    constraints.AddItem(webrtc::MediaConstraintsInterface::kAutoGainControl, audio->agc.val, audio->agc.optional);
                if (audio->ns.valid)
                    constraints.AddItem(webrtc::MediaConstraintsInterface::kNoiseSuppression, audio->ns.val, audio->ns.optional);
                if (audio->highPassFilter.valid)
                    constraints.AddItem(webrtc::MediaConstraintsInterface::kHighpassFilter, audio->highPassFilter.val, audio->highPassFilter.optional);
            }
            m_source = pc_factory->CreateAudioSource(&constraints);
        }
        m_track = pc_factory->CreateAudioTrack(label, (webrtc::AudioSourceInterface *)(m_source.get()));
    }else if (kind == kVideoKind) {
        if (!m_source.get()) {
            std::string vname = "";
            if (m_constraints.mtype == XRTC_VIDEO && m_constraints.ptr) {
                video_constraints_t *video = (video_constraints_t *)m_constraints.ptr;
                if (video && video->device.valid) {
                    vname = video->device.val.did;
                }
            }

            // if vname empty, select default device
            LOGI("vname="<<vname);
            cricket::VideoCapturer* capturer = OpenVideoCaptureDevice(vname);
            if (capturer) {
                m_source = pc_factory->CreateVideoSource(capturer, NULL);
            }
        }

        LOGD("create video track by source");
        if (m_source) {
            m_track = pc_factory->CreateVideoTrack(label, (webrtc::VideoSourceInterface *)(m_source.get()));
        }
    }
    return (m_track != NULL);
}
예제 #2
0
파일: track.cpp 프로젝트: jetlive/librtc
MediaStreamTrackState readyState() {
    returnv_assert(m_track.get(), TRACK_ENDED);

    MediaStreamTrackState state = TRACK_ENDED;
    webrtc::MediaStreamTrackInterface::TrackState tstate = m_track->state();
    switch (tstate) {
    case webrtc::MediaStreamTrackInterface::kInitializing: 
        state = TRACK_NEW; 
        break;
    case webrtc::MediaStreamTrackInterface::kLive: 
        state = TRACK_LIVE; 
        break;
    case webrtc::MediaStreamTrackInterface::kEnded: 
    case webrtc::MediaStreamTrackInterface::kFailed: 
        state = TRACK_ENDED; 
        break;
    }
    return state;
}
예제 #3
0
파일: track.cpp 프로젝트: jetlive/librtc
boolean muted() {
    returnv_assert(m_source.get(), false);
    webrtc::MediaSourceInterface::SourceState state = m_source->state();
    return (state == webrtc::MediaSourceInterface::kMuted);
}
예제 #4
0
파일: track.cpp 프로젝트: jetlive/librtc
void Put_enabled(boolean enable) {
    return_assert(m_track.get());
    m_track->set_enabled(enable);
}
예제 #5
0
파일: track.cpp 프로젝트: jetlive/librtc
boolean enabled() {
    returnv_assert(m_track.get(), false);
    return m_track->enabled();
}
예제 #6
0
파일: track.cpp 프로젝트: jetlive/librtc
DOMString label() {
    returnv_assert(m_track.get(), "");
    return m_track->id();
}
예제 #7
0
파일: track.cpp 프로젝트: jetlive/librtc
DOMString kind() {
    returnv_assert(m_track.get(), "");
    return m_track->kind();
}
예제 #8
0
파일: track.cpp 프로젝트: jetlive/librtc
void * getptr()
{
    return m_track.get();
}