这两个概念完全不同吗?或者它们的含义是否有重叠?
说Web框架用于创建前端,而CMS用于后端是否正确?
如果是,那么Web框架应该使用与CMS相同的技术吗?例如,Ruby on Rails可以与Drupal结合使用吗?或者根本没有任何意义?
我想创建一个Qt小部件,可以播放传入的RTP流,其中视频编码为H264并且不包含音频.
我的实施基本计划如下:
我的环境:
我的问题:
编辑
我找到的一个解决方案是将libVLC与Qt结合使用,我在这个帖子中学到了这个.这是感兴趣的代码示例.我还在寻找基于Phonon的解决方案.
理想情况下,我只需要提供一个SDP文件并完成工作.
我正在开发一个GStreamer应用程序,并为实现传入RTP流的播放器而苦苦挣扎.我正在尝试围绕gstrtpbin元素构建一个管道.我正在尝试使用gst-launch构造对管道进行建模:
VIDEO_CAPS="application/x-rtp,media=(string)video,clock-rate=(int)90000,encoding-name=(string)H264"
gst-launch -v udpsrc caps=$VIDEO_CAPS port=4444 \
! gstrtpbin .recv_rtp_sink_0 \
! rtph264depay ! ffdec_h264 ! xvimagesink
Run Code Online (Sandbox Code Playgroud)
当我启动脚本时,GStreamer报告这些错误:
Setting pipeline to PAUSED ...
Pipeline is live and does not need PREROLL ...
Setting pipeline to PLAYING ...
/GstPipeline:pipeline0/GstRtpBin:rtpbin0/GstRtpSession:rtpsession0: ntp-ns-base = 3469468914024449000
New clock: GstSystemClock
/GstPipeline:pipeline0/GstRtpBin:rtpbin0/GstRtpSession:rtpsession0.GstPad:recv_rtp_sink: caps = application/x-rtp, media=(string)video, clock-rate=(int)90000, encoding-name=(string)H264
/GstPipeline:pipeline0/GstRtpBin:rtpbin0.GstGhostPad:recv_rtp_sink_0: caps = application/x-rtp, media=(string)video, clock-rate=(int)90000, encoding-name=(string)H264
/GstPipeline:pipeline0/GstRtpBin:rtpbin0.GstGhostPad:recv_rtp_sink_0.GstProxyPad:proxypad0: caps = application/x-rtp, media=(string)video, clock-rate=(int)90000, encoding-name=(string)H264
/GstPipeline:pipeline0/GstRtpBin:rtpbin0/GstRtpSession:rtpsession0.GstPad:recv_rtp_src: caps = application/x-rtp, media=(string)video, clock-rate=(int)90000, encoding-name=(string)H264
/GstPipeline:pipeline0/GstRtpBin:rtpbin0/GstRtpSsrcDemux:rtpssrcdemux0.GstPad:sink: caps = application/x-rtp, media=(string)video, clock-rate=(int)90000, encoding-name=(string)H264 …Run Code Online (Sandbox Code Playgroud) 作为一名C++程序员,我有时需要使用C语言处理内存缓冲区.例如:
char buffer[512];
sprintf(buffer, "Hello %s!", userName.c_str());
Run Code Online (Sandbox Code Playgroud)
或者在Windows中:
TCHAR buffer[MAX_PATH+1]; // edit: +1 added
::GetCurrentDirectory(sizeof(buffer)/sizeof(TCHAR), &buffer[0]);
Run Code Online (Sandbox Code Playgroud)
上面的示例是我通常如何创建本地缓冲区(本地堆栈分配的char数组).但是,有许多可能的变化,因此我对您对以下问题的答案非常感兴趣:
&buffer[0]比传递更好的编程风格buffer?(我更喜欢&buffer[0].)static char buffer[N];)更快吗?是否还有其他论据支持或反对?const char *.这(通常)是好还是坏?(我确实意识到调用者需要自己创建副本以避免下一次调用会改变之前的返回值.)static char * buffer = new char[N];,永远不要删除缓冲区并在每次调用时重复使用它.sprintf_s,memcpy_s......变种?(Visual Studio一直试图让我相信这一点很长时间,但我想要第二个意见:p)errno处理相同错误时多次调用是否安全.或者使用本地副本更安全?
这个例子说明了我的问题:
// If recvfrom() fails it returns -1 and sets errno to indicate the error.
int res = recvfrom(...);
if (res < 0)
{
// Risky?
printf("Error code: %d. Error message: %s\n", errno, strerror(errno));
// Safer alternative?
int errorNumber = errno;
printf("Error code: %d. Error message: %s\n", errorNumber, strerror(errorNumber));
}
Run Code Online (Sandbox Code Playgroud) 我正在尝试编译-Werror在现有代码库中引入标志.我遇到的一个问题是在某些地方#warning用于显示信息性消息.这些不应被视为错误.
一种解决方案是使用#pragma message,但旧版本的gcc似乎并不支持这种解决方案.(我们的构建服务器使用gcc 4.1.2).
谁能帮我解决这个问题?
根据规范,不允许使用带有前导下划线的全局名称:
17.4.3.1.2全局名称
- 以下划线开头的每个名称都保留给实现,以用作全局名称空间中的名称.
这是否也适用于顶级匿名命名空间中定义的名称?
这是通用原子交换函数的正确实现吗?我正在寻找GCC上兼容C++ 03的解决方案.
template<typename T>
void atomic_swap(T & a, T & b) {
static_assert(sizeof(T) <= sizeof(void*), "Maximum size type exceeded.");
T * ptr = &a;
b =__sync_lock_test_and_set(ptr, b);
__sync_lock_release(&ptr);
}
Run Code Online (Sandbox Code Playgroud)
如果没有,我该怎么做才能修复它?
另外:__sync_lock_release总是必要的吗?在搜索其他代码库时,我发现通常不会调用它.没有发布调用,我的代码如下所示:
template<typename T>
void atomic_swap(T & a, T & b) {
static_assert(sizeof(T) <= sizeof(void*), "Maximum size type exceeded.");
b = __sync_lock_test_and_set(&a, b);
}
Run Code Online (Sandbox Code Playgroud)
PS:GNU C++中的原子交换是一个类似的问题,但它没有回答我的问题,因为提供的答案需要C++ 11,std::atomic并且它具有签名Data *swap_data(Data *new_data),对于swap函数而言似乎没有任何意义.(它实际上将提供的参数与在函数之前定义的全局变量交换.)
在下面的程序中,由于依赖指令,我希望test1运行得更慢.用-O2测试运行似乎证实了这一点.但后来我尝试使用-O3,现在时间或多或少相等.怎么会这样?
#include <iostream>
#include <vector>
#include <cstring>
#include <chrono>
volatile int x = 0; // used for preventing certain optimizations
enum { size = 60 * 1000 * 1000 };
std::vector<unsigned> a(size + x); // `size + x` makes the vector size unknown by compiler
std::vector<unsigned> b(size + x);
void test1()
{
for (auto i = 1u; i != size; ++i)
{
a[i] = a[i] + a[i-1]; // data dependency hinders pipelining(?)
}
}
void test2()
{
for (auto i …Run Code Online (Sandbox Code Playgroud) 从二进制数据读取整数时,我注意到memcpy比铸造解决方案慢.
版本1:reinterpret_cast,由于潜在的对齐问题而臭,但也更快(?)
int get_int_v1(const char * data) { return *reinterpret_cast<const int*>(data); }
Run Code Online (Sandbox Code Playgroud)
版本2:memcpy,正确且稍慢:
int get_int_v2(const char * data) { int result; memcpy(&result, data, sizeof(result)); return result; }
Run Code Online (Sandbox Code Playgroud)
供将来参考,代码是:
#include <cstdlib>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <iostream>
#include <vector>
#include <sys/time.h>
double get_current_time()
{
timeval tv;
gettimeofday(&tv, NULL);
return double (tv.tv_sec) + 0.000001 * tv.tv_usec;
}
int get_int_v1(const char * data) { return *reinterpret_cast<const int*>(data); }
int get_int_v2(const char * data) { …Run Code Online (Sandbox Code Playgroud)