本文整理汇总了C++中MediaSource类的典型用法代码示例。如果您正苦于以下问题:C++ MediaSource类的具体用法?C++ MediaSource怎么用?C++ MediaSource使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了MediaSource类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: DragDrop
/* FUNCTION: ViewObject :: DragDrop
ARGUMENTS: none
RETURN: n/a
DESCRIPTION: Hook function called when user drops files in application window.
Essentially, determine if file is image or video.
*/
void ViewObject :: DragDrop(entry_ref *ref, float mouse_x, float mouse_y)
{
// Image file?
BPath path(ref);
BBitmap *bitmap = BTranslationUtils::GetBitmap(path.Path(), NULL);
if (bitmap)
{
MediaSource *media = new MediaSource(this);
GLCreateTexture(media, bitmap);
if (!SurfaceUpdate(media, mouse_x, mouse_y))
delete media;
delete bitmap;
return;
}
// Video file
Video *video = new Video(ref);
if (video->GetStatus() == B_OK)
{
MediaSource *media = new MediaSource(this);
GLCreateTexture(media, video->GetBitmap());
media->SetVideo(video);
if (SurfaceUpdate(media, mouse_x, mouse_y))
video->Start();
else
delete media;
return;
}
else
delete video;
printf("Unsupported file\n");
}
示例2: DCHECK_EQ
void MediaSourceRegistry::registerURL(SecurityOrigin*, const KURL& url, URLRegistrable* registrable)
{
DCHECK_EQ(®istrable->registry(), this);
DCHECK(isMainThread());
MediaSource* source = static_cast<MediaSource*>(registrable);
source->addedToRegistry();
m_mediaSources.set(url.getString(), source);
}
示例3: ASSERT
void MediaSourceRegistry::registerURL(SecurityOrigin*, const URL& url, URLRegistrable* registrable)
{
ASSERT(®istrable->registry() == this);
ASSERT(isMainThread());
MediaSource* source = static_cast<MediaSource*>(registrable);
source->addedToRegistry();
m_mediaSources.set(url.string(), source);
}
示例4: durationAttrSetter
static void durationAttrSetter(v8::Local<v8::String> name, v8::Local<v8::Value> value, const v8::AccessorInfo& info)
{
MediaSource* imp = V8MediaSource::toNative(info.Holder());
double v = static_cast<double>(value->NumberValue());
ExceptionCode ec = 0;
imp->setDuration(v, ec);
if (UNLIKELY(ec))
setDOMException(ec, info.GetIsolate());
return;
}
示例5: DCHECK
void MediaSourceRegistry::unregisterURL(const KURL& url)
{
DCHECK(isMainThread());
PersistentHeapHashMap<String, Member<MediaSource>>::iterator iter = m_mediaSources.find(url.getString());
if (iter == m_mediaSources.end())
return;
MediaSource* source = iter->value;
m_mediaSources.remove(iter);
source->removedFromRegistry();
}
示例6: activeSourceBuffersAttrGetter
static v8::Handle<v8::Value> activeSourceBuffersAttrGetter(v8::Local<v8::String> name, const v8::AccessorInfo& info)
{
MediaSource* imp = V8MediaSource::toNative(info.Holder());
RefPtr<SourceBufferList> result = imp->activeSourceBuffers();
v8::Handle<v8::Value> wrapper = result.get() ? v8::Handle<v8::Value>(DOMDataStore::getWrapper(result.get(), info.GetIsolate())) : v8Undefined();
if (wrapper.IsEmpty()) {
wrapper = toV8(result.get(), info.Holder(), info.GetIsolate());
if (!wrapper.IsEmpty())
V8DOMWrapper::setNamedHiddenReference(info.Holder(), "activeSourceBuffers", wrapper);
}
return wrapper;
}
示例7: endOfStreamCallback
static v8::Handle<v8::Value> endOfStreamCallback(const v8::Arguments& args)
{
MediaSource* imp = V8MediaSource::toNative(args.Holder());
ExceptionCode ec = 0;
{
V8TRYCATCH_FOR_V8STRINGRESOURCE(V8StringResource<>, error, MAYBE_MISSING_PARAMETER(args, 0, DefaultIsNullString));
imp->endOfStream(error, ec);
if (UNLIKELY(ec))
goto fail;
return v8Undefined();
}
fail:
return setDOMException(ec, args.GetIsolate());
}
示例8: lookupByName
Boolean FramedSource::lookupByName(UsageEnvironment& env, char const* sourceName,
FramedSource*& resultSource) {
resultSource = NULL; // unless we succeed
MediaSource* source;
if (!MediaSource::lookupByName(env, sourceName, source)) return False;
if (!source->isFramedSource()) {
env.setResultMsg(sourceName, " is not a framed source");
return False;
}
resultSource = (FramedSource*)source;
return True;
}
示例9: setNextSource
void MediaObject::setNextSource(const MediaSource &source)
{
if (source.type() == MediaSource::Invalid &&
source.type() == MediaSource::Empty)
return;
m_nextSource = source;
}
示例10: dispatchEventCallback
static v8::Handle<v8::Value> dispatchEventCallback(const v8::Arguments& args)
{
if (args.Length() < 1)
return throwNotEnoughArgumentsError(args.GetIsolate());
MediaSource* imp = V8MediaSource::toNative(args.Holder());
ExceptionCode ec = 0;
{
V8TRYCATCH(Event*, event, V8Event::HasInstance(MAYBE_MISSING_PARAMETER(args, 0, DefaultIsUndefined)) ? V8Event::toNative(v8::Handle<v8::Object>::Cast(MAYBE_MISSING_PARAMETER(args, 0, DefaultIsUndefined))) : 0);
bool result = imp->dispatchEvent(event, ec);
if (UNLIKELY(ec))
goto fail;
return v8Boolean(result, args.GetIsolate());
}
fail:
return setDOMException(ec, args.GetIsolate());
}
示例11: sourceIsCompatibleWithUs
Boolean LiveAMRAudioRTPSink::sourceIsCompatibleWithUs( MediaSource& source )
{
// Our source must be an AMR audio source:
if (!source.isAMRAudioSource()) return False;
// Also, the source must be wideband iff we asked for this:
LiveAMRAudioDeviceSource& amrSource = (LiveAMRAudioDeviceSource&)source;
if ((amrSource.isWideband()^sourceIsWideband()) != 0) return False;
// Also, the source must have the same number of channels that we
// specified. (It could, in principle, have more, but we don't
// support that.)
if (amrSource.numChannels() != numChannels()) return False;
// Also, because in our current implementation we output only one
// frame in each RTP packet, this means that for multi-channel audio,
// each 'frame-block' will be split over multiple RTP packets, which
// may violate the spec. Warn about this:
if (amrSource.numChannels() > 1) {
envir() << "AMRAudioRTPSink: Warning: Input source has " << amrSource.numChannels()
<< " audio channels. In the current implementation, the multi-frame frame-block will be split over multiple RTP packets\n";
}
return True;
}
示例12: addSourceBufferCallback
static v8::Handle<v8::Value> addSourceBufferCallback(const v8::Arguments& args)
{
if (args.Length() < 1)
return throwNotEnoughArgumentsError(args.GetIsolate());
MediaSource* imp = V8MediaSource::toNative(args.Holder());
ExceptionCode ec = 0;
{
V8TRYCATCH_FOR_V8STRINGRESOURCE(V8StringResource<>, type, MAYBE_MISSING_PARAMETER(args, 0, DefaultIsUndefined));
RefPtr<SourceBuffer> result = imp->addSourceBuffer(type, ec);
if (UNLIKELY(ec))
goto fail;
return toV8(result.release(), args.Holder(), args.GetIsolate());
}
fail:
return setDOMException(ec, args.GetIsolate());
}
示例13: K_D
void MediaObject::setCurrentSource(const MediaSource &newSource)
{
K_D(MediaObject);
if (!k_ptr->backendObject()) {
d->mediaSource = newSource;
return;
}
pDebug() << Q_FUNC_INFO << newSource.url();
stop(); // first call stop as that often is the expected state
// for setting a new URL
d->mediaSource = newSource;
#ifndef QT_NO_PHONON_ABSTRACTMEDIASTREAM
d->kiofallback = 0; // kiofallback auto-deletes
#endif //QT_NO_PHONON_ABSTRACTMEDIASTREAM
//X if (url.scheme() == "http") {
//X d->kiofallback = Platform::createMediaStream(url, this);
//X if (d->kiofallback) {
//X ...
//X return;
//X }
//X }
#ifndef QT_NO_PHONON_ABSTRACTMEDIASTREAM
if (d->mediaSource.type() == MediaSource::Stream) {
Q_ASSERT(d->mediaSource.stream());
d->mediaSource.stream()->d_func()->setMediaObjectPrivate(d);
}
#endif //QT_NO_PHONON_ABSTRACTMEDIASTREAM
INTERFACE_CALL(setSource(d->mediaSource));
}
示例14: removeSourceBufferCallback
static v8::Handle<v8::Value> removeSourceBufferCallback(const v8::Arguments& args)
{
if (args.Length() < 1)
return throwNotEnoughArgumentsError(args.GetIsolate());
MediaSource* imp = V8MediaSource::toNative(args.Holder());
ExceptionCode ec = 0;
{
V8TRYCATCH(SourceBuffer*, buffer, V8SourceBuffer::HasInstance(MAYBE_MISSING_PARAMETER(args, 0, DefaultIsUndefined)) ? V8SourceBuffer::toNative(v8::Handle<v8::Object>::Cast(MAYBE_MISSING_PARAMETER(args, 0, DefaultIsUndefined))) : 0);
imp->removeSourceBuffer(buffer, ec);
if (UNLIKELY(ec))
goto fail;
return v8Undefined();
}
fail:
return setDOMException(ec, args.GetIsolate());
}
示例15: data
void MediaSourceTest::testIODevice()
{
const QByteArray data("0192380");
QBuffer *buffer = new QBuffer;
buffer->setData(data);
buffer->open(QIODevice::ReadOnly);
MediaSource a(buffer);
QCOMPARE(a.type(), MediaSource::Stream);
QCOMPARE(a.fileName(), QString());
QCOMPARE(a.url(), QUrl());
QCOMPARE(a.discType(), Phonon::NoDisc);
QVERIFY(a.stream() != 0);
QCOMPARE(a.deviceName(), QString());
//QCOMPARE(a.audioCaptureDevice(), AudioCaptureDevice());
//QCOMPARE(a.videoCaptureDevice(), VideoCaptureDevice());
MediaSource b(a);
MediaSource c;
c = a;
QCOMPARE(a, b);
QCOMPARE(a, c);
QCOMPARE(b, c);
QCOMPARE(b.type(), MediaSource::Stream);
QCOMPARE(b.fileName(), QString());
QCOMPARE(b.url(), QUrl());
QCOMPARE(b.discType(), Phonon::NoDisc);
QVERIFY(b.stream() != 0);
QCOMPARE(b.deviceName(), QString());
//QCOMPARE(b.audioCaptureDevice(), AudioCaptureDevice());
//QCOMPARE(b.videoCaptureDevice(), VideoCaptureDevice());
QCOMPARE(c.type(), MediaSource::Stream);
QCOMPARE(c.fileName(), QString());
QCOMPARE(c.url(), QUrl());
QCOMPARE(c.discType(), Phonon::NoDisc);
QVERIFY(c.stream() != 0);
QCOMPARE(c.deviceName(), QString());
//QCOMPARE(c.audioCaptureDevice(), AudioCaptureDevice());
//QCOMPARE(c.videoCaptureDevice(), VideoCaptureDevice());
delete buffer;
QCOMPARE(a.type(), MediaSource::Invalid);
QCOMPARE(b.type(), MediaSource::Invalid);
QCOMPARE(c.type(), MediaSource::Invalid);
const AbstractMediaStream *null = 0;
QCOMPARE(a.stream(), null);
QCOMPARE(b.stream(), null);
QCOMPARE(c.stream(), null);
}