예제 #1
0
파일: echo.cpp 프로젝트: aopui/gnash
// format a response to the 'echo' test used for testing Gnash. This
// is only used for testing by developers. The format appears to be
// a string '_result', followed by the number of the test, and then two
// NULL objects.
std::shared_ptr<cygnal::Buffer>
EchoTest::formatEchoResponse(double num, cygnal::Element &el)
{
//    GNASH_REPORT_FUNCTION;
    std::shared_ptr<cygnal::Buffer> data = cygnal::AMF::encodeElement(el);
    if (data) {
	return formatEchoResponse(num, data->reference(), data->allocated());
    } else {
	log_error("Couldn't encode element: %s", el.getName());
	el.dump();
    }

    return data;
}
예제 #2
0
파일: element.cpp 프로젝트: aopui/gnash
size_t
Element::calculateSize(cygnal::Element &el) const
{
//    GNASH_REPORT_FUNCTION;    
    size_t outsize = 0;

    // Simple Elements have everything contained in just the class itself.
    // If thr name is set, it's a property, so the length is
    // prefixed to the name string.
    if (el.getNameSize()) {
	outsize += el.getNameSize() + sizeof(std::uint16_t);
    }
    // If there is any data, then the size of the data plus the header
    // of the type and the length is next.
    if (el.getDataSize()) {
	outsize += el.getDataSize() + AMF_HEADER_SIZE;
    }

    // If an array has no data, it's undefined, so has a length of zero.
    if (el.getType() == Element::STRICT_ARRAY_AMF0) {
	if (el.getDataSize() == 0) {
	    outsize = sizeof(std::uint32_t) + 1;
	}
    }
    
    // More complex messages have child elements, either properties or
    // the items in an array, If we have children, count up their size too.
    // Calculate the total size of the message
    std::vector<std::shared_ptr<cygnal::Element> > props = el.getProperties();
    for (size_t i=0; i<props.size(); i++) {
	outsize += props[i]->getDataSize();
	if (props[i]->getNameSize()) {
	    outsize += props[i]->getNameSize();
	    outsize += cygnal::AMF_PROP_HEADER_SIZE;
	} else {
	    outsize += cygnal::AMF_HEADER_SIZE;
	}
    }

    return outsize;
}
예제 #3
0
파일: rtmp.cpp 프로젝트: BrandRegard/gnash
void
RTMP::addProperty(cygnal::Element &el)
{
//    GNASH_REPORT_FUNCTION;
    _properties[el.getName()] = el;
}