
|
|
Auteur
|
Message
|
1
|
|
|
|
Bonjour,
J'ai le problème suivant quand je crée un nouveau objet avec l'opérateur new de C++ :
terminate called after throwing an instance of 'std::logic_error'
what(): basic_string::_S_construct NULL not valid
Abandon
Est ce que quelqu'un a une idée comment résoudre le pb ?
Merci
|
|
Je calcul donc je suis relativ
|
|
|
T'as un bout de code?
quel est le compilo, et c'est sur LInux??
comment t'as fais l'allocation?? comment tu l'tuilise..
quand t'utilse new, t'utilise aussi delete pour libèrer la ressource lorsqu'elle est plus nécéssaire??
plus de détails! (tant quien a)
-->Message édité par esselfe le 30/11/2006 13:16:37<--
-------
vive Linux!
|
|
|
|
|
J'utilise Linux Mandriva 2006, compilateur g++, un processeur dual core Dell Presicion 390.
Je traite dans mon code la transmission multimédia avec le protocole RTP.
et donc au moment ou j'appelle new donc ca bloque ....
voilà le code :
//Create the connexion to the destination
void RelayIn::connectDestination(const char* IP, unsigned short RTPPortNum, const char* codec, const char* protocol){
string id = to_string(IP) + ":" + to_string(RTPPortNum);
//TODO : gérer la compatibilité des codecs : Pblm lors de la récupération avec getCodec()
if((in!=NULL) && (strcasecmp(in->getCodec(),codec) != 0))
{
CodecException e(1); // throw an CodecCompatibilityException
throw e;
}
else
{ // LOME (03/11/2006) : OK gestion mise en place au sein de la méthode "defineCurrentSource"...
if(out != NULL)
{
LOG4CXX_WARN(logger, "Automatically trying to disconnect old destination");
disconnectDestination();
}
// RABIH - Connecter la destination
// bloque ici durant l'appel de new
out = new ConnexionOut(IP,RTPPortNum,env,codec,protocol);
LOG4CXX_INFO(logger, "New destination ("+id+","+out->getCodec()+") connected") ;
// RABIH - Si l'entrée existe alors transmettre
if(in!=NULL)
{
LOG4CXX_INFO(logger, "Transmitting current source") ;
out->transmit(in->getSource());
}
else
{
LOG4CXX_WARN(logger, "No source to transmit") ;
}
}
la classe connexioOut est le suivant :
#include "ConnexionOut.h"
//Constructor : Create RTP Connexion to the Destination "IP:port"
ConnexionOut::ConnexionOut(const char* IP, unsigned short RTPPortNum,UsageEnvironment* e, const char* codec, const char* protocol):ip(IP),rtpPortNum(RTPPortNum),codec(codec),protocol(protocol){
LOG4CXX_DEBUG(logger, "ConnexionOut(IP,RTPPortNum,env,codec,protocol)");
env = e;
//*env << IP << ":" << RTPPortNum;
// Create 'groupsocks' for RTP and RTCP:
struct in_addr destinationAddress;
destinationAddress.s_addr = our_inet_addr(IP);
const Port rtpPort(RTPPortNum);
const Port rtcpPort(RTPPortNum+1);
const unsigned char ttl = 255;
rtpGroupsock = new Groupsock(*env, destinationAddress, rtpPort, ttl);
rtcpGroupsock = new Groupsock(*env, destinationAddress, rtcpPort, ttl);
//Le commentaire ci-dessous permet de deciderle port d'arrivée, sinon, le meme que celui de depart (en sortie du relai)
/* struct in_addr destinationAddressBis;
destinationAddressBis.s_addr = our_inet_addr("10.194.5.180");
rtpGroupsock->addDestination(destinationAddress, Port(2344));
rtcpGroupsock->addDestination(destinationAddress, Port(2345));*/
// Create an appropriate audio RTP sink (using a modified "SimpleRTPSink" (à terme))
// from the RTP 'groupsock':
// LOME (02/11/2006) :
// if (codec == "MPA"){
// if(this->codec.compare(MPEG_AUDIO) == 0){
if(strcasecmp(this->codec.c_str(),MPEG_AUDIO) == 0){
sink = MPEG1or2AudioRTPSink::createNew(*env, rtpGroupsock);
// LOME (02/11/2006) :
// }else if (codec == "MPV"){
// }else if(this->codec.compare(MPEG_VIDEO) == 0){
}else if(strcasecmp(this->codec.c_str(),MPEG_VIDEO) == 0){
sink = MPEG1or2VideoRTPSink::createNew(*env, rtpGroupsock);
// LOME (08/11/2006) : gestion du flux Transport Stream...
// }else if(this->codec.compare(MPEG_TS) == 0){
}else if(strcasecmp(this->codec.c_str(),MPEG_TS) == 0){
sink = SimpleRTPSink::createNew(*env, rtpGroupsock, 33, 90000, "video", "mp2t", 1, True, False /*no 'M' bit*/);
// FIN LOME (08/11/2006)...
}else{
CodecException e(0);
throw(e);
}
const unsigned estimatedSessionBandwidth = 160; // in kbps; for RTCP b/w share
const unsigned maxCNAMElen = 100;
unsigned char CNAME[maxCNAMElen+1];
gethostname((char*)CNAME, maxCNAMElen);
CNAME[maxCNAMElen] = '\0'; // just in case
//RTCP Instance
rtcpInstance = RTCPInstance::createNew(*env, rtcpGroupsock, estimatedSessionBandwidth, CNAME,sink, NULL /* server */, False /* Unicast */);
// Note: This starts RTCP running automatically
//*env << " Destination RTP Connexion Actived\n";
}
ConnexionOut::~ConnexionOut()
{
Medium::close(rtcpInstance);
Medium::close(sink);
delete rtpGroupsock;
delete rtcpGroupsock;
}
void ConnexionOut::transmit(FramedSource* source){
LOG4CXX_DEBUG(logger, "ConnexionOut::transmit(src)");
//Begin The Transmission
// LOME (02/11/2006) :
// if(!strcmp(codec, "MPA")){
// if(this->codec.compare(MPEG_AUDIO) == 0){
if(strcasecmp(this->codec.c_str(),MPEG_AUDIO) == 0){
sink->startPlaying(*source, NULL, NULL);
// LOME (02/11/2006) :
// }else if(!strcmp(codec, "MPV")){
// }else if(this->codec.compare(MPEG_VIDEO) == 0){
}else if(strcasecmp(this->codec.c_str(),MPEG_VIDEO) == 0){
MPEG1or2VideoStreamFramer* videoSource = MPEG1or2VideoStreamDiscreteFramer::createNew(*env, source, false);
sink->startPlaying(*videoSource, NULL, NULL);
// LOME (08/11/2006) : gestion du flux Transport Stream...
// }else if(this->codec.compare(MPEG_TS) == 0){
}else if(strcasecmp(this->codec.c_str(),MPEG_TS) == 0){
sink->startPlaying(*source, NULL, NULL);
// FIN LOME (08/11/2006)...
}else{
CodecException e(0);
throw(e);
}
}
void ConnexionOut::stopTransmit(){
LOG4CXX_DEBUG(logger, "ConnexionOut::stopTransmit()");
//Stop the transmission
sink->stopPlaying();
}
//Execution after the transmission
void ConnexionOut::afterTransmit(void* clientData){
*env << "Relaying Finished (Connexion Still Active)\n";
}
|
|
Je calcul donc je suis relativ
|
|
|
au premier coup d'eoil, 'out' n'est pas déclaré et tu tente de le définir.
la définition de in est correcte?
-------
vive Linux!
|
|
|
|
|
C'est bon j'ai résolu le problème....
il y avait un NULL pointer quelque part
Merci
|
|
1
|
|

|


|