The court also encouraged the Maryland General Assembly to consider changing the law.

Maryland's child pornography laws apply when the child is both the subject and sender of sexually explicit material, the state's highest court ruled Wednesday, in a case testing how to treat teenagers who voluntarily self-produce and share their own images.

The case before the Maryland Court of Appeals began with a teenage girl who texted friends a one-minute graphic video of herself, and comes as law enforcement officials, judges and legislators throughout the country are struggling with how to reconcile laws crafted before the era of cellphone videos with evolving technology and teen behavior.

The question for the court, as Judge Joseph Getty wrote for the majority: "Can a minor legally engaged in consensual sexual activity be his or her own pornographer through the act of sexting?"

The high court's ruling upholds an earlier decision from the state's Court of Special Appeals - which is one step below the top court - in finding that state lawmakers did not include exceptions in the law for consensual sex or for self-produced child pornography.

But the court also encouraged the Maryland General Assembly to consider changing the law.

"This case presents a unique challenge. On the one hand, there is no question that the State has an overwhelming interest in preventing the spread of child pornography," the court said in a 35-page opinion. "On the other hand," the teen "albeit unwisely, engaged in the same behavior as many of her peers."

Even as the court found the law "all encompassing" to include minors, the judges said that "we recognize that there may be compelling policy reasons for treating teenage sexting different from child pornography" and it urged the General Assembly to consider such legislation.

The lone dissenter, Judge Michele Hotten, wrote that the law was intended to "protect children from exploitation and abuse," not to criminalize consensual sex between minors.

The teen was "not being exploited by someone else," Hotten wrote. "The General Assembly did not seek to subject minors who recorded themselves in non-exploitative sexual encounters to prosecution."

The case began in October 2016, when the then-16-year-old, referred to by her initials in court records, shared a video she made with a three-person group text chain - another 16-year-old girl and a 17-year-old boy - best friends, the court said, attending Maurice McDonough High. She expected the text would stay private.

But the group "fell off as friends" a few months later, according to court records, and the students who received the text shared a copy with their school resource officer from the Charles County Sheriff's Office.

The girl who shared the video of herself performing a sex act on an unidentified male was the only teen charged, according to the county prosecutor. Because her case on the distribution of child pornography was in juvenile court, the teen never faced a mandatory sentence or the possibility of having to register as a sex offender.

In May 2017, she was put on probation, electronic monitoring and had to undergo weekly drug testing, according to the court's opinion.

On appeal in February, the teen's lawyer from the Maryland's Office of the Public Defender, Claudia Cortese, said that the teen's conduct was voluntary and legal. Letting the decision stand against the girl would amount to convicting her as her own pornographer, the girl's lawyers wrote.

Maryland Assistant Attorney General Sarah Pritzlaff responded in filings that the court should not ignore the possible harm to the teen from her shared video. Overturning the conviction, she wrote, would disregard the legislature's interest in protecting minors and stopping child pornography.

On a separate issue, the court ruled Wednesday that the teen was responsible for "displaying obscene material" to a minor even though the law does not specifically list the technology she used - a digital video file - to share the material.